When you write code, you'll want to create shortcuts to data values so you can don't have to write out the same value every time.
We can use variable to create a reference to a value.
var greeting = "Hello world";
console.log(greeting);The program above will print "Hello world" to the console. Notice how it uses the value assigned to the variable greeting.
- Add a variable
greetingto exercise.js (make sure it comes before the console.log) - Print your
greetingto the console 3 times
Remember: to run this exercise you must change directory to the
C-variables. If you already have a terminal window open for the previous exercise you can do this by running the commandcd ../C-variables.
Hello world
Hello world
Hello world