├── data.js ├── index.html ├── iterators.js ├── iteratorsSpec.js ├── lib ├── chai.js ├── mocha.css └── mocha.js └── readme.md /data.js: -------------------------------------------------------------------------------- 1 | var songs = [{ 2 | name: "Smooth", 3 | artist: "Santana featuring Rob Thomas", 4 | year: 1999, 5 | month: 10, 6 | day: 23, 7 | weeksAtNumberOne: 12, 8 | duration: "4:00" 9 | }, { 10 | name: "What a Girl Wants", 11 | artist: "Christina Aguilera", 12 | year: 2000, 13 | month: 1, 14 | day: 15, 15 | weeksAtNumberOne: 2, 16 | duration: "3:20" 17 | }, { 18 | name: "I Knew I Loved You", 19 | artist: "Savage Garden", 20 | year: 2000, 21 | month: 1, 22 | day: 29, 23 | weeksAtNumberOne: 4, 24 | duration: "4:10" 25 | }, { 26 | name: "Thank God I Found You", 27 | artist: "Mariah Carey featuring Joe and 98 Degrees", 28 | year: 2000, 29 | month: 2, 30 | day: 19, 31 | weeksAtNumberOne: 2, 32 | duration: "4:17" 33 | }, { 34 | name: "Amazed", 35 | artist: "Lonestar", 36 | year: 2000, 37 | month: 3, 38 | day: 4, 39 | weeksAtNumberOne: 2, 40 | duration: "4:00" 41 | }, { 42 | name: "Say My Name", 43 | artist: "Destiny's Child", 44 | year: 2000, 45 | month: 3, 46 | day: 18, 47 | weeksAtNumberOne: 3, 48 | duration: "4:31" 49 | }, { 50 | name: "Maria Maria", 51 | artist: "Santana featuring The Product G&B", 52 | year: 2000, 53 | month: 4, 54 | day: 8, 55 | weeksAtNumberOne: 10, 56 | duration: "4:23" 57 | }, { 58 | name: "Try Again", 59 | artist: "Aaliyah", 60 | year: 2000, 61 | month: 6, 62 | day: 17, 63 | weeksAtNumberOne: 1, 64 | duration: "4:49" 65 | }, { 66 | name: "Be With You", 67 | artist: "Enrique Iglesias", 68 | year: 2000, 69 | month: 6, 70 | day: 24, 71 | weeksAtNumberOne: 3, 72 | duration: "3:40" 73 | }, { 74 | name: "Everything You Want", 75 | artist: "Vertical Horizon", 76 | year: 2000, 77 | month: 7, 78 | day: 15, 79 | weeksAtNumberOne: 1, 80 | duration: "4:06" 81 | }, { 82 | name: "Bent", 83 | artist: "Matchbox Twenty", 84 | year: 2000, 85 | month: 7, 86 | day: 22, 87 | weeksAtNumberOne: 1, 88 | duration: "4:16" 89 | }, { 90 | name: "It's Gonna Be Me", 91 | artist: "NSYNC", 92 | year: 2000, 93 | month: 7, 94 | day: 29, 95 | weeksAtNumberOne: 2, 96 | duration: "3:12" 97 | }, { 98 | name: "Incomplete", 99 | artist: "Sisqo", 100 | year: 2000, 101 | month: 8, 102 | day: 12, 103 | weeksAtNumberOne: 2, 104 | duration: "4:12" 105 | }, { 106 | name: "Doesn't Really Matter", 107 | artist: "Janet Jackson", 108 | year: 2000, 109 | month: 8, 110 | day: 26, 111 | weeksAtNumberOne: 3, 112 | duration: "4:25" 113 | }, { 114 | name: "Music", 115 | artist: "Madonna", 116 | year: 2000, 117 | month: 9, 118 | day: 16, 119 | weeksAtNumberOne: 4, 120 | duration: "3:44" 121 | }, { 122 | name: "Come On Over Baby (All I Want Is You)", 123 | artist: "Christina Aguilera", 124 | year: 2000, 125 | month: 8, 126 | day: 26, 127 | weeksAtNumberOne: 4, 128 | duration: "3:23" 129 | }, { 130 | name: "With Arms Wide Open", 131 | artist: "Creed", 132 | year: 2000, 133 | month: 11, 134 | day: 11, 135 | weeksAtNumberOne: 1, 136 | duration: "3:53" 137 | }, { 138 | name: "Independent Woman Part I", 139 | artist: "Destiny's Child", 140 | year: 2000, 141 | month: 11, 142 | day: 18, 143 | weeksAtNumberOne: 11, 144 | duration: "3:37" 145 | }, { 146 | name: "It Wasn't Me", 147 | artist: "Shaggy featuring Ricardo \"RikRok\" Ducent", 148 | year: 2001, 149 | month: 2, 150 | day: 3, 151 | weeksAtNumberOne: 2, 152 | duration: "3:47" 153 | }, { 154 | name: "Ms. Jackson", 155 | artist: "OutKast", 156 | year: 2001, 157 | month: 2, 158 | day: 17, 159 | weeksAtNumberOne: 1, 160 | duration: "4:03" 161 | }, { 162 | name: "Stutter", 163 | artist: "Joe featuring Mystikal", 164 | year: 2001, 165 | month: 2, 166 | day: 24, 167 | weeksAtNumberOne: 4, 168 | duration: "3:33" 169 | }, { 170 | name: "Butterfly", 171 | artist: "Crazy Town", 172 | year: 2001, 173 | month: 3, 174 | day: 24, 175 | weeksAtNumberOne: 2, 176 | duration: "3:36" 177 | }, { 178 | name: "Angel", 179 | artist: "Shaggy featuring Rayvon", 180 | year: 2001, 181 | month: 3, 182 | day: 31, 183 | weeksAtNumberOne: 1, 184 | duration: "3:31" 185 | }, { 186 | name: "All for You", 187 | artist: "Janet Jackson", 188 | year: 2001, 189 | month: 4, 190 | day: 14, 191 | weeksAtNumberOne: 7, 192 | duration: "4:24" 193 | }, { 194 | name: "Lady Marmalade", 195 | artist: "Christina Aguilera, Lil' Kim, Mya, and Pink", 196 | year: 2001, 197 | month: 6, 198 | day: 2, 199 | weeksAtNumberOne: 5, 200 | duration: "4:24" 201 | }, { 202 | name: "U Remind Me", 203 | artist: "Usher", 204 | year: 2001, 205 | month: 7, 206 | day: 7, 207 | weeksAtNumberOne: 4, 208 | duration: "4:27" 209 | }, { 210 | name: "Bootylicious", 211 | artist: "Destiny's Child", 212 | year: 2001, 213 | month: 8, 214 | day: 4, 215 | weeksAtNumberOne: 2, 216 | duration: "3:27" 217 | }, { 218 | name: "Fallin", 219 | artist: "Alicia Keys", 220 | year: 2001, 221 | month: 8, 222 | day: 18, 223 | weeksAtNumberOne: 6, 224 | duration: "3:30" 225 | }, { 226 | name: "I'm Real", 227 | artist: "Jennifer Lopez featuring Ja Rule", 228 | year: 2001, 229 | month: 9, 230 | day: 8, 231 | weeksAtNumberOne: 5, 232 | duration: "4:15" 233 | }, { 234 | name: "Family Affair", 235 | artist: "Mary J. Blige", 236 | year: 2001, 237 | month: 11, 238 | day: 3, 239 | weeksAtNumberOne: 6, 240 | duration: "4:04" 241 | }, { 242 | name: "U Got It Bad", 243 | artist: "Usher", 244 | year: 2001, 245 | month: 12, 246 | day: 15, 247 | weeksAtNumberOne: 6, 248 | duration: "4:07" 249 | }, { 250 | name: "How You Remind Me", 251 | artist: "Nickelback", 252 | year: 2001, 253 | month: 12, 254 | day: 22, 255 | weeksAtNumberOne: 4, 256 | duration: "3:43" 257 | }, { 258 | name: "Always on Time", 259 | artist: "Ja Rule featuring Ashanti", 260 | year: 2002, 261 | month: 2, 262 | day: 23, 263 | weeksAtNumberOne: 2, 264 | duration: "4:05" 265 | }, { 266 | name: "Ain't It Funny", 267 | artist: "Jennifer Lopez featuring Ja Rule", 268 | year: 2002, 269 | month: 3, 270 | day: 9, 271 | weeksAtNumberOne: 6, 272 | duration: "3:36" 273 | }, { 274 | name: "Foolish", 275 | artist: "Ashanti", 276 | year: 2002, 277 | month: 4, 278 | day: 20, 279 | weeksAtNumberOne: 10, 280 | duration: "3:47" 281 | }, { 282 | name: "Hot in Herre", 283 | artist: "Nelly", 284 | year: 2002, 285 | month: 6, 286 | day: 29, 287 | weeksAtNumberOne: 7, 288 | duration: "3:49" 289 | }, { 290 | name: "Dilemma", 291 | artist: "Nelly featuring Kelly Rowland", 292 | year: 2002, 293 | month: 8, 294 | day: 17, 295 | weeksAtNumberOne: 10, 296 | duration: "3:55" 297 | }, { 298 | name: "A Moment Like This", 299 | artist: "Kelly Clarkson", 300 | year: 2002, 301 | month: 10, 302 | day: 5, 303 | weeksAtNumberOne: 2, 304 | duration: "3:49" 305 | }, { 306 | name: "Lose Yourself", 307 | artist: "Eminem", 308 | year: 2002, 309 | month: 11, 310 | day: 9, 311 | weeksAtNumberOne: 12, 312 | duration: "4:27" 313 | }, { 314 | name: "Bump, Bump, Bump", 315 | artist: "B2K featuring P. Diddy", 316 | year: 2003, 317 | month: 2, 318 | day: 1, 319 | weeksAtNumberOne: 1, 320 | duration: "3:56" 321 | }, { 322 | name: "All I Have", 323 | artist: "Jennifer Lopez featuring LL Cool J", 324 | year: 2003, 325 | month: 2, 326 | day: 8, 327 | weeksAtNumberOne: 4, 328 | duration: "4:17" 329 | }, { 330 | name: "In da Club", 331 | artist: "50 Cent", 332 | year: 2003, 333 | month: 3, 334 | day: 8, 335 | weeksAtNumberOne: 9, 336 | duration: "3:40" 337 | }, { 338 | name: "Get Busy", 339 | artist: "Sean Paul", 340 | year: 2003, 341 | month: 5, 342 | day: 10, 343 | weeksAtNumberOne: 3, 344 | duration: "3:32" 345 | }, { 346 | name: "21 Questions", 347 | artist: "50 Cent featuring Nate Dogg", 348 | year: 2003, 349 | month: 5, 350 | day: 31, 351 | weeksAtNumberOne: 4, 352 | duration: "3:44" 353 | }, { 354 | name: "This Is the Night", 355 | artist: "Clay Aiken", 356 | year: 2003, 357 | month: 6, 358 | day: 28, 359 | weeksAtNumberOne: 2, 360 | duration: "3:32" 361 | }, { 362 | name: "Crazy in Love", 363 | artist: "Beyonce featuring Jay-Z", 364 | year: 2003, 365 | month: 7, 366 | day: 12, 367 | weeksAtNumberOne: 8, 368 | duration: "3:56" 369 | }, { 370 | name: "Shake Ya Tailfeather", 371 | artist: "Nelly, P. Diddy, and Murphy Lee", 372 | year: 2003, 373 | month: 9, 374 | day: 6, 375 | weeksAtNumberOne: 4, 376 | duration: "4:53" 377 | }, { 378 | name: "Baby Boy", 379 | artist: "Beyonce featuring Sean Paul", 380 | year: 2003, 381 | month: 10, 382 | day: 4, 383 | weeksAtNumberOne: 9, 384 | duration: "4:04" 385 | }, { 386 | name: "Stand Up", 387 | artist: "Ludacris featuring Shawna", 388 | year: 2003, 389 | month: 12, 390 | day: 6, 391 | weeksAtNumberOne: 1, 392 | duration: "3:33" 393 | }, { 394 | name: "Hey Ya!", 395 | artist: "OutKast", 396 | year: 2003, 397 | month: 12, 398 | day: 13, 399 | weeksAtNumberOne: 9, 400 | duration: "3:55" 401 | }, { 402 | name: "The Way You Move", 403 | artist: "OutKast featuring Sleepy Brown", 404 | year: 2004, 405 | month: 2, 406 | day: 14, 407 | weeksAtNumberOne: 1, 408 | duration: "3:55" 409 | }, { 410 | name: "Slow Jamz", 411 | artist: "Twista featuring Kanye West and Jamie Foxx", 412 | year: 2004, 413 | month: 2, 414 | day: 21, 415 | weeksAtNumberOne: 1, 416 | duration: "3:34" 417 | }, { 418 | name: "Yeah!", 419 | artist: "Usher featuring Lil Jon and Ludacris", 420 | year: 2004, 421 | month: 2, 422 | day: 28, 423 | weeksAtNumberOne: 12, 424 | duration: "4:10" 425 | }, { 426 | name: "Burn", 427 | artist: "Usher", 428 | year: 2004, 429 | month: 5, 430 | day: 22, 431 | weeksAtNumberOne: 8, 432 | duration: "4:15" 433 | }, { 434 | name: "I Believe", 435 | artist: "Fantasia", 436 | year: 2004, 437 | month: 7, 438 | day: 10, 439 | weeksAtNumberOne: 1, 440 | duration: "4:07" 441 | }, { 442 | name: "Confessions Part II", 443 | artist: "Usher", 444 | year: 2004, 445 | month: 7, 446 | day: 24, 447 | weeksAtNumberOne: 2, 448 | duration: "3:49" 449 | }, { 450 | name: "Slow Motion", 451 | artist: "Juvenile featuring Soulja Slim", 452 | year: 2004, 453 | month: 8, 454 | day: 7, 455 | weeksAtNumberOne: 2, 456 | duration: "4:08" 457 | }, { 458 | name: "Lean Back", 459 | artist: "Terror Squad", 460 | year: 2004, 461 | month: 8, 462 | day: 21, 463 | weeksAtNumberOne: 3, 464 | duration: "4:07" 465 | }, { 466 | name: "Goodies", 467 | artist: "Ciara featuring Petey Pablo", 468 | year: 2004, 469 | month: 9, 470 | day: 11, 471 | weeksAtNumberOne: 7, 472 | duration: "3:43" 473 | }, { 474 | name: "My Boo", 475 | artist: "Usher and Alicia Keys", 476 | year: 2004, 477 | month: 10, 478 | day: 30, 479 | weeksAtNumberOne: 6, 480 | duration: "3:42" 481 | }, { 482 | name: "Drop It Like It's Hot", 483 | artist: "Snoop Dogg featuring Pharrell", 484 | year: 2004, 485 | month: 12, 486 | day: 11, 487 | weeksAtNumberOne: 3, 488 | duration: "4:30" 489 | }, { 490 | name: "Let Me Love You", 491 | artist: "Mario", 492 | year: 2005, 493 | month: 1, 494 | day: 1, 495 | weeksAtNumberOne: 9, 496 | duration: "4:09" 497 | }, { 498 | name: "Candy Shop", 499 | artist: "50 Cent featuring Olivia", 500 | year: 2005, 501 | month: 3, 502 | day: 5, 503 | weeksAtNumberOne: 9, 504 | duration: "3:29" 505 | }, { 506 | name: "Hollaback Girl", 507 | artist: "Gwen Stefani", 508 | year: 2005, 509 | month: 5, 510 | day: 7, 511 | weeksAtNumberOne: 4, 512 | duration: "3:19" 513 | }, { 514 | name: "We Belong Together", 515 | artist: "Mariah Carey", 516 | year: 2005, 517 | month: 6, 518 | day: 4, 519 | weeksAtNumberOne: 14, 520 | duration: "3:21" 521 | }, { 522 | name: "Inside Your Heaven", 523 | artist: "Carrie Underwood", 524 | year: 2005, 525 | month: 7, 526 | day: 2, 527 | weeksAtNumberOne: 1, 528 | duration: "3:45" 529 | }, { 530 | name: "Gold Digger", 531 | artist: "Kanye West featuring Jamie Foxx", 532 | year: 2005, 533 | month: 9, 534 | day: 17, 535 | weeksAtNumberOne: 10, 536 | duration: "3:28" 537 | }, { 538 | name: "Run It!", 539 | artist: "Chris Brown", 540 | year: 2005, 541 | month: 11, 542 | day: 26, 543 | weeksAtNumberOne: 5, 544 | duration: "3:12" 545 | }, { 546 | name: "Don't Forget About Us", 547 | artist: "Mariah Carey", 548 | year: 2005, 549 | month: 12, 550 | day: 31, 551 | weeksAtNumberOne: 2, 552 | duration: "3:53" 553 | }, { 554 | name: "Laffy Taffy", 555 | artist: "D4L", 556 | year: 2006, 557 | month: 1, 558 | day: 14, 559 | weeksAtNumberOne: 1, 560 | duration: "3:44" 561 | }, { 562 | name: "Grillz", 563 | artist: "Nelly featuring Paul Wall, Ali & Gipp", 564 | year: 2006, 565 | month: 1, 566 | day: 21, 567 | weeksAtNumberOne: 2, 568 | duration: "4:30" 569 | }, { 570 | name: "Check on It", 571 | artist: "Beyonce featuring Slim Thug", 572 | year: 2006, 573 | month: 2, 574 | day: 4, 575 | weeksAtNumberOne: 5, 576 | duration: "3:30" 577 | }, { 578 | name: "You're Beautiful", 579 | artist: "James Blunt", 580 | year: 2006, 581 | month: 3, 582 | day: 11, 583 | weeksAtNumberOne: 1, 584 | duration: "3:22" 585 | }, { 586 | name: "So Sick", 587 | artist: "Ne-Yo", 588 | year: 2006, 589 | month: 3, 590 | day: 18, 591 | weeksAtNumberOne: 2, 592 | duration: "3:27" 593 | }, { 594 | name: "Temperature", 595 | artist: "Sean Paul", 596 | year: 2006, 597 | month: 4, 598 | day: 1, 599 | weeksAtNumberOne: 1, 600 | duration: "3:36" 601 | }, { 602 | name: "Bad Day", 603 | artist: "Daniel Powter", 604 | year: 2006, 605 | month: 4, 606 | day: 8, 607 | weeksAtNumberOne: 5, 608 | duration: "3:54" 609 | }, { 610 | name: "SOS", 611 | artist: "Rihanna", 612 | year: 2006, 613 | month: 5, 614 | day: 13, 615 | weeksAtNumberOne: 3, 616 | duration: "3:59" 617 | }, { 618 | name: "Ridin'", 619 | artist: "Chamillionaire featuring Krayzie Bone", 620 | year: 2006, 621 | month: 6, 622 | day: 3, 623 | weeksAtNumberOne: 2, 624 | duration: "4:08" 625 | }, { 626 | name: "Hips Don't Lie", 627 | artist: "Shakira featuring Wyclef Jean", 628 | year: 2006, 629 | month: 6, 630 | day: 17, 631 | weeksAtNumberOne: 2, 632 | duration: "3:38" 633 | }, { 634 | name: "Do I Make You Proud", 635 | artist: "Taylor Hicks", 636 | year: 2006, 637 | month: 7, 638 | day: 1, 639 | weeksAtNumberOne: 1, 640 | duration: "4:13" 641 | }, { 642 | name: "Promiscuous", 643 | artist: "Nelly Furtado featuring Timbaland", 644 | year: 2006, 645 | month: 7, 646 | day: 8, 647 | weeksAtNumberOne: 6, 648 | duration: "4:02" 649 | }, { 650 | name: "London Bridge", 651 | artist: "Fergie", 652 | year: 2006, 653 | month: 8, 654 | day: 19, 655 | weeksAtNumberOne: 3, 656 | duration: "3:28" 657 | }, { 658 | name: "SexyBack", 659 | artist: "Justin Timberlake", 660 | year: 2006, 661 | month: 9, 662 | day: 9, 663 | weeksAtNumberOne: 7, 664 | duration: "4:02" 665 | }, { 666 | name: "Money Maker", 667 | artist: "Ludacris featuring Pharrell", 668 | year: 2006, 669 | month: 10, 670 | day: 28, 671 | weeksAtNumberOne: 2, 672 | duration: "3:54" 673 | }, { 674 | name: "My Love", 675 | artist: "Justin Timberlake featuring T.I.", 676 | year: 2006, 677 | month: 11, 678 | day: 11, 679 | weeksAtNumberOne: 3, 680 | duration: "4:41" 681 | }, { 682 | name: "I Wanna Love You", 683 | artist: "Akon featuring Snoop Dogg", 684 | year: 2006, 685 | month: 12, 686 | day: 2, 687 | weeksAtNumberOne: 2, 688 | duration: "4:07" 689 | }, { 690 | name: "Irreplaceable", 691 | artist: "Beyonce", 692 | year: 2006, 693 | month: 12, 694 | day: 16, 695 | weeksAtNumberOne: 10, 696 | duration: "3:47" 697 | }, { 698 | name: "Say It Right", 699 | artist: "Nelly Furtado", 700 | year: 2007, 701 | month: 2, 702 | day: 24, 703 | weeksAtNumberOne: 1, 704 | duration: "3:43" 705 | }, { 706 | name: "What Goes Around...Comes Around", 707 | artist: "Justin Timberlake", 708 | year: 2007, 709 | month: 3, 710 | day: 3, 711 | weeksAtNumberOne: 1, 712 | duration: "5:09" 713 | }, { 714 | name: "This Is Why I'm Hot", 715 | artist: "Mims", 716 | year: 2007, 717 | month: 3, 718 | day: 10, 719 | weeksAtNumberOne: 2, 720 | duration: "4:13" 721 | }, { 722 | name: "Glamorous", 723 | artist: "Fergie featuring Ludacris", 724 | year: 2007, 725 | month: 3, 726 | day: 24, 727 | weeksAtNumberOne: 2, 728 | duration: "4:06" 729 | }, { 730 | name: "Don't Matter", 731 | artist: "Akon", 732 | year: 2007, 733 | month: 4, 734 | day: 7, 735 | weeksAtNumberOne: 2, 736 | duration: "4:54" 737 | }, { 738 | name: "Give It to Me", 739 | artist: "Timbaland featuring Nelly Furtado and Justin Timberlake", 740 | year: 2007, 741 | month: 4, 742 | day: 21, 743 | weeksAtNumberOne: 2, 744 | duration: "3:58" 745 | }, { 746 | name: "Girlfriend", 747 | artist: "Avril Lavigne", 748 | year: 2007, 749 | month: 5, 750 | day: 5, 751 | weeksAtNumberOne: 1, 752 | duration: "3:37" 753 | }, { 754 | name: "Makes Me Wonder", 755 | artist: "Maroon 5", 756 | year: 2007, 757 | month: 5, 758 | day: 12, 759 | weeksAtNumberOne: 3, 760 | duration: "3:31" 761 | }, { 762 | name: "Buy U a Drank (Shawty Snappin')", 763 | artist: "T-Pain featuring Yung Joc", 764 | year: 2007, 765 | month: 5, 766 | day: 26, 767 | weeksAtNumberOne: 1, 768 | duration: "3:48" 769 | }, { 770 | name: "Umbrella", 771 | artist: "Rihanna featuring Jay-Z", 772 | year: 2007, 773 | month: 6, 774 | day: 9, 775 | weeksAtNumberOne: 7, 776 | duration: "4:36" 777 | }, { 778 | name: "Hey There Delilah", 779 | artist: "Plain White T's", 780 | year: 2007, 781 | month: 7, 782 | day: 28, 783 | weeksAtNumberOne: 2, 784 | duration: "3:52" 785 | }, { 786 | name: "Beautiful Girls", 787 | artist: "Sean Kingston", 788 | year: 2007, 789 | month: 8, 790 | day: 11, 791 | weeksAtNumberOne: 4, 792 | duration: "3:43" 793 | }, { 794 | name: "Big Girls Don't Cry", 795 | artist: "Fergie", 796 | year: 2007, 797 | month: 9, 798 | day: 8, 799 | weeksAtNumberOne: 1, 800 | duration: "4:28" 801 | }, { 802 | name: "Crank That (Soulja Boy)", 803 | artist: "Soulja Boy Tell 'Em", 804 | year: 2007, 805 | month: 9, 806 | day: 15, 807 | weeksAtNumberOne: 7, 808 | duration: "3:42" 809 | }, { 810 | name: "Stronger", 811 | artist: "Kanye West", 812 | year: 2007, 813 | month: 9, 814 | day: 29, 815 | weeksAtNumberOne: 1, 816 | duration: "4:04" 817 | }, { 818 | name: "Kiss Kiss", 819 | artist: "Chris Brown featuring T-Pain", 820 | year: 2007, 821 | month: 11, 822 | day: 10, 823 | weeksAtNumberOne: 3, 824 | duration: "4:10" 825 | }, { 826 | name: "No One", 827 | artist: "Alicia Keys", 828 | year: 2007, 829 | month: 12, 830 | day: 1, 831 | weeksAtNumberOne: 5, 832 | duration: "4:10" 833 | }, { 834 | name: "Low", 835 | artist: "Flo Rida featuring T-Pain", 836 | year: 2008, 837 | month: 1, 838 | day: 5, 839 | weeksAtNumberOne: 10, 840 | duration: "3:50" 841 | }, { 842 | name: "Love in This Club", 843 | artist: "Usher featuring Young Jeezy", 844 | year: 2008, 845 | month: 3, 846 | day: 15, 847 | weeksAtNumberOne: 3, 848 | duration: "4:19" 849 | }, { 850 | name: "Bleeding Love", 851 | artist: "Leona Lewis", 852 | year: 2008, 853 | month: 4, 854 | day: 5, 855 | weeksAtNumberOne: 4, 856 | duration: "4:22" 857 | }, { 858 | name: "Touch My Body", 859 | artist: "Mariah Carey", 860 | year: 2008, 861 | month: 4, 862 | day: 12, 863 | weeksAtNumberOne: 2, 864 | duration: "3:24" 865 | }, { 866 | name: "Lollipop", 867 | artist: "Lil Wayne featuring Static Major", 868 | year: 2008, 869 | month: 5, 870 | day: 3, 871 | weeksAtNumberOne: 5, 872 | duration: "4:07" 873 | }, { 874 | name: "Take a Bow", 875 | artist: "Rihanna", 876 | year: 2008, 877 | month: 5, 878 | day: 24, 879 | weeksAtNumberOne: 1, 880 | duration: "3:48" 881 | }, { 882 | name: "Viva la Vida", 883 | artist: "Coldplay", 884 | year: 2008, 885 | month: 6, 886 | day: 28, 887 | weeksAtNumberOne: 1, 888 | duration: "3:45" 889 | }, { 890 | name: "I Kissed a Girl", 891 | artist: "Katy Perry", 892 | year: 2008, 893 | month: 7, 894 | day: 5, 895 | weeksAtNumberOne: 7, 896 | duration: "3:00" 897 | }, { 898 | name: "Disturbia", 899 | artist: "Rihanna", 900 | year: 2008, 901 | month: 8, 902 | day: 23, 903 | weeksAtNumberOne: 2, 904 | duration: "3:59" 905 | }, { 906 | name: "Whatever You Like", 907 | artist: "T.I.", 908 | year: 2008, 909 | month: 9, 910 | day: 6, 911 | weeksAtNumberOne: 7, 912 | duration: "3:40" 913 | }, { 914 | name: "So What", 915 | artist: "Pink", 916 | year: 2008, 917 | month: 9, 918 | day: 27, 919 | weeksAtNumberOne: 1, 920 | duration: "3:35" 921 | }, { 922 | name: "Live Your Life", 923 | artist: "T.I. featuring Rihanna", 924 | year: 2008, 925 | month: 10, 926 | day: 18, 927 | weeksAtNumberOne: 6, 928 | duration: "4:01" 929 | }, { 930 | name: "Womanizer", 931 | artist: "Britney Spears", 932 | year: 2008, 933 | month: 10, 934 | day: 25, 935 | weeksAtNumberOne: 1, 936 | duration: "3:44" 937 | }, { 938 | name: "Single Ladies (Put a Ring on It)", 939 | artist: "Beyonce", 940 | year: 2008, 941 | month: 12, 942 | day: 13, 943 | weeksAtNumberOne: 4, 944 | duration: "3:13" 945 | }, { 946 | name: "Just Dance", 947 | artist: "Lady Gaga featuring Colby O'Donis", 948 | year: 2009, 949 | month: 1, 950 | day: 17, 951 | weeksAtNumberOne: 3, 952 | duration: "4:01" 953 | }, { 954 | name: "My Life Would Suck Without You", 955 | artist: "Kelly Clarkson", 956 | year: 2009, 957 | month: 2, 958 | day: 7, 959 | weeksAtNumberOne: 2, 960 | duration: "3:31" 961 | }, { 962 | name: "Crack a Bottle", 963 | artist: "Eminem, Dr. Dre, and 50 Cent", 964 | year: 2009, 965 | month: 2, 966 | day: 21, 967 | weeksAtNumberOne: 1, 968 | duration: "4:57" 969 | }, { 970 | name: "Right Round", 971 | artist: "Flo Rida", 972 | year: 2009, 973 | month: 2, 974 | day: 28, 975 | weeksAtNumberOne: 6, 976 | duration: "3:27" 977 | }, { 978 | name: "Poker Face", 979 | artist: "Lady Gaga", 980 | year: 2009, 981 | month: 4, 982 | day: 11, 983 | weeksAtNumberOne: 1, 984 | duration: "3:58" 985 | }, { 986 | name: "Boom Boom Pow", 987 | artist: "The Black Eyed Peas", 988 | year: 2009, 989 | month: 4, 990 | day: 18, 991 | weeksAtNumberOne: 12, 992 | duration: "3:38" 993 | }, { 994 | name: "I Gotta Feeling", 995 | artist: "The Black Eyed Peas", 996 | year: 2009, 997 | month: 7, 998 | day: 11, 999 | weeksAtNumberOne: 14, 1000 | duration: "4:05" 1001 | }, { 1002 | name: "Down", 1003 | artist: "Jay Sean featuring Lil Wayne", 1004 | year: 2009, 1005 | month: 10, 1006 | day: 17, 1007 | weeksAtNumberOne: 2, 1008 | duration: "3:32" 1009 | }, { 1010 | name: "3", 1011 | artist: "Britney Spears", 1012 | year: 2009, 1013 | month: 10, 1014 | day: 24, 1015 | weeksAtNumberOne: 1, 1016 | duration: "3:33" 1017 | }, { 1018 | name: "Fireflies", 1019 | artist: "Owl City", 1020 | year: 2009, 1021 | month: 11, 1022 | day: 7, 1023 | weeksAtNumberOne: 2, 1024 | duration: "3:48" 1025 | }, { 1026 | name: "Whatcha Say", 1027 | artist: "Jason Derulo", 1028 | year: 2009, 1029 | month: 11, 1030 | day: 14, 1031 | weeksAtNumberOne: 1, 1032 | duration: "3:46" 1033 | }, { 1034 | name: "Empire State of Mind", 1035 | artist: "Jay-Z and Alicia Keys", 1036 | year: 2009, 1037 | month: 11, 1038 | day: 28, 1039 | weeksAtNumberOne: 5, 1040 | duration: "4:36" 1041 | }, { 1042 | name: "Tik Tok", 1043 | artist: "Kesha", 1044 | year: 2010, 1045 | month: 1, 1046 | day: 2, 1047 | weeksAtNumberOne: 9, 1048 | duration: "3:21" 1049 | }, { 1050 | name: "Imma Be", 1051 | artist: "The Black Eyed Peas", 1052 | year: 2010, 1053 | month: 3, 1054 | day: 6, 1055 | weeksAtNumberOne: 2, 1056 | duration: "3:53" 1057 | }, { 1058 | name: "Break Your Heart", 1059 | artist: "Taio Cruz featuring Ludacris", 1060 | year: 2010, 1061 | month: 3, 1062 | day: 20, 1063 | weeksAtNumberOne: 1, 1064 | duration: "3:23" 1065 | }, { 1066 | name: "Rude Boy", 1067 | artist: "Rihanna", 1068 | year: 2010, 1069 | month: 3, 1070 | day: 27, 1071 | weeksAtNumberOne: 5, 1072 | duration: "3:43" 1073 | }, { 1074 | name: "Nothin' on You", 1075 | artist: "B.o.B. featuring Bruno Mars", 1076 | year: 2010, 1077 | month: 5, 1078 | day: 1, 1079 | weeksAtNumberOne: 2, 1080 | duration: "4:29" 1081 | }, { 1082 | name: "OMG", 1083 | artist: "Usher featuring will.i.am", 1084 | year: 2010, 1085 | month: 5, 1086 | day: 15, 1087 | weeksAtNumberOne: 4, 1088 | duration: "4:28" 1089 | }, { 1090 | name: "Not Afraid", 1091 | artist: "Eminem", 1092 | year: 2010, 1093 | month: 5, 1094 | day: 22, 1095 | weeksAtNumberOne: 1, 1096 | duration: "4:10" 1097 | }, { 1098 | name: "California Gurls", 1099 | artist: "Katy Perry", 1100 | year: 2010, 1101 | month: 6, 1102 | day: 19, 1103 | weeksAtNumberOne: 6, 1104 | duration: "3:56" 1105 | }, { 1106 | name: "Love the Way You Lie", 1107 | artist: "Eminem featuring Rihanna", 1108 | year: 2010, 1109 | month: 7, 1110 | day: 31, 1111 | weeksAtNumberOne: 7, 1112 | duration: "4:23" 1113 | }, { 1114 | name: "Teenage Dream", 1115 | artist: "Katy Perry", 1116 | year: 2010, 1117 | month: 9, 1118 | day: 18, 1119 | weeksAtNumberOne: 2, 1120 | duration: "3:47" 1121 | }, { 1122 | name: "Just the Way You Are", 1123 | artist: "Bruno Mars", 1124 | year: 2010, 1125 | month: 10, 1126 | day: 2, 1127 | weeksAtNumberOne: 4, 1128 | duration: "3:41" 1129 | }, { 1130 | name: "Like a G6", 1131 | artist: "Far East Movement featuring The Cataracs and Dev", 1132 | year: 2010, 1133 | month: 10, 1134 | day: 30, 1135 | weeksAtNumberOne: 3, 1136 | duration: "3:38" 1137 | }, { 1138 | name: "We R Who We R", 1139 | artist: "Kesha", 1140 | year: 2010, 1141 | month: 11, 1142 | day: 13, 1143 | weeksAtNumberOne: 1, 1144 | duration: "3:24" 1145 | }, { 1146 | name: "What's My Name?", 1147 | artist: "Rihanna featuring Drake", 1148 | year: 2010, 1149 | month: 11, 1150 | day: 20, 1151 | weeksAtNumberOne: 1, 1152 | duration: "4:23" 1153 | }, { 1154 | name: "Only Girl (In the World)", 1155 | artist: "Rihanna", 1156 | year: 2010, 1157 | month: 12, 1158 | day: 4, 1159 | weeksAtNumberOne: 1, 1160 | duration: "3:55" 1161 | }, { 1162 | name: "Raise Your Glass", 1163 | artist: "Pink", 1164 | year: 2010, 1165 | month: 12, 1166 | day: 11, 1167 | weeksAtNumberOne: 1, 1168 | duration: "3:23" 1169 | }, { 1170 | name: "Firework", 1171 | artist: "Katy Perry", 1172 | year: 2010, 1173 | month: 12, 1174 | day: 18, 1175 | weeksAtNumberOne: 4, 1176 | duration: "3:46" 1177 | }, { 1178 | name: "Grenade", 1179 | artist: "Bruno Mars", 1180 | year: 2011, 1181 | month: 1, 1182 | day: 8, 1183 | weeksAtNumberOne: 4, 1184 | duration: "3:42" 1185 | }, { 1186 | name: "Hold It Against Me", 1187 | artist: "Britney Spears", 1188 | year: 2011, 1189 | month: 1, 1190 | day: 29, 1191 | weeksAtNumberOne: 1, 1192 | duration: "3:49" 1193 | }, { 1194 | name: "Black and Yellow", 1195 | artist: "Wiz Khalifa", 1196 | year: 2011, 1197 | month: 2, 1198 | day: 19, 1199 | weeksAtNumberOne: 1, 1200 | duration: "3:37" 1201 | }, { 1202 | name: "Born This Way", 1203 | artist: "Lady Gaga", 1204 | year: 2011, 1205 | month: 2, 1206 | day: 26, 1207 | weeksAtNumberOne: 6, 1208 | duration: "4:20" 1209 | }, { 1210 | name: "E.T.", 1211 | artist: "Katy Perry featuring Kanye West", 1212 | year: 2011, 1213 | month: 4, 1214 | day: 9, 1215 | weeksAtNumberOne: 5, 1216 | duration: "3:51" 1217 | }, { 1218 | name: "S&M", 1219 | artist: "Rihanna", 1220 | year: 2011, 1221 | month: 4, 1222 | day: 30, 1223 | weeksAtNumberOne: 1, 1224 | duration: "4:03" 1225 | }, { 1226 | name: "Rolling in the Deep", 1227 | artist: "Adele", 1228 | year: 2011, 1229 | month: 5, 1230 | day: 21, 1231 | weeksAtNumberOne: 7, 1232 | duration: "3:48" 1233 | }, { 1234 | name: "Give Me Everything", 1235 | artist: "Pitbull featuring Ne-Yo, Afrojack, and Nayer", 1236 | year: 2011, 1237 | month: 7, 1238 | day: 9, 1239 | weeksAtNumberOne: 1, 1240 | duration: "4:12" 1241 | }, { 1242 | name: "Party Rock Anthem", 1243 | artist: "LMFAO featuring Lauren Bennett and GoonRock", 1244 | year: 2011, 1245 | month: 7, 1246 | day: 16, 1247 | weeksAtNumberOne: 6, 1248 | duration: "3:52" 1249 | }, { 1250 | name: "Last Friday Night (T.G.I.F.)", 1251 | artist: "Katy Perry", 1252 | year: 2011, 1253 | month: 8, 1254 | day: 27, 1255 | weeksAtNumberOne: 2, 1256 | duration: "3:50" 1257 | }, { 1258 | name: "Moves Like Jagger", 1259 | artist: "Maroon 5 featuring Christina Aguilera", 1260 | year: 2011, 1261 | month: 9, 1262 | day: 10, 1263 | weeksAtNumberOne: 4, 1264 | duration: "3:21" 1265 | }, { 1266 | name: "Someone Like You", 1267 | artist: "Adele", 1268 | year: 2011, 1269 | month: 9, 1270 | day: 17, 1271 | weeksAtNumberOne: 5, 1272 | duration: "4:45" 1273 | }, { 1274 | name: "We Found Love", 1275 | artist: "Rihanna featuring Calvin Harris", 1276 | year: 2011, 1277 | month: 11, 1278 | day: 12, 1279 | weeksAtNumberOne: 10, 1280 | duration: "3:35" 1281 | }, { 1282 | name: "Sexy and I Know It", 1283 | artist: "LMFAO", 1284 | year: 2012, 1285 | month: 1, 1286 | day: 7, 1287 | weeksAtNumberOne: 2, 1288 | duration: "3:19" 1289 | }, { 1290 | name: "Set Fire to the Rain", 1291 | artist: "Adele", 1292 | year: 2012, 1293 | month: 2, 1294 | day: 4, 1295 | weeksAtNumberOne: 2, 1296 | duration: "4:02" 1297 | }, { 1298 | name: "Stronger (What Doesn't Kill You)", 1299 | artist: "Kelly Clarkson", 1300 | year: 2012, 1301 | month: 2, 1302 | day: 18, 1303 | weeksAtNumberOne: 3, 1304 | duration: "3:42" 1305 | }, { 1306 | name: "Part of Me", 1307 | artist: "Katy Perry", 1308 | year: 2012, 1309 | month: 3, 1310 | day: 3, 1311 | weeksAtNumberOne: 1, 1312 | duration: "3:35" 1313 | }, { 1314 | name: "We Are Young", 1315 | artist: "Fun featuring Janelle Monae", 1316 | year: 2012, 1317 | month: 3, 1318 | day: 17, 1319 | weeksAtNumberOne: 6, 1320 | duration: "4:10" 1321 | }, { 1322 | name: "Somebody That I Used to Know", 1323 | artist: "Gotye featuring Kimbra", 1324 | year: 2012, 1325 | month: 4, 1326 | day: 28, 1327 | weeksAtNumberOne: 8, 1328 | duration: "3:33" 1329 | }, { 1330 | name: "Call Me Maybe", 1331 | artist: "Carly Rae Jepsen", 1332 | year: 2012, 1333 | month: 6, 1334 | day: 23, 1335 | weeksAtNumberOne: 9, 1336 | duration: "3:13" 1337 | }, { 1338 | name: "Whistle", 1339 | artist: "Flo Rida", 1340 | year: 2012, 1341 | month: 8, 1342 | day: 25, 1343 | weeksAtNumberOne: 2, 1344 | duration: "3:45" 1345 | }, { 1346 | name: "We Are Never Ever Getting Back Together", 1347 | artist: "Taylor Swift", 1348 | year: 2012, 1349 | month: 9, 1350 | day: 1, 1351 | weeksAtNumberOne: 3, 1352 | duration: "3:12" 1353 | }, { 1354 | name: "One More Night", 1355 | artist: "Maroon 5", 1356 | year: 2012, 1357 | month: 9, 1358 | day: 29, 1359 | weeksAtNumberOne: 9, 1360 | duration: "3:39" 1361 | }, { 1362 | name: "Diamonds", 1363 | artist: "Rihanna", 1364 | year: 2012, 1365 | month: 12, 1366 | day: 1, 1367 | weeksAtNumberOne: 3, 1368 | duration: "3:45" 1369 | }, { 1370 | name: "Locked Out of Heaven", 1371 | artist: "Bruno Mars", 1372 | year: 2012, 1373 | month: 12, 1374 | day: 22, 1375 | weeksAtNumberOne: 6, 1376 | duration: "3:53" 1377 | }, { 1378 | name: "Thrift Shop", 1379 | artist: "Macklemore & Ryan Lewis featuring Wanz", 1380 | year: 2013, 1381 | month: 2, 1382 | day: 2, 1383 | weeksAtNumberOne: 6, 1384 | duration: "3:55" 1385 | }, { 1386 | name: "Harlem Shake", 1387 | artist: "Baauer", 1388 | year: 2013, 1389 | month: 3, 1390 | day: 2, 1391 | weeksAtNumberOne: 5, 1392 | duration: "3:16" 1393 | }, { 1394 | name: "When I Was Your Man", 1395 | artist: "Bruno Mars", 1396 | year: 2013, 1397 | month: 4, 1398 | day: 20, 1399 | weeksAtNumberOne: 1, 1400 | duration: "3:34" 1401 | }, { 1402 | name: "Just Give Me a Reason", 1403 | artist: "Pink featuring Nate Ruess", 1404 | year: 2013, 1405 | month: 4, 1406 | day: 27, 1407 | weeksAtNumberOne: 3, 1408 | duration: "4:02" 1409 | }, { 1410 | name: "Can't Hold Us", 1411 | artist: "Macklemore & Ryan Lewis featuring Ray Dalton", 1412 | year: 2013, 1413 | month: 5, 1414 | day: 18, 1415 | weeksAtNumberOne: 5, 1416 | duration: "3:48" 1417 | }, { 1418 | name: "Blurred Lines", 1419 | artist: "Robin Thicke featuring T.I. and Pharrell", 1420 | year: 2013, 1421 | month: 6, 1422 | day: 22, 1423 | weeksAtNumberOne: 12, 1424 | duration: "4:25" 1425 | }, { 1426 | name: "Roar", 1427 | artist: "Katy Perry", 1428 | year: 2013, 1429 | month: 9, 1430 | day: 14, 1431 | weeksAtNumberOne: 2, 1432 | duration: "3:42" 1433 | }, { 1434 | name: "Wrecking Ball", 1435 | artist: "Miley Cyrus", 1436 | year: 2013, 1437 | month: 9, 1438 | day: 28, 1439 | weeksAtNumberOne: 3, 1440 | duration: "3:41" 1441 | }, { 1442 | name: "Royals", 1443 | artist: "Lorde", 1444 | year: 2013, 1445 | month: 10, 1446 | day: 12, 1447 | weeksAtNumberOne: 9, 1448 | duration: "3:10" 1449 | }, { 1450 | name: "The Monster", 1451 | artist: "Eminem featuring Rihanna", 1452 | year: 2013, 1453 | month: 12, 1454 | day: 21, 1455 | weeksAtNumberOne: 4, 1456 | duration: "4:10" 1457 | }, { 1458 | name: "Timber", 1459 | artist: "Pitbull featuring Kesha", 1460 | year: 2014, 1461 | month: 1, 1462 | day: 18, 1463 | weeksAtNumberOne: 3, 1464 | duration: "3:24" 1465 | }, { 1466 | name: "Dark Horse", 1467 | artist: "Katy Perry featuring Juicy J", 1468 | year: 2014, 1469 | month: 2, 1470 | day: 8, 1471 | weeksAtNumberOne: 4, 1472 | duration: "3:35" 1473 | }, { 1474 | name: "Happy", 1475 | artist: "Pharrell Williams", 1476 | year: 2014, 1477 | month: 3, 1478 | day: 8, 1479 | weeksAtNumberOne: 10, 1480 | duration: "3:53" 1481 | }, { 1482 | name: "All of Me", 1483 | artist: "John Legend", 1484 | year: 2014, 1485 | month: 5, 1486 | day: 17, 1487 | weeksAtNumberOne: 3, 1488 | duration: "4:29" 1489 | }, { 1490 | name: "Fancy", 1491 | artist: "Iggy Izalea featuring Charli XCX", 1492 | year: 2014, 1493 | month: 6, 1494 | day: 7, 1495 | weeksAtNumberOne: 7, 1496 | duration: "3:19" 1497 | }, { 1498 | name: "Rude", 1499 | artist: "Magic!", 1500 | year: 2014, 1501 | month: 7, 1502 | day: 26, 1503 | weeksAtNumberOne: 6, 1504 | duration: "3:44" 1505 | }, { 1506 | name: "Shake It Off", 1507 | artist: "Taylor Swift", 1508 | year: 2014, 1509 | month: 9, 1510 | day: 6, 1511 | weeksAtNumberOne: 4, 1512 | duration: "3:39" 1513 | }, { 1514 | name: "All About That Bass", 1515 | artist: "Meghan Trainor", 1516 | year: 2014, 1517 | month: 9, 1518 | day: 20, 1519 | weeksAtNumberOne: 8, 1520 | duration: "3:11" 1521 | }, { 1522 | name: "Blank Space", 1523 | artist: "Taylor Swift", 1524 | year: 2014, 1525 | month: 11, 1526 | day: 29, 1527 | weeksAtNumberOne: 7, 1528 | duration: "3:51" 1529 | }, { 1530 | name: "Uptown Funk", 1531 | artist: "Mark Ronson featuring Bruno Mars", 1532 | year: 2015, 1533 | month: 1, 1534 | day: 17, 1535 | weeksAtNumberOne: 14, 1536 | duration: "3:58" 1537 | }, { 1538 | name: "See You Again", 1539 | artist: "Wiz Khalifa featuring Charlie Puth", 1540 | year: 2015, 1541 | month: 4, 1542 | day: 25, 1543 | weeksAtNumberOne: 12, 1544 | duration: "3:57" 1545 | }, { 1546 | name: "Bad Blood", 1547 | artist: "Taylor Swift featuring Kendrick Lamar", 1548 | year: 2015, 1549 | month: 6, 1550 | day: 6, 1551 | weeksAtNumberOne: 1, 1552 | duration: "3:19" 1553 | }, { 1554 | name: "Cheerleader", 1555 | artist: "OMI", 1556 | year: 2015, 1557 | month: 7, 1558 | day: 25, 1559 | weeksAtNumberOne: 6, 1560 | duration: "2:58" 1561 | }, { 1562 | name: "Can't Feel My Face", 1563 | artist: "The Weeknd", 1564 | year: 2015, 1565 | month: 8, 1566 | day: 22, 1567 | weeksAtNumberOne: 3, 1568 | duration: "3:35" 1569 | }, { 1570 | name: "What Do You Mean?", 1571 | artist: "Justin Bieber", 1572 | year: 2015, 1573 | month: 9, 1574 | day: 19, 1575 | weeksAtNumberOne: 1, 1576 | duration: "3:26" 1577 | }, { 1578 | name: "The Hills", 1579 | artist: "The Weeknd", 1580 | year: 2015, 1581 | month: 10, 1582 | day: 3, 1583 | weeksAtNumberOne: 6, 1584 | duration: "4:04" 1585 | }, { 1586 | name: "Hello", 1587 | artist: "Adele", 1588 | year: 2015, 1589 | month: 11, 1590 | day: 14, 1591 | weeksAtNumberOne: 10, 1592 | duration: "4:55" 1593 | }]; -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Document 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 21 | 22 | -------------------------------------------------------------------------------- /iterators.js: -------------------------------------------------------------------------------- 1 | // Write a function called listNames which takes in an array of songs and console.logs the name of each one. 2 | 3 | // Write a function called listSongDetails which takes in an array of songs and console.logs details about each one. The details should be in the following example format: "Smooth, by Santana featuring Rob Thomas (4:00)". 4 | 5 | // Write a function called summerJamCount which takes in an array of songs and returns the number of songs which hit #1 on the charts in June, July, or August. 6 | 7 | // Write a function called getDurations which takes in an array of songs and returns an array of each song's duration. 8 | 9 | // Write a function called getDurationInSeconds which takes in an array of songs and returns an array of each song's duration in seconds. 10 | 11 | // Write a function called getMainArtists which takes in an array of songs and returns an array of the primary artists on the recordings. If there's only one artist, that artist should be returned; if there are featured artists, they should be ignored (so only the artist to the left of "featuring" is kept.) 12 | 13 | // Write a function called getBigHits which takes an array of songs and returns an array of songs which were number one for 10 or more weeks. 14 | 15 | // Write a function called getShortSongs which takes an array of songs and returns an array of songs which shorter than 3 minutes. 16 | 17 | // Write a function called getSongsByArtist which takes in an array of artists and the name of an artist and returns an array of songs by that artist. 18 | 19 | // Refactor summerJamCount to use reduce! 20 | 21 | // Write a function called getTotalDurationInSeconds which takes in an array of songs and returns the total amount of time (in seconds) it would take to listen to all of the songs. (Hint: can you use anything you've written already to help solve this problem?) 22 | 23 | // Write a function called getSongCountByArtist which takes in an array of songs and returns an object. The keys in the object should be artist names, and the values should be the number of songs by that artist in the orignal array. 24 | 25 | // Write a function called averageWeeksAtNumberOne which takes in an array of songs and returns the average number of weeks that songs on the list were #1. 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /iteratorsSpec.js: -------------------------------------------------------------------------------- 1 | var expect = chai.expect 2 | 3 | describe("#getDurations", function(){ 4 | it("should return the same length of the original array", function(){ 5 | expect(getDurations(songs).length).to.equal(199) 6 | }); 7 | it("should return the correct format for each song", function(){ 8 | expect(getDurations(songs)[0]).to.equal("4:00") 9 | expect(getDurations(songs)[1]).to.equal("3:20") 10 | expect(getDurations(songs)[2]).to.equal("4:10") 11 | expect(getDurations(songs)[3]).to.equal("4:17") 12 | expect(getDurations(songs)[198]).to.equal("4:55") 13 | }); 14 | }); 15 | 16 | describe("#getDurationsInSeconds", function(){ 17 | it("should return the same length of the original array", function(){ 18 | expect(getDurationsInSeconds(songs).length).to.equal(199) 19 | }); 20 | it("should return the correct format for each song", function(){ 21 | expect(getDurationsInSeconds(songs)[0]).to.equal(240) 22 | expect(getDurationsInSeconds(songs)[1]).to.equal(200) 23 | expect(getDurationsInSeconds(songs)[2]).to.equal(250) 24 | expect(getDurationsInSeconds(songs)[3]).to.equal(257) 25 | expect(getDurationsInSeconds(songs)[198]).to.equal(295) 26 | }); 27 | }); 28 | 29 | describe("#getMainArtists", function(){ 30 | it("should return the same length of the original array", function(){ 31 | expect(getMainArtists(songs).length).to.equal(199) 32 | }); 33 | it("should return the correct artist for each song", function(){ 34 | expect(getMainArtists(songs)[0]).to.equal("Santana") 35 | expect(getMainArtists(songs)[1]).to.equal("Christina Aguilera") 36 | expect(getMainArtists(songs)[2]).to.equal("Savage Garden") 37 | expect(getMainArtists(songs)[3]).to.equal("Mariah Carey") 38 | expect(getMainArtists(songs)[198]).to.equal("Adele") 39 | }); 40 | }); 41 | 42 | describe("#getBigHits", function(){ 43 | it("should return all of the number one hits for more than 10 weeks", function(){ 44 | expect(getBigHits(songs).length).to.equal(19) 45 | }); 46 | it("should return the correct big hit", function(){ 47 | expect(getBigHits(songs)[0].name).to.equal("Smooth") 48 | expect(getBigHits(songs)[0].month).to.equal(10) 49 | expect(getBigHits(songs)[0].year).to.equal(1999) 50 | }); 51 | }); 52 | 53 | describe("#getShortSongs", function(){ 54 | it("should return all of the short songs", function(){ 55 | expect(getShortSongs(songs).length).to.equal(1) 56 | }); 57 | it("should return the correct short song", function(){ 58 | expect(getShortSongs(songs)[0].artist).to.equal("OMI") 59 | expect(getShortSongs(songs)[0].month).to.equal(7) 60 | expect(getShortSongs(songs)[0].year).to.equal(2015) 61 | }); 62 | }); 63 | 64 | describe("#getSongsByArtist", function(){ 65 | it("should find an artist correctly", function(){ 66 | expect(getSongsByArtist(songs,'OMI').length).to.equal(1) 67 | expect(getSongsByArtist(songs,'OMI')[0].name).to.equal('Cheerleader') 68 | }); 69 | it("should return an empty array if the artist is not found", function(){ 70 | expect(getSongsByArtist(songs,'WRONG').length).to.equal(0) 71 | }); 72 | }); 73 | 74 | // change xit to it so that your tests are no longer pending! 75 | 76 | describe("#summerJamCount", function(){ 77 | xit("needs you to write some tests!", function(){ 78 | // WRITE YOUR OWN TESTS! 79 | }); 80 | }); 81 | 82 | describe("#getTotalDurationInSeconds", function(){ 83 | xit("needs you to write some tests!", function(){ 84 | // WRITE YOUR OWN TESTS! 85 | }); 86 | }); 87 | 88 | describe("#getSongCountByArtist", function(){ 89 | xit("needs you to write some tests!", function(){ 90 | // WRITE YOUR OWN TESTS! 91 | }); 92 | }); 93 | 94 | 95 | -------------------------------------------------------------------------------- /lib/mocha.css: -------------------------------------------------------------------------------- 1 | @charset "utf-8"; 2 | 3 | body { 4 | margin:0; 5 | } 6 | 7 | #mocha { 8 | font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif; 9 | margin: 60px 50px; 10 | } 11 | 12 | #mocha ul, 13 | #mocha li { 14 | margin: 0; 15 | padding: 0; 16 | } 17 | 18 | #mocha ul { 19 | list-style: none; 20 | } 21 | 22 | #mocha h1, 23 | #mocha h2 { 24 | margin: 0; 25 | } 26 | 27 | #mocha h1 { 28 | margin-top: 15px; 29 | font-size: 1em; 30 | font-weight: 200; 31 | } 32 | 33 | #mocha h1 a { 34 | text-decoration: none; 35 | color: inherit; 36 | } 37 | 38 | #mocha h1 a:hover { 39 | text-decoration: underline; 40 | } 41 | 42 | #mocha .suite .suite h1 { 43 | margin-top: 0; 44 | font-size: .8em; 45 | } 46 | 47 | #mocha .hidden { 48 | display: none; 49 | } 50 | 51 | #mocha h2 { 52 | font-size: 12px; 53 | font-weight: normal; 54 | cursor: pointer; 55 | } 56 | 57 | #mocha .suite { 58 | margin-left: 15px; 59 | } 60 | 61 | #mocha .test { 62 | margin-left: 15px; 63 | overflow: hidden; 64 | } 65 | 66 | #mocha .test.pending:hover h2::after { 67 | content: '(pending)'; 68 | font-family: arial, sans-serif; 69 | } 70 | 71 | #mocha .test.pass.medium .duration { 72 | background: #c09853; 73 | } 74 | 75 | #mocha .test.pass.slow .duration { 76 | background: #b94a48; 77 | } 78 | 79 | #mocha .test.pass::before { 80 | content: '✓'; 81 | font-size: 12px; 82 | display: block; 83 | float: left; 84 | margin-right: 5px; 85 | color: #00d6b2; 86 | } 87 | 88 | #mocha .test.pass .duration { 89 | font-size: 9px; 90 | margin-left: 5px; 91 | padding: 2px 5px; 92 | color: #fff; 93 | -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.2); 94 | -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,.2); 95 | box-shadow: inset 0 1px 1px rgba(0,0,0,.2); 96 | -webkit-border-radius: 5px; 97 | -moz-border-radius: 5px; 98 | -ms-border-radius: 5px; 99 | -o-border-radius: 5px; 100 | border-radius: 5px; 101 | } 102 | 103 | #mocha .test.pass.fast .duration { 104 | display: none; 105 | } 106 | 107 | #mocha .test.pending { 108 | color: #0b97c4; 109 | } 110 | 111 | #mocha .test.pending::before { 112 | content: '◦'; 113 | color: #0b97c4; 114 | } 115 | 116 | #mocha .test.fail { 117 | color: #c00; 118 | } 119 | 120 | #mocha .test.fail pre { 121 | color: black; 122 | } 123 | 124 | #mocha .test.fail::before { 125 | content: '✖'; 126 | font-size: 12px; 127 | display: block; 128 | float: left; 129 | margin-right: 5px; 130 | color: #c00; 131 | } 132 | 133 | #mocha .test pre.error { 134 | color: #c00; 135 | max-height: 300px; 136 | overflow: auto; 137 | } 138 | 139 | #mocha .test .html-error { 140 | overflow: auto; 141 | color: black; 142 | line-height: 1.5; 143 | display: block; 144 | float: left; 145 | clear: left; 146 | font: 12px/1.5 monaco, monospace; 147 | margin: 5px; 148 | padding: 15px; 149 | border: 1px solid #eee; 150 | max-width: 85%; /*(1)*/ 151 | max-width: -webkit-calc(100% - 42px); 152 | max-width: -moz-calc(100% - 42px); 153 | max-width: calc(100% - 42px); /*(2)*/ 154 | max-height: 300px; 155 | word-wrap: break-word; 156 | border-bottom-color: #ddd; 157 | -webkit-box-shadow: 0 1px 3px #eee; 158 | -moz-box-shadow: 0 1px 3px #eee; 159 | box-shadow: 0 1px 3px #eee; 160 | -webkit-border-radius: 3px; 161 | -moz-border-radius: 3px; 162 | border-radius: 3px; 163 | } 164 | 165 | #mocha .test .html-error pre.error { 166 | border: none; 167 | -webkit-border-radius: 0; 168 | -moz-border-radius: 0; 169 | border-radius: 0; 170 | -webkit-box-shadow: 0; 171 | -moz-box-shadow: 0; 172 | box-shadow: 0; 173 | padding: 0; 174 | margin: 0; 175 | margin-top: 18px; 176 | max-height: none; 177 | } 178 | 179 | /** 180 | * (1): approximate for browsers not supporting calc 181 | * (2): 42 = 2*15 + 2*10 + 2*1 (padding + margin + border) 182 | * ^^ seriously 183 | */ 184 | #mocha .test pre { 185 | display: block; 186 | float: left; 187 | clear: left; 188 | font: 12px/1.5 monaco, monospace; 189 | margin: 5px; 190 | padding: 15px; 191 | border: 1px solid #eee; 192 | max-width: 85%; /*(1)*/ 193 | max-width: -webkit-calc(100% - 42px); 194 | max-width: -moz-calc(100% - 42px); 195 | max-width: calc(100% - 42px); /*(2)*/ 196 | word-wrap: break-word; 197 | border-bottom-color: #ddd; 198 | -webkit-box-shadow: 0 1px 3px #eee; 199 | -moz-box-shadow: 0 1px 3px #eee; 200 | box-shadow: 0 1px 3px #eee; 201 | -webkit-border-radius: 3px; 202 | -moz-border-radius: 3px; 203 | border-radius: 3px; 204 | } 205 | 206 | #mocha .test h2 { 207 | position: relative; 208 | } 209 | 210 | #mocha .test a.replay { 211 | position: absolute; 212 | top: 3px; 213 | right: 0; 214 | text-decoration: none; 215 | vertical-align: middle; 216 | display: block; 217 | width: 15px; 218 | height: 15px; 219 | line-height: 15px; 220 | text-align: center; 221 | background: #eee; 222 | font-size: 15px; 223 | -webkit-border-radius: 15px; 224 | -moz-border-radius: 15px; 225 | border-radius: 15px; 226 | -webkit-transition:opacity 200ms; 227 | -moz-transition:opacity 200ms; 228 | -o-transition:opacity 200ms; 229 | transition: opacity 200ms; 230 | opacity: 0.3; 231 | color: #888; 232 | } 233 | 234 | #mocha .test:hover a.replay { 235 | opacity: 1; 236 | } 237 | 238 | #mocha-report.pass .test.fail { 239 | display: none; 240 | } 241 | 242 | #mocha-report.fail .test.pass { 243 | display: none; 244 | } 245 | 246 | #mocha-report.pending .test.pass, 247 | #mocha-report.pending .test.fail { 248 | display: none; 249 | } 250 | #mocha-report.pending .test.pass.pending { 251 | display: block; 252 | } 253 | 254 | #mocha-error { 255 | color: #c00; 256 | font-size: 1.5em; 257 | font-weight: 100; 258 | letter-spacing: 1px; 259 | } 260 | 261 | #mocha-stats { 262 | position: fixed; 263 | top: 15px; 264 | right: 10px; 265 | font-size: 12px; 266 | margin: 0; 267 | color: #888; 268 | z-index: 1; 269 | } 270 | 271 | #mocha-stats .progress { 272 | float: right; 273 | padding-top: 0; 274 | 275 | /** 276 | * Set safe initial values, so mochas .progress does not inherit these 277 | * properties from Bootstrap .progress (which causes .progress height to 278 | * equal line height set in Bootstrap). 279 | */ 280 | height: auto; 281 | -webkit-box-shadow: none; 282 | -moz-box-shadow: none; 283 | box-shadow: none; 284 | background-color: initial; 285 | } 286 | 287 | #mocha-stats em { 288 | color: black; 289 | } 290 | 291 | #mocha-stats a { 292 | text-decoration: none; 293 | color: inherit; 294 | } 295 | 296 | #mocha-stats a:hover { 297 | border-bottom: 1px solid #eee; 298 | } 299 | 300 | #mocha-stats li { 301 | display: inline-block; 302 | margin: 0 5px; 303 | list-style: none; 304 | padding-top: 11px; 305 | } 306 | 307 | #mocha-stats canvas { 308 | width: 40px; 309 | height: 40px; 310 | } 311 | 312 | #mocha code .comment { color: #ddd; } 313 | #mocha code .init { color: #2f6fad; } 314 | #mocha code .string { color: #5890ad; } 315 | #mocha code .keyword { color: #8a6343; } 316 | #mocha code .number { color: #2f6fad; } 317 | 318 | @media screen and (max-device-width: 480px) { 319 | #mocha { 320 | margin: 60px 0px; 321 | } 322 | 323 | #mocha #stats { 324 | position: absolute; 325 | } 326 | } 327 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # JavaScript Iterators 2 | 3 | This repository consists of additional questions on several JavaScript iterators: `forEach`, `map`, `filter`, and `reduce`. If you need a refresher on these methods, check out our [free course materials](https://www.rithmschool.com/courses/intermediate-javascript-part-2). 4 | 5 | The problems all assume you have access to the song data in the `data.js` file. The data represents all of the songs to hit #1 on the Billboard Hot 100 from 2000 through 2015. The following data is recorded for each song: 6 | 7 | - song name, 8 | - artist name, 9 | - the year when the song _first_ hit #1 10 | - the month when the song _first_ hit #1 11 | - the date in the month when the song _first_ hit #1 12 | - how many (not necessary consecutive!) weeks the song was #1 13 | - the duration of the song, in minutes and seconds. 14 | 15 | To use the data, throw it into the Chrome console, or use a tool like [JSBin](jsbin.com) or [Repl.it](repl.it) to copy and paste the data before you start trying to solve these problems. 16 | 17 | Have fun! 18 | 19 | ### `forEach` 20 | 21 | 1. Write a function called `listNames` which takes in an array of songs and console.logs the name of each one. 22 | 2. Write a function called `listSongDetails` which takes in an array of songs and console.logs details about each one. The details should be in the following example format: "Smooth, by Santana featuring Rob Thomas (4:00)". 23 | 3. Write a function called `summerJamCount` which takes in an array of songs and returns the number of songs which hit #1 on the charts in June, July, or August. 24 | 25 | ### `map` 26 | 27 | 1. Write a function called `getDurations` which takes in an array of songs and returns an array of each song's duration. 28 | 2. Write a function called `getDurationInSeconds` which takes in an array of songs and returns an array of each song's duration in seconds. 29 | 3. Write a function called `getMainArtists` which takes in an array of songs and returns an array of the primary artists on the recordings. If there's only one artist, that artist should be returned; if there are featured artists, they should be ignored (so only the artist to the left of "featuring" is kept.) 30 | 31 | ### `filter` 32 | 33 | 1. Write a function called `getBigHits` which takes an array of songs and returns an array of song objects which were number one for 10 or more weeks. 34 | 2. Write a function called `getShortSongs` which takes an array of songs and returns an array of songs which are shorter than 3 minutes. 35 | 3. Write a function called `getSongsByArtist` which takes in an array of songs and the name of an artist and returns an array of songs by that artist. 36 | 37 | ### `reduce` 38 | 39 | 1. Refactor `summerJamCount` to use reduce! 40 | 2. Write a function called `getTotalDurationInSeconds` which takes in an array of songs and returns the total amount of time (in seconds) it would take to listen to all of the songs. (Hint: can you use anything you've written already to help solve this problem?) 41 | 3. Write a function called `getSongCountByArtist` which takes in an array of songs and returns an object. The keys in the object should be artist names, and the values should be the number of songs by that artist in the orignal array. 42 | 4. Write a function called `averageWeeksAtNumberOne` which takes in an array of songs and returns the average number of weeks that songs on the list were #1. 43 | --------------------------------------------------------------------------------