0% found this document useful (0 votes)
125 views

Javascript Exercises

The document provides 7 JavaScript exercises: 1. Declare and initialize a variable 2. Output the value of a variable set to a string 3. Output the value of a variable that is reassigned multiple times 4. Output variable values after a series of variable assignments 5. Calculate and output potential ages in a future year based on a birth year variable 6. Calculate and output the circumference and area of a circle based on a radius variable 7. Convert between Celsius and Fahrenheit temperatures stored in variables and output the results

Uploaded by

MOYIN
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views

Javascript Exercises

The document provides 7 JavaScript exercises: 1. Declare and initialize a variable 2. Output the value of a variable set to a string 3. Output the value of a variable that is reassigned multiple times 4. Output variable values after a series of variable assignments 5. Calculate and output potential ages in a future year based on a birth year variable 6. Calculate and output the circumference and area of a circle based on a radius variable 7. Convert between Celsius and Fahrenheit temperatures stored in variables and output the results

Uploaded by

MOYIN
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

JAVASCRIPT EXERCISES

1. Declare a variable and initialize it. (Choose any variable name and keyword of your choice)
2. What will be the value of x when the code below is executed?
Let x = “hello”;

3. What will be the value of x when the code below is executed?


Let x = ‘tic’;
X = ‘tac’;
X = ‘toe’;

4. What will be the value of x when the code below is executed?


Let x =’Aaron’;
Let y = ‘zuri’;
Let z = y;
y = x;
x = z;

5. Store your birth year in a variable.

Store a future year in a variable.

Calculate your 2 possible ages for that year based on the stored values.
For example, if you were born in 1988, then in 2026 you'll be either 37 or 38, depending on
what month it is in 2026.

Output them to the screen like so: "I will be either NN or NN in YYYY", substituting the
values.

6. Store a radius into a variable.

Calculate the circumference based on the radius, and output "The circumference is NN".

Calculate the area based on the radius, and output "The area is NN".

7. Store a celsius temperature into a variable.

Convert it to fahrenheit and output "NN°C is NN°F".

Now store a fahrenheit temperature into a variable.


Convert it to celsius and output "NN°F is NN°C."

You might also like