Coder Social home page Coder Social logo

js-beatles-loops-lab-js-apply-000's Introduction

Beatles Loops

Objectives

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

Instructions

Make sure you run the tests with learn.

  1. Create a function theBeatlesPlay, which accepts two parameters--an array of musicians and an array of instruments.

    • Create a variable with an empty array.
    • Use a for loop, which iterates over the array of musicians. Be careful about what value you set your counter variable to store. (Hint: Think about what the first index of an array is).
    • The first time through the loop, it should create a string using the first index of the musicians array and the first index of the instruments array: "John Lennon plays guitar".
    • Add this string to the empty array you created. The loop should make the same sentence for every member of the musicians array.
    • The function should return the array of new strings containing what instruments each musician plays.
  2. Create a function johnLennonFacts.

    • This function will accept one argument, an array of facts about John Lennon (note that it might not be exactly the following facts):
    const facts = [
      "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 of every fact.

    • Return an array of strings with exclamation points.

  3. Create a function iLoveTheBeatles 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. The condition of the loop should check to see that the parameter number is less than 15. It should contain a number of strings that represents the difference between the input number and 15.
    • Return the array with the strings "I love the Beatles!".

View Beatles Loops on Learn.co and start learning to code for free.

js-beatles-loops-lab-js-apply-000's People

Contributors

pletcher avatar maxwellbenton avatar victhevenot avatar drakeltheryuujin avatar ipc103 avatar ivalentine avatar jessrudder avatar alpha-convert avatar techtwin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.