Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

License

NotificationsYou must be signed in to change notification settings

learn-co-students/js-beatles-loops-lab-js-apply-000

Repository files navigation

Objectives

  • Build a for loop
  • Build a while loop
  • Build a do-while loop

Instructions

Make sure you run the tests withlearn.

  1. Create a functiontheBeatlesPlay, which accepts two parameters--an array ofmusicians and an array of instruments.

    • Create a variable with an empty array.
    • Use afor loop, which iterates over the array of musicians. Be carefulabout what value you set yourcounter variable to store. (Hint: Thinkabout what the first index of an array is).
    • The first time through the loop, it should create a string using thefirstindex of the musicians arrayand the first index of the instrumentsarray:"John Lennon plays guitar".
    • Add this string to the empty array you created. The loop should make thesame sentence for every member of the musicians array.
    • The function should return the array of new strings containing whatinstruments each musician plays.
  2. Create a functionjohnLennonFacts.

    • This function will accept one argument, an array of facts about JohnLennon (note that it might not be exactly the following facts):
    constfacts=["He was the last Beatle to learn to drive","He was never a vegetarian","He was a choir boy and boy scout","He hated the sound of his own voice"];
    • Use a while loop to loop over the facts array and add"!!!" to the end ofevery fact.

    • Return an array of strings with exclamation points.

  3. Create a functioniLoveTheBeatles which accepts a number as a parameter.

    • The function should create a variable that stores an empty array.
    • Implement a do-while loop inside the function that adds"I love the Beatles!" to the empty array.
    • The loop should then increment the number passed in as a parameter. Thecondition of the loop should check to see that the parameter number isless than15. It should contain a number of strings that represents thedifference between the input number and15.
    • Return the array with the strings"I love the Beatles!".

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors11


[8]ページ先頭

©2009-2025 Movatter.jp