Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Exercise 1:
- Create a variable called `name` and assign it your name as a string. Then, write a line of code to log the value of `name` to the console.
- let myName = "Rozi";
- console.log(myName);
- Exercise 2:
- Create two variables called `num1` and `num2` and assign them any numeric values of your choice. Then, calculate the sum of the two numbers and assign it to a new variable called `sum`. Finally, log the value of `sum` to the console.
- let num1 = 7;
- let num2 = 3;
- let sum = num1+num2;
- console.log(sum);
- Exercise 3:
- Create a variable called `message` and assign it an empty string. Then, concatenate the strings "Hello," and " how are you?" to the `message` variable. Log the final message to the console.
- let message = ""; // this is an empty string
- message = "Hello, " + "how are you?";
- console.log(message);
- Exercise 4:
- Create a variable called `radius` and assign it a numeric value representing the radius of a circle. Calculate the circumference of the circle (2 * π * radius) and assign it to a new variable called `circumference`. Log the value of `circumference` to the console.
- let radius = 5,55;
- let circumference = 2*3.14159265359*radius;
- console.log(circumference);
- Exercise 5:
- Create a variable called `isRaining` and assign it a boolean value of `true` or `false`, depending on the current weather condition. Use an `if` statement to check if it's raining. If it is, log "Remember to take your umbrella!" to the console. If it's not raining, log "Enjoy the sunny day!".
- let isRaining = 'true';
- if isRaining === 'true' {
- console.log(Remember to take your umbrella!");
- } else {
- console.log(Enjoy the sunny day!);
- }
Advertisement
Add Comment
Please, Sign In to add comment