const x = 8;
const y = 4;
const result = x + y;
console.log(result);
Output
12
const x = 8;
const y = 4;
console.log(x + y);
Output
12
const x = 8.5;
const y = 4;
const result = x + y;
console.log(result);
Output
12.5
const text1 = 'JavaScript';
const text2 = 'Programming';
console.log(text1 + text2);
Output
JavaScriptProgramming
const x = 8;
const y = 4;
const result = x - y;
console.log(result);
Output
4
const x = 8;
const y = 4;
const result = x * y;
console.log(result);
Output
32
const x = 8;
const y = 4;
const result = x / y;
console.log(result);
Output
2
const x = 8;
const y = 4;
const result = x % y;
console.log(result);
Output
0
const x = 11;
const y = 4;
const result = x % y;
console.log(result);
Output
3
let x = 8;
console.log(++x);
Output
9
let x = 8;
console.log(x++);
Output
8
let x = 8;
console.log(x++);
console.log(x);
Output
8
9
let x = 8;
console.log(--x);
Output
7
let x = 8;
console.log(x--);
console.log(x);
Output
8
7
let x = 8;
const result = x ** 2;
console.log(result);
Output
64
const result = 4 / 2 + 3 * 5 - 1;
console.log(result);
Output
16
const initialFee = 4535;
const discountPercent = 10;
const discountAmount = discountPercent/100 * initialFee;
const totalFee = initialFee - discountAmount;
console.log(`Fee after discount: ${totalFee} dollars`);
Output
Fee after discount: 4081.5 dollars
const kmDistance = 5;
const converstionRatio = 0.621371;
const milesDistance = kmDistance * converstionRatio;
console.log('You covered ' + milesDistance + ' miles.');
Output
You covered 3.106855 miles.
Create a program that converts degree celsius to fahrenheit. The formula to convert celsius to fahrenheit is Formula: fahrenheit = celsius * 1.8 + 32. What you can do is store the value of celsius value in the celsius variable. Then use the formula fahrenheit = celsius * 1.8 + 32 to convert celsius to fahrenheit and display the result.
let celcius = 88;
let fahrenheit = celcius * 1.8 + 32;
console.log(`${celcius} celcius equals to ${fahrenheit} fahrenheit`);
Output
88 celcius equals to 190.4 fahrenheit
Q. What is the output of the following code?
console.log(5**3);
- 555
- 15
- 125
- 8
Answer: 3