DEV Community

Abhishek Gupta for Coder Studios

Posted on

Mastering JavaScript Assignment Operators: Key Questions and Concepts

Question 1:

  • What will be the value of x after this code executes?
let x = 10;
x = 5;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 10
  • b) 5
  • c) undefined
  • d) Error

Question 2:

  • What will be the value of result after the following code?
let result = 8;
result = result + 3;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 11
  • b) 8
  • c) 5
  • d) 3

Question 3:

  • What is the value of x after this code runs?
let x = 2;
x = x * 3;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 6
  • b) 5
  • c) 3
  • d) 2

Question 4:

  • What will the value of y be after executing this code?
let y = 7;
y = y - 4;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 7
  • b) 3
  • c) 4
  • d) 10

Question 5:

  • What does the following code do?
let a = 15;
a = a / 3;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) Sets a to 45
  • b) Sets a to 5
  • c) Divides a by 3
  • d) Sets a to 18

Question 6:

  • What is the output of the following code?
let x = 4;
let y = 2;
x += y;
console.log(x);
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 4
  • b) 6
  • c) 2
  • d) 8

Question 7:

  • What will be the value of z after this code?
let z = 5;
z *= 3;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 15
  • b) 5
  • c) 10
  • d) 3

Question 8:

  • What is the value of num after this code?
let num = 20;
num /= 4;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 4
  • b) 5
  • c) 10
  • d) 2

Question 9:

  • What will be the value of score after executing the following code?
let score = 30;
score += 5;
score *= 2;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 35
  • b) 65
  • c) 70
  • d) 60

Question 10:

  • What is the result of the following code?
let x = 8;
x -= 4;
x += 3;
console.log(x);
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 7
  • b) 10
  • c) 5
  • d) 6

Question 11:

  • What will be the output of this code?
let a = 5;
let b = 10;
a += b;
b = a * 2;
console.log(a, b);
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 15,30
  • b) 10,30
  • c) 15,20
  • d) 5,20

Question 12:

  • What does this code do?
let value = 5;
value *= 4;
value /= 2;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) Sets value to 10
  • b) Sets value to 20
  • c) Doubles value
  • d) Multiplies value by 2 and then divides it by 4

Question 13:

  • What is the value of total after executing the following code?
let total = 100;
total -= 20;
total /= 2;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 40
  • b) 80
  • c) 90
  • d) 50

Question 14:

  • What will be the value of a after the following code executes?
let a = 12;
a += 4 * 2;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 24
  • b) 20
  • c) 18
  • d) 16

Question 15:

  • What is the value of count after this code?
let count = 10;
count *= 5;
count /= 10;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 50
  • b) 10
  • c) 5
  • d) 100

Question 16:

  • What will be the value of result after the following code?
let result = 15;
result += 5;
result *= 3;
result /= 2;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 30
  • b) 45
  • c) 25
  • d) 15

Question 17:

  • What does the following code do?
let num = 6;
num *= 4;
num %= 7;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) Sets num to 4
  • b) Sets num to 6
  • c) Sets num to 3
  • d) Sets num to 2

Question 18:

  • What will be the output of this code?
let x = 20;
x -= 5;
x *= 2;
x /= 5;
console.log(x);
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 10
  • b) 15
  • c) 5
  • d) 20

Question 19:

  • What is the final value of z after executing this code?
let z = 7;
z += 3;
z -= 4;
z *= 2;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 10
  • b) 12
  • c) 8
  • d) 6

Question 20:

  • What is the value of total after this code?
let total = 12;
total += 8;
total /= 4;
total *= 5;
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 25
  • b) 20
  • c) 15
  • d) 30

Question 21:

  • What will be the output of this code?
let x = 10;
x = x * 2;
x %= 3;
console.log(x);
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 2
  • b) 3
  • c) 1
  • d) 0

Question 22:

  • What is the value of x after executing the following code?
let x = 5;
x *= 4;
x += 2;
x %= 3;

Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 1
  • b) 2
  • c) 5
  • d) 4

Question 23:

  • What will be the output of this code?
let a = 20;
a /= 4;
a *= 3;
a += 5;
console.log(a);


Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 20
  • b) 25
  • c) 35
  • d) 30

Question 24:

  • What will be the value of str?
let str = "Hello";
str += " World!";
console.log(str); 


