This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function max(arr){ | |
var m = arr[0]; | |
for (var i = 0; i < arr.length; i++){ | |
if (arr[i] >= m){ | |
m = arr[i]; | |
} | |
} | |
return m; | |
} | |
function main(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function factorial(n) { | |
if (n < 0) | |
return -1; | |
else if (n == 0) | |
return 1; | |
else { | |
return (n * factorial(n - 1)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ispositive(x){ | |
if (x > 0){ | |
console.log('positive'); | |
} else console.log('not positive'); | |
} | |
function main(){ | |
var a = ispositive(4); | |
var b = ispositive(0); | |
var c = ispositive(6); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function iseven(x){ | |
if (x % 2 === 0){ | |
console.log(x+'is even!'); | |
} else console.log(x + 'not even'); | |
} | |
function main(){ | |
var x = iseven(4); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getarea(length,width){ | |
var a = length * width; | |
return a; | |
} | |
function getperimeter(a,b){ | |
var p = 2*(a+b); | |
return p; | |
} | |
function main(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add(a,b){ | |
var c = a+b; | |
return c; | |
} | |
function main(){ | |
var c = add(2,5); | |
console.log(c); | |
} | |
main(); |