Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions assignments/bmi_calculator/bmi_calculator.js
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 11 additions & 0 deletions assignments/can_drive/can_drive.js
Original file line number Diff line number Diff line change
@@ -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;


8 changes: 7 additions & 1 deletion assignments/favourite_movie/favourite_movie.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
7 changes: 6 additions & 1 deletion assignments/play_with_array/play_with_array.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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 = {
Expand Down
2 changes: 2 additions & 0 deletions assignments/run_callback/run_callback.js
Original file line number Diff line number Diff line change
@@ -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;