Enter fullscreen mode Exit fullscreen mode

Options:

  • a) Hello World
  • b) HelloWorls
  • c) str
  • d) Hello + World

Question 25:

  • What will be the value of arr after this code executes?
let arr = [1, 2, 3];
arr[1] = 10;

Enter fullscreen mode Exit fullscreen mode

Options:

  • a) [1, 10, 3]
  • b) [1, 2, 10]
  • c) [10, 2, 3]
  • d) [1, 2, 3]

Question 26:

  • What will be the value of x and y after this code executes?
const obj = { x: 10, y: 20 };
const { x, y } = obj; 
console.log(x, y); 
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 10 , 20
  • b) undefined , undefined
  • c) 10 , 10
  • d) 20 , 10

Question 27:

  • What will be the value of the array arr after the following code?
let arr = [1, 2, 3];
arr[1] = arr[0] + arr[2];
console.log(arr);

Enter fullscreen mode Exit fullscreen mode

Options:

  • a) [1, 3, 3]
  • b) [1, 2, 3]
  • c) [1, 4, 3]
  • d) [1, 5, 6]

Question 28:

  • What will the output of the following code be?
const obj = { a: 1, b: 2 };
obj.b = 3;
console.log(obj);
Enter fullscreen mode Exit fullscreen mode

Options:

  • a) { a: 1, b: 2 }
  • b) { a: 1, b: 3 }
  • c) { a: 3, b: 2 }
  • d) { a: 1, b: 5 }

Question 29:

  • What will the output of the following code be?
let person = { name: 'Alice', age: 30 };
person.age += 1;
console.log(person);


Enter fullscreen mode Exit fullscreen mode

Options:

  • a) { name: 'Alice', age: 31 }
  • b) { name: 'Alice', age: 30 }
  • c) { name: 'Bob', age: 31 }
  • d) { name: 'Alice', age: 32 }

Question 30:

  • What will be the output of the following code, considering hoisting?
console.log(x);  // undefined
var x = 100;

Enter fullscreen mode Exit fullscreen mode

Options:

  • a) 100
  • b) undefined
  • c) ReferenceError
  • d) null

Question 31:

  • What will be the output of the following code,
let x = "5";
let y = 5;
console.log(x == y);

Enter fullscreen mode Exit fullscreen mode

Options:

  • a) true
  • b) false
  • c) undefined
  • d) NaN

Question 32:

  • What will be the output of the following code,
let a = "5";
let b = 5;
console.log(a === b);

Enter fullscreen mode Exit fullscreen mode

Options:

  • a) true
  • b) false
  • c) undefined
  • d) NaN

Question 33:

  • What will be the output of the following code,
let x = 0;
let y = false;
console.log(x == y);


Enter fullscreen mode Exit fullscreen mode

Options:

  • a) true
  • b) false
  • c) undefined
  • d) NaN

Question 34:

  • What will be the output of the following code,
let a = 0;
let b = "";
console.log(a == b);


Enter fullscreen mode Exit fullscreen mode

Options:

  • a) true
  • b) false
  • c) undefined
  • d) NaN

Question 35:

  • What will be the output of the following code,
let a = "100";
let b = 100;
console.log(a == b);

Enter fullscreen mode Exit fullscreen mode

Options:

  • a) true
  • b) false
  • c) undefined
  • d) NaN

Question 36:

  • What will be the output of the following code,
let x = 10;
let y = "10";
console.log(x === y);

Enter fullscreen mode Exit fullscreen mode

Options:

  • a) true
  • b) false
  • c) undefined
  • d) NaN

Question 37:

  • Which of the following comparisons will return true?
let x = null;
let y = undefined;

Enter fullscreen mode Exit fullscreen mode

Options:

  • a) x == y
  • b) x === y
  • c) x != y
  • d) x === null

Question 38:

  • What will be the value of a after the following code runs?
let a = "5";
let b = 10;
a = b + a;
console.log(a);

Enter fullscreen mode Exit fullscreen mode

Options:

  • a) "510"
  • b) 15
  • c) "5"
  • d) Nan

Link

Join Discord :- https://github.com/Coder-Studies
Follow Us of Github :- https://github.com/Coder-Studies

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

πŸ‘‹ Kindness is contagious

If you found this post helpful, please leave a ❀️ or a friendly comment below!

Okay