Skip to content
This repository was archived by the owner on Oct 26, 2020. It is now read-only.

Week 3 #96

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Exercise commits
  • Loading branch information
Osman-Hajr committed Jun 22, 2020
commit d5e52adf1b39d6ddeb44ea02278dc44070526b79
30 changes: 28 additions & 2 deletions week-2/1-exercises/F-logical-operators/exercise2.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,34 @@
Update the code so that you get the expected result.
*/

function isNegative() {}

function isNegative(num) {
if (num < 0) {
return true;
} else {
return false;
}
}
function isBetween5and10(num) {
if (num >= 5 && num <= 10) {
return true;
} else {
return false;
}
}
function isShortName(name) {
if (name.length < 10) {
return true;
} else {
return false;
}
}
function startsWithD(name) {
if (name[0] === "D") {
return "Yes";
} else {
return "No";
}
}
/*
DO NOT EDIT BELOW THIS LINE
--------------------------- */
Expand Down
6 changes: 5 additions & 1 deletion week-2/1-exercises/G-conditionals-2/exercise-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
*/

function negativeOrPositive(number) {

if (number < 0) {
return "negative";
} else if (number >= 0) {
return "positive";
}
}

/*
Expand Down
12 changes: 8 additions & 4 deletions week-2/1-exercises/G-conditionals-2/exercise-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
*/

function studentPassed(grade) {

if (grade < 50) {
return "failed";
} else {
return "passed";
}
}

/*
Expand All @@ -18,9 +22,9 @@ var grade1 = 49;
var grade2 = 50;
var grade3 = 100;

console.log("'" + grade1 + "': " + studentPassed(grade1))
console.log("'" + grade2 + "': " + studentPassed(grade2))
console.log("'" + grade3 + "': " + studentPassed(grade3))
console.log("'" + grade1 + "': " + studentPassed(grade1));
console.log("'" + grade2 + "': " + studentPassed(grade2));
console.log("'" + grade3 + "': " + studentPassed(grade3));

/*
EXPECTED RESULT
Expand Down
12 changes: 10 additions & 2 deletions week-2/1-exercises/G-conditionals-2/exercise-3.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@
*/

function calculateGrade(mark) {

if (mark > 80) {
return "A";
} else if (mark < 80 && mark >= 60) {
return "B";
} else if (mark < 60 && mark >= 50) {
return "C";
} else {
return "F";
}
}

/*
Expand All @@ -25,7 +33,7 @@ console.log("'" + grade2 + "': " + calculateGrade(grade2));
console.log("'" + grade3 + "': " + calculateGrade(grade3));
console.log("'" + grade4 + "': " + calculateGrade(grade4));

/*
/*
EXPECTED RESULT
---------------
'49': F
Expand Down
14 changes: 9 additions & 5 deletions week-2/1-exercises/G-conditionals-2/exercise-4.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
*/

function containsCode(sentence) {

if (sentence.includes("code")) {
return true;
} else {
return false;
}
}

/*
Expand All @@ -19,11 +23,11 @@ var sentence1 = "code your future";
var sentence2 = "draw your future";
var sentence3 = "design your future";

console.log("'" + sentence1 + "': " + containsCode(sentence1))
console.log("'" + sentence2 + "': " + containsCode(sentence2))
console.log("'" + sentence3 + "': " + containsCode(sentence3))
console.log("'" + sentence1 + "': " + containsCode(sentence1));
console.log("'" + sentence2 + "': " + containsCode(sentence2));
console.log("'" + sentence3 + "': " + containsCode(sentence3));

/*
/*
EXPECTED RESULT
---------------
'code your future': true
Expand Down
4 changes: 2 additions & 2 deletions week-2/1-exercises/H-array-literals/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Declare some variables assigned to arrays of values
*/

var numbers = []; // add numbers from 1 to 10 into this array
var mentors; // Create an array with the names of the mentors: Daniel, Irina and Rares
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; // add numbers from 1 to 10 into this array
var mentors = ["Daniel", "Irina", "Rares"]; // Create an array with the names of the mentors: Daniel, Irina and Rares

/*
DO NOT EDIT BELOW THIS LINE
Expand Down
7 changes: 6 additions & 1 deletion week-2/1-exercises/I-array-properties/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
*/

function isEmpty(arr) {
return; // complete this statement
if (arr.length === 0) {
return true;
} else {
return false;
}
// complete this statement
}

/*
Expand Down
4 changes: 2 additions & 2 deletions week-2/1-exercises/J-array-get-set/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
*/

function first(arr) {
return; // complete this statement
return arr[0]; // complete this statement
}

function last(arr) {
return; // complete this statement
return arr[arr.length - 1]; // complete this statement
}

/*
Expand Down
2 changes: 1 addition & 1 deletion week-2/1-exercises/J-array-get-set/exercises2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

var numbers = [1, 2, 3]; // Don't change this array literal declaration

numbers.push(4);
/*
DO NOT EDIT BELOW THIS LINE
--------------------------- */
Expand Down