Created
July 7, 2018 20:14
-
-
Save shravanipl/e919ab1740a1117421612f169b2d025e to your computer and use it in GitHub Desktop.
Number
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 isDivisible(divisee, divisor) { | |
if(divisee%divisor===0){ | |
return true; | |
} | |
else | |
return false; | |
} | |
/* From here down, you are not expected to | |
understand.... for now :) | |
Nothing to see here! | |
*/ | |
// tests | |
function testIsDivisible() { | |
if (isDivisible(10, 2) && !isDivisible(11, 2)) { | |
console.log('SUCCESS: `isDivisible` is working'); | |
} else { | |
console.log('FAILURE: `isDivisible` is not working'); | |
} | |
} | |
testIsDivisible(); |
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 computeArea(width, height) { | |
let area = width*height; | |
return area; | |
} | |
/* From here down, you are not expected to | |
understand.... for now :) | |
Nothing to see here! | |
*/ | |
// tests | |
function testComputeArea() { | |
let width = 3; | |
let height = 4; | |
let expected = 12; | |
if (computeArea(width, height) === expected) { | |
console.log('SUCCESS: `computeArea` is working'); | |
} else { | |
console.log('FAILURE: `computeArea` is not working'); | |
} | |
} | |
testComputeArea(); |
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 celsToFahr(celsTemp) { | |
let result = celsTemp * (9/5) + 32; | |
return result; | |
} | |
function fahrToCels(fahrTemp) { | |
let final = (fahrTemp- 32) * (5/9); | |
return final; | |
} | |
/* From here down, you are not expected to | |
understand.... for now :) | |
Nothing to see here! | |
*/ | |
// tests | |
function testConversion(fn, input, expected) { | |
if (fn(input) === expected) { | |
console.log('SUCCESS: `' + fn.name + '` is working'); | |
return true; | |
} else { | |
console.log('FAILURE: `' + fn.name + '` is not working'); | |
return false; | |
} | |
} | |
function testConverters() { | |
let cel2FahrInput = 100; | |
let cel2FahrExpect = 212; | |
let fahr2CelInput = 32; | |
let fahr2CelExpect = 0; | |
if ( | |
testConversion(celsToFahr, cel2FahrInput, cel2FahrExpect) && | |
testConversion(fahrToCels, fahr2CelInput, fahr2CelExpect) | |
) { | |
console.log('SUCCESS: All tests passing'); | |
} else { | |
console.log('FAILURE: Some tests are failing'); | |
} | |
} | |
testConverters(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment