[go: up one dir, main page]

0% found this document useful (0 votes)
3 views2 pages

Javascript Assignment 2

Uploaded by

Elon Musk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Javascript Assignment 2

Uploaded by

Elon Musk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

What are the final values of all variables a, b, c and d after the code below?

let a = 1, b = 1;

let c = ++a;
let d = b++;

find the final value for a, b, c ,d

What are the values of a and x after the code below?

let a = 2;

let x = 1 + (a *= 2);

What are results of these expressions?

"" + 1 + 0 = ?
"" - 1 + 0 = ?
true + false = ?
6 / "3" = ?
"2" * "3" = ?
4 + 5 + "px" = ?
"$" + 4 + 5 = ?
"4" – 2 = ?
"4px" – 2 = ?
" -9 " + 5 = ?
" -9 " – 5 = ?
null + 1 = ?
undefined + 1 = ?
" \t \n" – 2 = ?
Here’s a code that asks the user for two numbers and shows their sum.

It works incorrectly. The output in the example below is 12 (for default prompt
values).

Why? Fix it. The result should be 3.

let a = prompt("First number?", 1);


let b = prompt("Second number?", 2);

alert(a + b); // 12

PART II
Variables:
1. Create a variable with the name of our planet. How would you name such a variable?

2. Create a variable to store the name of a current visitor to a website. How would you name
that variable?

Comparison Operators:

What will be the result for these expressions?

5 > 4 = ?
"apple" > "pineapple" = ?
"2" > "12" = ?
undefined == null = ?
undefined === null = ?
null == "\n0\n" = ?
null === +"\n0\n" = ?

You might also like