Created
July 11, 2017 15:06
-
-
Save HassanAlgoz/7c3146e3f7030554cbec7ac503dbf6c7 to your computer and use it in GitHub Desktop.
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
window.addEventListener('load', function() { | |
console.log("Hello from script.js") | |
// Functions | |
let a = Math.max(10, 43) | |
console.log( myMax(99, 45) ) | |
console.log( myMin(34, 12) ) | |
function myMax(a, b) { | |
if (a > b) { | |
return a | |
} else { | |
return b | |
} | |
} | |
function myMin(a, b) { | |
if (a <= b) { | |
return a | |
} else { | |
return b | |
} | |
} | |
function cubed(x) { | |
return x * x * x | |
} | |
let c = cubed(2) | |
console.log(c) | |
function metersToFeet(m) { | |
let result = meters * 3.28084 | |
return result | |
} | |
function feetToMeter(f) { | |
return f / 3.28084 | |
} | |
let meters = 14 | |
console.log( metersToFeet(meters) ) | |
function checkPasswordStrength(str) { | |
let lowerLimit = 4 | |
if (str.length > 10) { | |
console.log("Very Strong Password") | |
} else if (str.length > 7 ) { | |
console.log("Good Password") | |
} else if (str.length > 4) { | |
console.log("Weak Password") | |
} else { | |
console.log("Warning: password is less than " + lowerLimit) | |
} | |
} | |
console.log(lowerLimit) // error! | |
let password1 = "mysecretpassword1290xlpld9f4" | |
let password2 = "mofdp2x" | |
checkPasswordStrength(password1) | |
checkPasswordStrength(password2) | |
function equalLength(str1, str2) { | |
return (str1.length === str2.length) | |
} | |
let msg1 = "Better late than never. But never late is better" | |
let msg2 = "Don’t be pushed by your problems. Be led by your dreams" | |
if ( equalLength(str1, str2) ) { | |
console.log("Equal indeed") | |
} else { | |
console.log("Strings are unequal in length") | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment