Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Return with an "IF" Statement

function getRectArea(width, height) {
  if (width > 0 && height > 0) {
    return width * height;
  }
  return 0;
}

console.log(getRectArea(3, 4));
// expected output: 12

console.log(getRectArea(-3, 4));
// expected output: 0
Comment

if and else in return

def label(number: float)-> str:
    return "Win" if number > 0 else "Lose"

print(label(0.1))

#output
#"Win"
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to add multiple objects into array in javascript 
Javascript :: express rate limit 
Javascript :: javaScript throw statement 
Javascript :: disadvantages of array 
Javascript :: angularjs popup 
Javascript :: jquery plugins 
Javascript :: javascript sleep 1 sec 
Javascript :: how to use switch case in javascript 
Javascript :: mongoose query object 
Javascript :: how to sort string alphabetically in javascript 
Javascript :: javascript call 
Javascript :: use next() in node js 
Javascript :: how reducer works in redux 
Javascript :: object model javascript 
Javascript :: return data with ajax 
Javascript :: fs.readfilesync withFileTypes true 
Javascript :: download in react 
Javascript :: typedjs 
Javascript :: parse tree for expression 
Javascript :: react tutorial 
Javascript :: Texto unitário no node js 
Javascript :: react and node js sample project github 
Javascript :: convert binary to string javascript 
Javascript :: ngfor with different id 
Javascript :: find smallest interval in array javascript 
Javascript :: dynamic thumbnail on hover in javascript 
Javascript :: liste des mois javascript 
Javascript :: onclick confirm jquery anchor tag 
Javascript :: javascript factorial with closure 
Javascript :: nodejs postgresql scalar query 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =