-
Create a
.jsfile that printsHellowhen you run it from the command line. (Hint:nodeis the program that can run your javascript files.) -
Create a function named
colorCarthat receives a color, and prints out, "a red car" for example. (Hint: put it in your file and run it like before.) -
Create a function named
vehicleTypethat receives a color, and a code, 1 for car, 2 for motorbike. And prints "a blue motorbike" for example when called asvehicleType("blue", 2) -
Create a function called
vehicle, like before, but takes another parameter called age, so thatvehicle("blue", 1, 5)prints "a blue used car" -
Make a list of vehicles, you can add
"motorbike","caravan","bike", or more. -
How do you get the third element from that list?
-
Change the function
vehicleto use the list of question 5. So thatvehicle("green", 3, 1)prints "a green new caravan". -
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 aforloop.) -
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:
- https://www.freecodecamp.com/challenges/multiply-two-decimals-with-javascript
- https://www.freecodecamp.com/challenges/store-multiple-values-in-one-variable-using-javascript-arrays
- https://www.freecodecamp.com/challenges/build-javascript-objects
- https://www.freecodecamp.com/challenges/add-new-properties-to-a-javascript-object
- https://www.freecodecamp.com/challenges/delete-properties-from-a-javascript-object