Decision Control Statements in JavaScript
Conversion function
// conversion
let a = '12.54'
let b = 13x = Number(a)
console.log(x, typeof x )
console.log(parseFloat(a) )
x = String(b)
// Control Instructions
1. Decision Control - if, else, if else if, conditional operator - Same as C
2. Iterative Control - while loop, do while loop, for loop, for in loop, for of loop
3. Switch Case Control
// Conditional operator
let x = 8
console.log( x > 10? "Greater than 10": "less than 10")
//switch
let y = 5
switch (y) {
case 1:
console.log('Monday');
break;
case 2:
console.log('Tuesday');
break;
case 3:
console.log('Wednesday');
break;
case 4:
console.log('Thursday');
break;
case 5:
console.log('Friday');
break;
case 6:
console.log('Saturday');
break;
case 7:
console.log('Sunday');
break;
default:
break;
}
Comments
Post a Comment