Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions 02-Fundamentals-Part-2/final/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ const num = Number('23');
// Function Declarations vs. Expressions

// Function declaration
function calcAge1(birthYeah) {
return 2037 - birthYeah;
function calcAge1(birthYear) {
return 2037 - birthYear;
}
const age1 = calcAge1(1991);

// Function expression
const calcAge2 = function (birthYeah) {
return 2037 - birthYeah;
const calcAge2 = function (birthYear) {
return 2037 - birthYear;
}
const age2 = calcAge2(1991);

Expand All @@ -59,12 +59,12 @@ console.log(age1, age2);
///////////////////////////////////////
// Arrow functions

const calcAge3 = birthYeah => 2037 - birthYeah;
const calcAge3 = birthYear => 2037 - birthYear;
const age3 = calcAge3(1991);
console.log(age3);

const yearsUntilRetirement = (birthYeah, firstName) => {
const age = 2037 - birthYeah;
const yearsUntilRetirement = (birthYear, firstName) => {
const age = 2037 - birthYear;
const retirement = 65 - age;
// return retirement;
return `${firstName} retires in ${retirement} years`;
Expand All @@ -91,12 +91,12 @@ console.log(fruitProcessor(2, 3));

///////////////////////////////////////
// Reviewing Functions
const calcAge = function (birthYeah) {
return 2037 - birthYeah;
const calcAge = function (birthYear) {
return 2037 - birthYear;
}

const yearsUntilRetirement = function (birthYeah, firstName) {
const age = calcAge(birthYeah);
const yearsUntilRetirement = function (birthYear, firstName) {
const age = calcAge(birthYear);
const retirement = 65 - age;

if (retirement > 0) {
Expand Down Expand Up @@ -191,8 +191,8 @@ console.log(jonas);
console.log(jonas.length);

// Exercise
const calcAge = function (birthYeah) {
return 2037 - birthYeah;
const calcAge = function (birthYear) {
return 2037 - birthYear;
}
const years = [1990, 1967, 2002, 2010, 2018];

Expand Down Expand Up @@ -332,22 +332,22 @@ console.log(`${jonas.firstName} has ${jonas.friends.length} friends, and his bes
const jonas = {
firstName: 'Jonas',
lastName: 'Schmedtmann',
birthYeah: 1991,
birthYear: 1991,
job: 'teacher',
friends: ['Michael', 'Peter', 'Steven'],
hasDriversLicense: true,

// calcAge: function (birthYeah) {
// return 2037 - birthYeah;
// calcAge: function (birthYear) {
// return 2037 - birthYear;
// }

// calcAge: function () {
// // console.log(this);
// return 2037 - this.birthYeah;
// return 2037 - this.birthYear;
// }

calcAge: function () {
this.age = 2037 - this.birthYeah;
this.age = 2037 - this.birthYear;
return this.age;
},

Expand Down