Skip to content

Latest commit

 

History

History
27 lines (16 loc) · 1.9 KB

File metadata and controls

27 lines (16 loc) · 1.9 KB

Assignments week 1:

  1. Create a .js file that prints Hello when you run it from the command line. (Hint: node is the program that can run your javascript files.)

  2. Create a function named colorCar that receives a color, and prints out, "a red car" for example. (Hint: put it in your file and run it like before.)

  3. 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)

  4. Create a function called vehicle, like before, but takes another parameter called age, so that vehicle("blue", 1, 5) prints "a blue used car"

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

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

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

  8. Use the list of vehicles to write an advertisment. So that it prints something like: "Amazing Joe's Garage, we service cars, motorbikes, caravans and bikes.". (Hint: use a for loop.)

  9. What if you add one more vehicle to the list, can you have that added to the advertisement without changing the code for question 8?

On freecodecamp.com please try to do all Basic JavaScript exercises (there are some topics we did not cover but you can do it). Please make sure you REALLY understand the exercises below: