From 71b22a3d81c3f0715f351a56ca19ba67e528ca04 Mon Sep 17 00:00:00 2001 From: lokeshvenkat17 Date: Wed, 20 Aug 2025 00:06:59 -0700 Subject: [PATCH] Fix variable name from birthYeah to birthYear for consistency in Section 2-Fundamentals-Part-2. --- 02-Fundamentals-Part-2/final/script.js | 36 +++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/02-Fundamentals-Part-2/final/script.js b/02-Fundamentals-Part-2/final/script.js index 8cee2087f7..c58140e987 100755 --- a/02-Fundamentals-Part-2/final/script.js +++ b/02-Fundamentals-Part-2/final/script.js @@ -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); @@ -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`; @@ -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) { @@ -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]; @@ -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; },