Created
February 24, 2018 18:33
-
-
Save ivalexandru/29ef2a12e2df3b09ff3e35e49086e5b1 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
//calc cati ani ai | |
function calculateAge(yearOfBirth) { | |
var age = 2016 - yearOfBirth; | |
return age; | |
} | |
var ageJohn = calculateAge(1990); | |
var ageMike = calculateAge(1969); | |
console.log(ageJohn); | |
//cat mai ai pana la pensie | |
//calling another function | |
function yearsUntilRetirement(name, year) { | |
var age = calculateAge(year); | |
var retirement = 65 - age; | |
//pui aici console.log ca sa nu mai pui pt fiecare persoana | |
if (retirement >= 0) { | |
console.log(name + ' retires in ' + retirement + ' years'); | |
} else { | |
console.log( name + ' is already retired'); | |
} | |
} | |
yearsUntilRetirement('John', 1990); | |
yearsUntilRetirement("Mary", 1948); | |
// in JS, functiile nu tre sa returneze neaparat ceva | |
//function statement just performs an action | |
//function expression PRODUCES A VALUE, an outcome | |
//var someFun = function(par) { //code } asta e function expression | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment