0
0
Javascriptprogramming~10 mins

Arithmetic operators in Javascript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add two numbers and store the result in sum.

Javascript
let a = 5;
let b = 3;
let sum = a [1] b;
Drag options to blanks, or click blank then click option'
A+
B-
C*
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using - instead of + will subtract instead of add.
2fill in blank
medium

Complete the code to multiply two numbers and store the result in product.

Javascript
let x = 4;
let y = 7;
let product = x [1] y;
Drag options to blanks, or click blank then click option'
A+
B-
C*
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using + will add instead of multiply.
3fill in blank
hard

Fix the error in the code to correctly divide num1 by num2.

Javascript
let num1 = 20;
let num2 = 4;
let result = num1 [1] num2;
Drag options to blanks, or click blank then click option'
A+
B/
C-
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using * multiplies instead of divides.
4fill in blank
hard

Fill both blanks to create an object that maps numbers to their squares only if the number is even.

Javascript
const squares = {n[1]2 for n in [1, 2, 3, 4, 5, 6] if n [2] 2 === 0};
Drag options to blanks, or click blank then click option'
A**
B%
C===
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using + instead of ** will add instead of square.
5fill in blank
hard

Fill all three blanks to create an object mapping uppercase letters to their ASCII codes only if the code is greater than 65.

Javascript
const codes = {[[1]]: [2] for [3] of ['A', 'B', 'C', 'D'] if [2] > 65};
Drag options to blanks, or click blank then click option'
Aletter
Bletter.charCodeAt(0)
Dcode
Attempts:
3 left
💡 Hint
Common Mistakes
Using for ... in instead of for ... of will iterate keys, not values.