Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

if and else shorthand

//Long version  
let points = 70;   
let result;   
if(marks >= 50){  
    result = 'Pass';   
}else{  
    result = 'Fail';   
}

//Shorthand  
let points = 70;   
let result = marks >= 50 ? 'Pass' : 'Fail';   
Source by devdojo.com #
 
PREVIOUS NEXT
Tagged: #shorthand
ADD COMMENT
Topic
Name
2+2 =