Skip to content

Latest commit

 

History

History
28 lines (18 loc) · 1.27 KB

File metadata and controls

28 lines (18 loc) · 1.27 KB

More JavaScript questions!

  1. Create a function that takes 3 arguments and returns the sum of the these arguments.

  2. Create a function named colorCar that receives a color, and prints out, 'a red car' for example.

  3. Create an object and a function that takes the object as a parameter and prints out all of its properties and values.

  4. Create a function named vehicleType that receives a color, and a code, 1 for car, 2 for motorbike. And prints 'a blue motorbike' for example when called as vehicleType("blue", 2)

  5. Can you write the following without the if statement, but with just as a single line with console.log(...);?

    if (3 === 3) {
      console.log("yes");
    } else {
      console.log("no");
    }
  6. Create a function called vehicle, like before, but takes another parameter called age, so that vehicle("blue", 1, 5) prints 'a blue used car'

  7. Make a list of vehicles, you can add "motorbike", "caravan", "bike", or more.

  8. How do you get the third element from that list?

  9. Change the function vehicle to use the list of question 7. So that vehicle("green", 3, 1) prints "a green new bike".

    Hint, it should use the code to get the value from the list. So vehicle("green", 2, 1) prints "a green new caravan".