From ac29a51c7e50a6765ffed2dcf13ab8523f13c3fd Mon Sep 17 00:00:00 2001 From: Swaroopaamruthwar Date: Mon, 17 Jan 2022 12:02:00 -0800 Subject: [PATCH 1/6] BMI-Calculator-Assignment --- assignments/bmi_calculator/bmi_calculator.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/assignments/bmi_calculator/bmi_calculator.js b/assignments/bmi_calculator/bmi_calculator.js index 0cdd351..ffeaa49 100644 --- a/assignments/bmi_calculator/bmi_calculator.js +++ b/assignments/bmi_calculator/bmi_calculator.js @@ -1,6 +1,13 @@ // This function should return the BMI for a person function BMICalculator(mass, height) { // Write your code here + if(mass>0 && height>0){ + BMI = mass / (height * height) + return BMI + } + else{ + return "INVALID INPUT"; + } } module.exports = BMICalculator; From 8d1b6ba94cd744bfd6fe29b705db96b82fcb0f44 Mon Sep 17 00:00:00 2001 From: Swaroopaamruthwar Date: Tue, 18 Jan 2022 13:01:13 -0800 Subject: [PATCH 2/6] CanDrive-Assignment --- assignments/can_drive/can_drive.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/assignments/can_drive/can_drive.js b/assignments/can_drive/can_drive.js index f2f1251..9d56844 100644 --- a/assignments/can_drive/can_drive.js +++ b/assignments/can_drive/can_drive.js @@ -1,5 +1,16 @@ function CanDrive(hasDrivingLiscence, isTired, isSober) { // Write you code here + if(hasDrivingLiscence===false){ + return "You cannot drive"; + } + else if(hasDrivingLiscence===true && (isTired===true || isSober===false)){ + return "You shouldn't drive"; + } + else if(hasDrivingLiscence===true && (isTired===false || isSober===true)){ + return "You can drive"; + } } module.exports = CanDrive; + + From a5e3ecceb01cdab88f2d17332f16d7137ca15462 Mon Sep 17 00:00:00 2001 From: Swaroopaamruthwar Date: Wed, 19 Jan 2022 13:13:47 -0800 Subject: [PATCH 3/6] favourite_movie AssignmentSubmission --- assignments/favourite_movie/favourite_movie.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/assignments/favourite_movie/favourite_movie.js b/assignments/favourite_movie/favourite_movie.js index a8148eb..cbc089f 100644 --- a/assignments/favourite_movie/favourite_movie.js +++ b/assignments/favourite_movie/favourite_movie.js @@ -2,6 +2,12 @@ const movies = []; function favouriteMovie(operation, movie) { // Write your code here + if(operation==="add"){ + movies.push(movie); + } + else if(operation==="remove"){ + movies.pop(); + } + return movies; } - module.exports = favouriteMovie; From 77148266a15534740e4875f4a5ae553c7cd49895 Mon Sep 17 00:00:00 2001 From: Swaroopaamruthwar Date: Thu, 20 Jan 2022 12:27:31 -0800 Subject: [PATCH 4/6] run_callback Assignment --- assignments/run_callback/run_callback.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assignments/run_callback/run_callback.js b/assignments/run_callback/run_callback.js index 04bf43e..6f866b4 100644 --- a/assignments/run_callback/run_callback.js +++ b/assignments/run_callback/run_callback.js @@ -1,5 +1,7 @@ function RunCallback(a, b, cb) { // Write you code here, you need to add a and b, pass the result into callback function cb as argument return the result + var sum=a+b; + return cb(sum); } module.exports = RunCallback; From e0729f27abc01607a53273ea7f9dfc0806ab3c16 Mon Sep 17 00:00:00 2001 From: Swaroopaamruthwar Date: Sat, 22 Jan 2022 12:18:29 -0800 Subject: [PATCH 5/6] play_with_array Assignment --- assignments/play_with_array/play_with_array.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/assignments/play_with_array/play_with_array.js b/assignments/play_with_array/play_with_array.js index 0601c6f..e30cbc2 100644 --- a/assignments/play_with_array/play_with_array.js +++ b/assignments/play_with_array/play_with_array.js @@ -7,7 +7,8 @@ function getEven(arr) { Write you code below */ - + var res=arr.filter(number=>number%2===0); + return res } function multiplyByN(arr, n) { @@ -18,6 +19,8 @@ function multiplyByN(arr, n) { Output: [3,9,13,165] Write you code below */ + var mul=arr.map(number=>number*n) + return mul } function removeNthElement(arr, n) { @@ -28,6 +31,8 @@ function removeNthElement(arr, n) { Output: [1,3,4,7] Write you code below */ + arr.splice(n,1); + return arr } module.exports = { From 34b2d2bb13dfde165a7d25ef0b0cfbd97e8b257a Mon Sep 17 00:00:00 2001 From: Swaroopaamruthwar Date: Sun, 23 Jan 2022 10:00:06 -0800 Subject: [PATCH 6/6] create_object Assignment --- assignments/create_object/create_object.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/assignments/create_object/create_object.js b/assignments/create_object/create_object.js index 775bc8c..09e0a33 100644 --- a/assignments/create_object/create_object.js +++ b/assignments/create_object/create_object.js @@ -1,5 +1,12 @@ function CreateObject(arr) { // Write your code here + obj={}; + arr.forEach((element,index,arr)=>{ + if(index%2===0){ + obj[element]=arr[index+1]; + } + }); + return obj; } module.exports = CreateObject;