Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /nfs/c03/h06/mnt/47997/domains/jeffschram.com/html/wp-content/plugins/types/embedded/includes/wpml.php on line 624

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /nfs/c03/h06/mnt/47997/domains/jeffschram.com/html/wp-content/plugins/types/embedded/includes/wpml.php on line 641
JeffLearnsReact – Flow | Jeff Schram

JeffLearnsReact – Flow


Warning: count(): Parameter must be an array or an object that implements Countable in /nfs/c03/h06/mnt/47997/domains/jeffschram.com/html/wp-content/plugins/workbox-video-from-vimeo-youtube-plugin/workbox_video.php on line 192

FLOW Controlling the flow of the execution with if, else if, else, and switch. NOTE: Lines of code between curly braces are called blocks. IF ELSE ELSE IF if/else statements are how programs can process yes/no questions programmatically. SWITCH let groceryItem = ‘papaya’; switch (groceryItem) { case ‘tomato’: console.log(‘Tomatoes are $0.49’); break; case ‘lime’: console.log(‘Limes […]


Warning: count(): Parameter must be an array or an object that implements Countable in /nfs/c03/h06/mnt/47997/domains/jeffschram.com/html/wp-content/plugins/workbox-video-from-vimeo-youtube-plugin/workbox_video.php on line 192

FLOW

Controlling the flow of the execution with if, else if, else, and switch.

NOTE: Lines of code between curly braces are called blocks.

IF ELSE ELSE IF
if/else statements are how programs can process yes/no questions programmatically.

SWITCH
let groceryItem = ‘papaya’;

switch (groceryItem) {
case ‘tomato’:
console.log(‘Tomatoes are $0.49’);
break;
case ‘lime’:
console.log(‘Limes are $1.49’);
break;
case ‘papaya’:
console.log(‘Papayas are $1.29’);
break;
default:
console.log(‘Invalid item’);
break;
}

Ternary Operator

let isNightTime = true;

if (isNightTime) {
console.log(‘Turn on the lights!’);
} else {
console.log(‘Turn off the lights!’);
}

can also be

isNightTime ? console.log(‘Turn on the lights!’) : console.log(‘Turn off the lights!’);

conditionIsMet ? do-if-true : do-if-false;

Powered by WPeMatico