diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..7a73a41bfd --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/01-Fundamentals-Part-1/starter/assignmentFolder/CodingChalleges/codingChallenge_1.js b/01-Fundamentals-Part-1/starter/assignmentFolder/CodingChalleges/codingChallenge_1.js new file mode 100644 index 0000000000..9547de97a8 --- /dev/null +++ b/01-Fundamentals-Part-1/starter/assignmentFolder/CodingChalleges/codingChallenge_1.js @@ -0,0 +1,27 @@ +function bmi(mass, height) { + return mass / height ** 2; +} +console.log(bmi(78, 1.69)); +console.log("Break\nBreak\nBreak"); +let mark = { + mass: 78, + height: 1.69, + bmi: function () { + return (bmi = this.mass / this.height ** 2); + }, +}; +console.log(mark.bmi()); + +let john = { + mass: 92, + height: 1.95, + bmi: function () { + return (bmi = this.mass / this.height ** 2); + }, +}; +console.log(john.bmi()); + +let markHigherBMI = mark.bmi() > john.bmi(); +console.log(markHigherBMI); + +module.exports = bmi; diff --git a/01-Fundamentals-Part-1/starter/assignmentFolder/CodingChalleges/codingChallenge_2.js b/01-Fundamentals-Part-1/starter/assignmentFolder/CodingChalleges/codingChallenge_2.js new file mode 100644 index 0000000000..0c2e8bc3fa --- /dev/null +++ b/01-Fundamentals-Part-1/starter/assignmentFolder/CodingChalleges/codingChallenge_2.js @@ -0,0 +1,41 @@ +/* function bmi(mass, height) { + return mass / height ** 2; +} +console.log(bmi(78, 1.69)); +console.log("Break\nBreak\nBreak"); + */ +let mark = { + name: "Mark", + mass: 78, + height: 1.69, + bmi: function () { + bmi = this.mass / this.height ** 2; + return bmi.toFixed(2); + }, +}; + +let john = { + name: "John", + mass: 92, + height: 1.95, + bmi: function () { + bmi = this.mass / this.height ** 2; + return bmi.toFixed(2); + }, +}; + +if (mark.bmi() > john.bmi()) { + return console.log( + `${mark.name}'s BMI (${mark.bmi()}) is higher than ${ + john.name + }'s (${john.bmi()})!` + ); +} else if (john.bmi() > mark.bmi()) { + return console.log( + `${john.name}'s BMI (${john.bmi()}) is higher than ${ + mark.name + }'s (${mark.bmi()})!` + ); +} + +module.exports = bmi; diff --git a/01-Fundamentals-Part-1/starter/assignmentFolder/CodingChalleges/codingChallenge_2_1.js b/01-Fundamentals-Part-1/starter/assignmentFolder/CodingChalleges/codingChallenge_2_1.js new file mode 100644 index 0000000000..17e4bc43ec --- /dev/null +++ b/01-Fundamentals-Part-1/starter/assignmentFolder/CodingChalleges/codingChallenge_2_1.js @@ -0,0 +1,29 @@ +class person { + constructor(name, mass, height) { + this.name = name; + this.mass = mass; + this.height = height; + } + bmi = function () { + return Math.round((this.mass / this.height ** 2) * 100) / 100; + }; +} + +let mark = new person("Mark", 78, 1.69); +let john = new person("John", 92, 1.95); + +if (mark.bmi() > john.bmi()) { + return console.log( + `${mark.name}'s BMI (${mark.bmi()}) is higher than ${ + john.name + }'s (${john.bmi()})!` + ); +} else if (john.bmi() > mark.bmi()) { + return console.log( + `${john.name}'s BMI (${john.bmi()}) is higher than ${ + mark.name + }'s (${mark.bmi()})!` + ); +} + +module.exports = person; diff --git a/01-Fundamentals-Part-1/starter/assignmentFolder/CodingChalleges/tests/scriptAssignment.spec.js b/01-Fundamentals-Part-1/starter/assignmentFolder/CodingChalleges/tests/scriptAssignment.spec.js new file mode 100644 index 0000000000..51a61e03d6 --- /dev/null +++ b/01-Fundamentals-Part-1/starter/assignmentFolder/CodingChalleges/tests/scriptAssignment.spec.js @@ -0,0 +1,13 @@ +const person = require("../codingChallenge_2_1.js"); + +describe("BMI Function", function () { + test("deviding weight by 2 times the height,", function () { + let mark = new person("Mark", 78, 1.69); + expect(mark.bmi()).toEqual(27.31); + }); + test("if statement", function () { + let mark = new person("Mark", 78, 1.69); + let john = new person("John", 92, 1.95); + expect(mark.bmi() > john.bmi()).toEqual(27.31 > 24.19); + }); +}); diff --git a/01-Fundamentals-Part-1/starter/assignmentFolder/indexAssignment.html b/01-Fundamentals-Part-1/starter/assignmentFolder/indexAssignment.html new file mode 100644 index 0000000000..f38a7ae8a3 --- /dev/null +++ b/01-Fundamentals-Part-1/starter/assignmentFolder/indexAssignment.html @@ -0,0 +1,31 @@ + + +
+ + + +