Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js return

//The return statement ends function execution,
//and specifies a value to be returned to the function caller.
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
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #js #return
ADD COMMENT
Topic
Name
2+4 =