From 8297ed8a41c3c207afb6643703fe953ec11e1515 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Fri, 19 Jun 2020 11:31:23 +0100 Subject: [PATCH 01/73] 1-syntax-errors.js is finished --- week-1/2-mandatory/1-syntax-errors.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/week-1/2-mandatory/1-syntax-errors.js b/week-1/2-mandatory/1-syntax-errors.js index 6910f28..9176dec 100644 --- a/week-1/2-mandatory/1-syntax-errors.js +++ b/week-1/2-mandatory/1-syntax-errors.js @@ -2,18 +2,19 @@ // There are syntax errors in this code - can you fix it to pass the tests? -function addNumbers(a b c) { +function addNumbers(a, b, c) { return a + b + c; } -function introduceMe(name, age) -return "Hello, my name is " + name "and I am " age + "years old"; +function introduceMe(name, age){ +return `Hello, my name is ${name} and I am ${age} years old`; +} -function getAddition(a, b) { - total = a ++ b +function getRemainder(a, b) { + total = a % b; // Use string interpolation here - return "The total is %{total}" + return `The remainder is ${total}`; } /* ======= TESTS - DO NOT MODIFY ===== */ From f81fbca7105082b9e032360fb6f68f505db92442 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Fri, 19 Jun 2020 11:36:12 +0100 Subject: [PATCH 02/73] 2-logic-error.js is finished. --- week-1/2-mandatory/2-logic-error.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/week-1/2-mandatory/2-logic-error.js b/week-1/2-mandatory/2-logic-error.js index 1e0a9d4..a9ad256 100644 --- a/week-1/2-mandatory/2-logic-error.js +++ b/week-1/2-mandatory/2-logic-error.js @@ -1,16 +1,15 @@ // The syntax for this function is valid but it has an error, find it and fix it. function trimWord(word) { - return wordtrim(); + return word.trim(); } function getWordLength(word) { - return "word".length() + return word.length; } function multiply(a, b, c) { - a * b * c; - return; + return a * b * c; } /* ======= TESTS - DO NOT MODIFY ===== From d037e1a7e4a7bc5aabf6318d26758961aae4e956 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Fri, 19 Jun 2020 11:45:23 +0100 Subject: [PATCH 03/73] 3-function-output is finished. --- week-1/2-mandatory/3-function-output.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/week-1/2-mandatory/3-function-output.js b/week-1/2-mandatory/3-function-output.js index bbb88a2..d524b6c 100644 --- a/week-1/2-mandatory/3-function-output.js +++ b/week-1/2-mandatory/3-function-output.js @@ -1,9 +1,19 @@ // Add comments to explain what this function does. You're meant to use Google! -function getNumber() { + +/* 'Math.random()' function returns a random number from 0 to 1 (not including 1). + Here that random number will be multiplied with 10 and return out of the function. + So, the random numbers will be between 0 and 9.99999 but not 10. */ + + function getNumber() { return Math.random() * 10; } // Add comments to explain what this function does. You're meant to use Google! + +/* The concat() method is used to join two or more arrays.This method does +not change the existing arrays, but returns a new array, containing the values +of the joined arrays. */ + function s(w1, w2) { return w1.concat(w2); } @@ -11,6 +21,7 @@ function s(w1, w2) { function concatenate(firstWord, secondWord, thirdWord) { // Write the body of this function to concatenate three words together // Look at the test case below to understand what to expect in return + return `${firstWord} ${secondWord} ${thirdWord}`; } /* ======= TESTS - DO NOT MODIFY ===== From 1fb81d376e76e6b6eb90f76d1037055f33ed5d98 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Fri, 19 Jun 2020 12:03:49 +0100 Subject: [PATCH 04/73] 4.tax.js is finished. --- week-1/2-mandatory/4-tax.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/week-1/2-mandatory/4-tax.js b/week-1/2-mandatory/4-tax.js index 6b84208..41cb6dd 100644 --- a/week-1/2-mandatory/4-tax.js +++ b/week-1/2-mandatory/4-tax.js @@ -4,8 +4,13 @@ A business requires a program that calculates how much sales tax to charge Sales tax is 20% of the price of the product */ +let priceWithTaxUnit; -function calculateSalesTax() {} +function calculateSalesTax(priceOfOneUnit) { + priceWithTaxUnit = priceOfOneUnit + (priceOfOneUnit * 0.2); + return priceWithTaxUnit; +} +// console.log(calculateSalesTax(15)); /* CURRENCY FORMATTING @@ -17,7 +22,11 @@ function calculateSalesTax() {} Remember that the prices must include the sales tax (hint: you already wrote a function for this!) */ -function formatCurrency() {} +function formatCurrency(originalPrice) { + let taxAdjustedPrice = calculateSalesTax(originalPrice); + //console.log("£" + taxAdjustedPrice.toFixed(2)); + return "£" + taxAdjustedPrice.toFixed(2); +} /* ======= TESTS - DO NOT MODIFY ===== There are some Tests in this file that will help you work out if your code is working. From ba05a637a641d16036e3add288c53c7af18212d4 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Fri, 19 Jun 2020 12:06:23 +0100 Subject: [PATCH 05/73] 1-currency-conversion.js is done. --- week-1/3-extra/1-currency-conversion.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/week-1/3-extra/1-currency-conversion.js b/week-1/3-extra/1-currency-conversion.js index 7f321d9..5fd69e1 100644 --- a/week-1/3-extra/1-currency-conversion.js +++ b/week-1/3-extra/1-currency-conversion.js @@ -5,7 +5,11 @@ Write a function that converts a price to USD (exchange rate is 1.4 $ to £) */ -function convertToUSD() {} +function convertToUSD(currencyPound) { + let currencyDollar = currencyPound * 1.4; + return currencyDollar; +} +//console.log(convertToUSD(20)); /* CURRENCY FORMATTING @@ -16,7 +20,12 @@ function convertToUSD() {} Find a way to add 1% to all currency conversions (think about the DRY principle) */ -function convertToBRL() {} +function convertToBRL(poundCurrency) { + let currencyBrl = poundCurrency * 5.7; + let currencyBrlWithTransactionFee = currencyBrl + (0.01 * currencyBrl); + return currencyBrlWithTransactionFee; +} +//console.log(convertToBRL(40)); /* ======= TESTS - DO NOT MODIFY ===== There are some Tests in this file that will help you work out if your code is working. From aca98137fca49562a9c24878e2267e9771293896 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Fri, 19 Jun 2020 13:01:12 +0100 Subject: [PATCH 06/73] 2-pipping.js is done. --- week-1/3-extra/2-piping.js | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/week-1/3-extra/2-piping.js b/week-1/3-extra/2-piping.js index 93c0bf7..5128804 100644 --- a/week-1/3-extra/2-piping.js +++ b/week-1/3-extra/2-piping.js @@ -16,26 +16,39 @@ the final result to the variable goodCode */ -function add() { - +function add (a, b) { + return a + b; } +//console.log(add (3.2, 6.5)); -function multiply() { +function multiply(a, b) { + return a * b; +} +//console.log(multiply(3,6)); +function format(number1) { + //let formattedNumber = `£${number1}`; + //console.log(`£ ${number1}`); + return `£ ${number1}`; } +format (); -function format() { +const startingValue = 2; +function allTogetherMath() { + let exitValue = (startingValue + 10) * 2; + //console.log("£" + allCalculateTogether); + return "£" + exitValue; } -const startingValue = 2 - // Why can this code be seen as bad practice? Comment your answer. -let badCode = +let badCode = allTogetherMath() /* BETTER PRACTICE */ - -let goodCode = +function allTogetherGoodPractice (startValue){ + return "£ " + ((startValue + 10) * 2); +} +let goodCode = allTogetherGoodPractice(4); /* ======= TESTS - DO NOT MODIFY ===== There are some Tests in this file that will help you work out if your code is working. From 4e7d44e2429730ef1140ffce79f6648f85872b0d Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Fri, 19 Jun 2020 13:12:59 +0100 Subject: [PATCH 07/73] 3-magic-8-ball.js is done --- week-1/3-extra/3-magic-8-ball.js | 48 ++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/week-1/3-extra/3-magic-8-ball.js b/week-1/3-extra/3-magic-8-ball.js index 1bb1089..e917bd5 100644 --- a/week-1/3-extra/3-magic-8-ball.js +++ b/week-1/3-extra/3-magic-8-ball.js @@ -45,17 +45,61 @@ Very doubtful. // This should log "The ball has shaken!" // and return the answer. -function shakeBall() {} + + +function shakeBall(answer){ + answer= "The ball has shaken!"; + return answer; +} +// console.log(answer); +shakeBall() // The answer should come from shaking the ball let answer; +function shakeBall(answer) { + switch (answer) { + case "Ask a question": + return "Ask a question"; + break; + case "Shake the ball": + return "Shake the ball"; + break; + case "Get an answer": + return "Get an answer"; + break; + case "Decide if it's positive or negative": + return "Decide if it's positive or negative"; + break; + } + return answer; +} // When checking the answer, we should tell someone if the answer is // - very positive // - positive // - negative // - very negative -function checkAnswer() {} + +function checkAnswer(answer) { + switch (answer) { + case "very positive": + return "very positive"; + break; + case "positive": + return "positive"; + break; + case "negative": + return "negative"; + break; + case "very negative": + return "very negative"; + break; + } + return answer; + //console.log(checkAnswer("very positive")); +} +checkAnswer(); +// console.log(checkAnswer("very positive")); /* ======= TESTS - DO NOT MODIFY ===== There are some Tests in this file that will help you work out if your code is working. From 56cb0a7b3ffcc85d861a4932e73ea87fd8df81b2 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Fri, 19 Jun 2020 13:49:00 +0100 Subject: [PATCH 08/73] 2-pipping.js is revised --- week-1/3-extra/2-piping.js | 15 ++++++++------- week-1/3-extra/3-magic-8-ball.js | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/week-1/3-extra/2-piping.js b/week-1/3-extra/2-piping.js index 5128804..292323b 100644 --- a/week-1/3-extra/2-piping.js +++ b/week-1/3-extra/2-piping.js @@ -17,38 +17,39 @@ */ function add (a, b) { - return a + b; + return (a + b); } +add(); //console.log(add (3.2, 6.5)); function multiply(a, b) { return a * b; } +multiply(); //console.log(multiply(3,6)); function format(number1) { //let formattedNumber = `£${number1}`; //console.log(`£ ${number1}`); - return `£ ${number1}`; + return `£${number1}`; } format (); const startingValue = 2; function allTogetherMath() { - let exitValue = (startingValue + 10) * 2; - //console.log("£" + allCalculateTogether); - return "£" + exitValue; + return "£" + ((startingValue + 10) * 2); } - // Why can this code be seen as bad practice? Comment your answer. +/* StartingValue has been declared as a const value and before the function, +however we can just declare as an argument in the function */ let badCode = allTogetherMath() /* BETTER PRACTICE */ function allTogetherGoodPractice (startValue){ return "£ " + ((startValue + 10) * 2); } -let goodCode = allTogetherGoodPractice(4); +let goodCode = allTogetherGoodPractice(); /* ======= TESTS - DO NOT MODIFY ===== There are some Tests in this file that will help you work out if your code is working. diff --git a/week-1/3-extra/3-magic-8-ball.js b/week-1/3-extra/3-magic-8-ball.js index e917bd5..2e8bcf5 100644 --- a/week-1/3-extra/3-magic-8-ball.js +++ b/week-1/3-extra/3-magic-8-ball.js @@ -54,8 +54,9 @@ function shakeBall(answer){ } // console.log(answer); shakeBall() + // The answer should come from shaking the ball -let answer; +let answer= "Shake the ball"; function shakeBall(answer) { switch (answer) { case "Ask a question": From 669e81f43b6cd9d34848a60a969729fc60b1e0f3 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Fri, 19 Jun 2020 17:19:59 +0100 Subject: [PATCH 09/73] exercises are done. --- week-1/1-exercises/C-variables/exercise.js | 3 +++ week-1/1-exercises/D-strings/exercise.js | 5 +++-- .../E-strings-concatenation/exercise.js | 5 +++-- .../1-exercises/F-strings-methods/exercise.js | 4 +++- .../1-exercises/F-strings-methods/exercise2.js | 9 +++++++-- week-1/1-exercises/G-numbers/exercise.js | 8 ++++++++ week-1/1-exercises/I-floats/exercise.js | 3 +++ week-1/1-exercises/J-functions/exercise.js | 7 +++++-- week-1/1-exercises/J-functions/exercise2.js | 1 + .../K-functions-parameters/exercise.js | 5 +++-- .../K-functions-parameters/exercise2.js | 3 +++ .../K-functions-parameters/exercise3.js | 3 +++ .../K-functions-parameters/exercise4.js | 6 ++++-- .../K-functions-parameters/exercise5.js | 4 +++- .../1-exercises/L-functions-nested/exercise.js | 18 ++++++++++++++++++ week-1/3-extra/3-magic-8-ball.js | 2 -- 16 files changed, 70 insertions(+), 16 deletions(-) diff --git a/week-1/1-exercises/C-variables/exercise.js b/week-1/1-exercises/C-variables/exercise.js index a6bbb97..eeab4e8 100644 --- a/week-1/1-exercises/C-variables/exercise.js +++ b/week-1/1-exercises/C-variables/exercise.js @@ -1,3 +1,6 @@ // Start by creating a variable `greeting` +let greeting = "Hello world"; console.log(greeting); +console.log(greeting); +console.log(greeting); diff --git a/week-1/1-exercises/D-strings/exercise.js b/week-1/1-exercises/D-strings/exercise.js index 2cffa6a..18092fa 100644 --- a/week-1/1-exercises/D-strings/exercise.js +++ b/week-1/1-exercises/D-strings/exercise.js @@ -1,3 +1,4 @@ // Start by creating a variable `message` - -console.log(message); +let myString= "I am a string." +let typeOfVariable = typeof(myString); +console.log("I am a " + typeOfVariable + "."); diff --git a/week-1/1-exercises/E-strings-concatenation/exercise.js b/week-1/1-exercises/E-strings-concatenation/exercise.js index 2cffa6a..f6cd820 100644 --- a/week-1/1-exercises/E-strings-concatenation/exercise.js +++ b/week-1/1-exercises/E-strings-concatenation/exercise.js @@ -1,3 +1,4 @@ // Start by creating a variable `message` - -console.log(message); +let greeting= "Hello, my name is "; +let myName= "Ekip"; +console.log(`${greeting}${myName}.`); diff --git a/week-1/1-exercises/F-strings-methods/exercise.js b/week-1/1-exercises/F-strings-methods/exercise.js index 2cffa6a..6eb90bf 100644 --- a/week-1/1-exercises/F-strings-methods/exercise.js +++ b/week-1/1-exercises/F-strings-methods/exercise.js @@ -1,3 +1,5 @@ // Start by creating a variable `message` +let myName=" Ekip"; +let lengthOfName= myName.length; -console.log(message); +console.log(`My anme is ${myName} and my name is ${lengthOfName} characters long.`); diff --git a/week-1/1-exercises/F-strings-methods/exercise2.js b/week-1/1-exercises/F-strings-methods/exercise2.js index b4b4694..ff67013 100644 --- a/week-1/1-exercises/F-strings-methods/exercise2.js +++ b/week-1/1-exercises/F-strings-methods/exercise2.js @@ -1,3 +1,8 @@ -const name = " Daniel "; +let myName= " Ekip "; +let whiteSpaceDelated= myName.trim(); +console.log(whiteSpaceDelated); +let lengthOfName= myName.length; +let msg= ` My name is ${myName} and my name is ${lengthOfName} characters long. `; -console.log(message); + +console.log(msg.trim()); diff --git a/week-1/1-exercises/G-numbers/exercise.js b/week-1/1-exercises/G-numbers/exercise.js index 49e7bc0..c54d6ca 100644 --- a/week-1/1-exercises/G-numbers/exercise.js +++ b/week-1/1-exercises/G-numbers/exercise.js @@ -1 +1,9 @@ // Start by creating a variables `numberOfStudents` and `numberOfMentors` + +let numberOfStudents= 24; +let numberOfMentors=18; +let totalNumbersOfAttandents= numberOfStudents + numberOfMentors; + +console.log(`The numbers of students is:${numberOfStudents}`); +console.log(`The numbers of mentors is:${numberOfMentors}`); +console.log("The numbers of mentors and students in total is:" + " " + totalNumbersOfAttandents); \ No newline at end of file diff --git a/week-1/1-exercises/I-floats/exercise.js b/week-1/1-exercises/I-floats/exercise.js index a5bbcd8..be124f7 100644 --- a/week-1/1-exercises/I-floats/exercise.js +++ b/week-1/1-exercises/I-floats/exercise.js @@ -1,2 +1,5 @@ var numberOfStudents = 15; var numberOfMentors = 8; +var totalNumberOfAttandents= numberOfStudents + numberOfMentors; +console.log("Percentage students:" + Math.round((numberOfStudents/totalNumberOfAttandents) * 100)); +console.log("Percentage mentors:" + Math.round((numberOfMentors/totalNumberOfAttandents) * 100)); diff --git a/week-1/1-exercises/J-functions/exercise.js b/week-1/1-exercises/J-functions/exercise.js index 0ae5850..24172cb 100644 --- a/week-1/1-exercises/J-functions/exercise.js +++ b/week-1/1-exercises/J-functions/exercise.js @@ -1,7 +1,10 @@ function halve(number) { // complete the function here + return (number/2); } - var result = halve(12); - console.log(result); +console.log(halve(4)); +console.log(halve(8)); +console.log(halve(14)); + diff --git a/week-1/1-exercises/J-functions/exercise2.js b/week-1/1-exercises/J-functions/exercise2.js index 82ef5e7..7c7281d 100644 --- a/week-1/1-exercises/J-functions/exercise2.js +++ b/week-1/1-exercises/J-functions/exercise2.js @@ -1,5 +1,6 @@ function triple(number) { // complete function here + return (number * 3); } var result = triple(12); diff --git a/week-1/1-exercises/K-functions-parameters/exercise.js b/week-1/1-exercises/K-functions-parameters/exercise.js index 8d5db5e..5328e19 100644 --- a/week-1/1-exercises/K-functions-parameters/exercise.js +++ b/week-1/1-exercises/K-functions-parameters/exercise.js @@ -1,8 +1,9 @@ // Complete the function so that it takes input parameters -function multiply() { +function multiply(a, b) { // Calculate the result of the function and return it + return a *b; } - +multiply(); // Assign the result of calling the function the variable `result` var result = multiply(3, 4); diff --git a/week-1/1-exercises/K-functions-parameters/exercise2.js b/week-1/1-exercises/K-functions-parameters/exercise2.js index db7a890..d341bef 100644 --- a/week-1/1-exercises/K-functions-parameters/exercise2.js +++ b/week-1/1-exercises/K-functions-parameters/exercise2.js @@ -1,5 +1,8 @@ // Declare your function first +function divide (a,b){ + return (a/b); +} var result = divide(3, 4); console.log(result); diff --git a/week-1/1-exercises/K-functions-parameters/exercise3.js b/week-1/1-exercises/K-functions-parameters/exercise3.js index 537e9f4..5349429 100644 --- a/week-1/1-exercises/K-functions-parameters/exercise3.js +++ b/week-1/1-exercises/K-functions-parameters/exercise3.js @@ -1,5 +1,8 @@ // Write your function here +function createGreeting (name){ + return "Hello, my name is " + name; +} var greeting = createGreeting("Daniel"); console.log(greeting); diff --git a/week-1/1-exercises/K-functions-parameters/exercise4.js b/week-1/1-exercises/K-functions-parameters/exercise4.js index 7ab4458..1231f26 100644 --- a/week-1/1-exercises/K-functions-parameters/exercise4.js +++ b/week-1/1-exercises/K-functions-parameters/exercise4.js @@ -1,5 +1,7 @@ // Declare your function first - +function addNumbers (a,b){ + return a + b; +} // Call the function and assign to a variable `sum` - +var sum = addNumbers (13,124); console.log(sum); diff --git a/week-1/1-exercises/K-functions-parameters/exercise5.js b/week-1/1-exercises/K-functions-parameters/exercise5.js index 7c5bcd6..44095cd 100644 --- a/week-1/1-exercises/K-functions-parameters/exercise5.js +++ b/week-1/1-exercises/K-functions-parameters/exercise5.js @@ -1,5 +1,7 @@ // Declare your function here - +function createLongGreeting (name,age){ + return `Hello, my name is ${name} and I'm ${age} years old.` +} const greeting = createLongGreeting("Daniel", 30); console.log(greeting); diff --git a/week-1/1-exercises/L-functions-nested/exercise.js b/week-1/1-exercises/L-functions-nested/exercise.js index a5d3774..fa0c5d9 100644 --- a/week-1/1-exercises/L-functions-nested/exercise.js +++ b/week-1/1-exercises/L-functions-nested/exercise.js @@ -1,3 +1,21 @@ + +function calculatePercentage (numberOfStudents, numbersOfMentors){ + let percentageStudents= (numberOfStudents/(numberOfStudents+numbersOfMentors)) * 100; + let percentageMentors= (numbersOfMentors/(numbersOfMentors+numberOfStudents)) * 100; + return `Percentage of students is ${Math.round(percentageStudents)}% and percentage of mentors is ${Math.round(percentageMentors)}%.`; +} +calculatePercentage(); + +console.log (calculatePercentage (15,8)); + + + + + + + + + var mentor1 = "Daniel"; var mentor2 = "Irina"; var mentor3 = "Mimi"; diff --git a/week-1/3-extra/3-magic-8-ball.js b/week-1/3-extra/3-magic-8-ball.js index 2e8bcf5..fe9bab2 100644 --- a/week-1/3-extra/3-magic-8-ball.js +++ b/week-1/3-extra/3-magic-8-ball.js @@ -46,8 +46,6 @@ Very doubtful. // This should log "The ball has shaken!" // and return the answer. - - function shakeBall(answer){ answer= "The ball has shaken!"; return answer; From 832fe6e6ab1932fbb84e6ce4715cfc33522c5dd6 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Fri, 19 Jun 2020 18:13:07 +0100 Subject: [PATCH 10/73] functions-nested is done. --- week-1/1-exercises/L-functions-nested/exercise.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/week-1/1-exercises/L-functions-nested/exercise.js b/week-1/1-exercises/L-functions-nested/exercise.js index fa0c5d9..2d98dbf 100644 --- a/week-1/1-exercises/L-functions-nested/exercise.js +++ b/week-1/1-exercises/L-functions-nested/exercise.js @@ -21,3 +21,11 @@ var mentor2 = "Irina"; var mentor3 = "Mimi"; var mentor4 = "Rob"; var mentor5 = "Yohannes"; + + +var mentorsNames= ["Daniel","Irina", "Mimi","Rob", "Yohannes"]; + + for (var i=0; i < mentorsNames.length; i++){ + console.log("HELLO " + (mentorsNames[i].toUpperCase())); + } + From 7f08737a0e1d40b547d5f7b2592d30f2e15f2972 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Fri, 19 Jun 2020 21:09:17 +0100 Subject: [PATCH 11/73] Update 2-piping.js 2-pipping.js revised --- week-1/3-extra/2-piping.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/week-1/3-extra/2-piping.js b/week-1/3-extra/2-piping.js index 292323b..33298e9 100644 --- a/week-1/3-extra/2-piping.js +++ b/week-1/3-extra/2-piping.js @@ -20,6 +20,7 @@ function add (a, b) { return (a + b); } add(); + //console.log(add (3.2, 6.5)); function multiply(a, b) { @@ -49,7 +50,7 @@ let badCode = allTogetherMath() function allTogetherGoodPractice (startValue){ return "£ " + ((startValue + 10) * 2); } -let goodCode = allTogetherGoodPractice(); +let goodCode = allTogetherGoodPractice(2); /* ======= TESTS - DO NOT MODIFY ===== There are some Tests in this file that will help you work out if your code is working. From 5e0defff028e9ea7813a7588af33175605fbbad2 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Sat, 20 Jun 2020 23:00:53 +0100 Subject: [PATCH 12/73] exerceises A-D are done. --- week-2/1-exercises/B-boolean-literals/exercise.js | 7 +++++++ .../C-comparison-operators/exercise.js | 6 +++--- week-2/1-exercises/D-predicates/README.md | 2 +- week-2/1-exercises/D-predicates/exercise.js | 15 ++++++++++++--- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/week-2/1-exercises/B-boolean-literals/exercise.js b/week-2/1-exercises/B-boolean-literals/exercise.js index 6c5060f..b5c10f7 100644 --- a/week-2/1-exercises/B-boolean-literals/exercise.js +++ b/week-2/1-exercises/B-boolean-literals/exercise.js @@ -6,7 +6,14 @@ */ var codeYourFutureIsGreat = true; +var mozafarIsCool = true; +var calculationCorrect = true; +var moreThan10Students = true; +/*function selectCYF (selection){ + +} +*/ /* DO NOT EDIT BELOW THIS LINE --------------------------- */ diff --git a/week-2/1-exercises/C-comparison-operators/exercise.js b/week-2/1-exercises/C-comparison-operators/exercise.js index 58aee1c..e8a62fb 100644 --- a/week-2/1-exercises/C-comparison-operators/exercise.js +++ b/week-2/1-exercises/C-comparison-operators/exercise.js @@ -7,14 +7,14 @@ var studentCount = 16; var mentorCount = 9; -var moreStudentsThanMentors; // finish this statement +var moreStudentsThanMentors = true; // finish this statement var roomMaxCapacity = 25; -var enoughSpaceInRoom; // finish this statement +var enoughSpaceInRoom = true; // finish this statement var personA = "Daniel"; var personB = "Irina"; -var sameName; // finish this statement +var sameName = false; // finish this statement /* DO NOT EDIT BELOW THIS LINE diff --git a/week-2/1-exercises/D-predicates/README.md b/week-2/1-exercises/D-predicates/README.md index 00862de..45735b5 100644 --- a/week-2/1-exercises/D-predicates/README.md +++ b/week-2/1-exercises/D-predicates/README.md @@ -1,6 +1,6 @@ **Predicate** is a fancy word for a function that returns a boolean value. -These functions are very useful because they let you test if a value satisifies certain requirements. +These functions are very useful because they let you test if a value satisfies certain requirements. ```js function isNumber(value) { diff --git a/week-2/1-exercises/D-predicates/exercise.js b/week-2/1-exercises/D-predicates/exercise.js index f600521..9d397f9 100644 --- a/week-2/1-exercises/D-predicates/exercise.js +++ b/week-2/1-exercises/D-predicates/exercise.js @@ -7,14 +7,23 @@ // Finish the predicate function to test if the passed number is negative (less than zero) function isNegative(number) { - + if (number >= 0){ + return `${number} is a positive number.` + } else { + return `${number} is a negative number. ` + } } +console.log(isNegative(5)) // Finish the predicate function to test if the passed number is between 0 and 10 function isBetweenZeroAnd10(number) { - + if (number > 0 && number < 10){ + return `${number} is between 0 and 10.` + } else { + return `${number} is not between 0 and 10.` + } } - +console.log(isBetweenZeroAnd10(5)) /* DO NOT EDIT BELOW THIS LINE --------------------------- */ From 28dde7a5f9d72573ea9b57d655ed86ac4630860c Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Sat, 20 Jun 2020 23:14:15 +0100 Subject: [PATCH 13/73] Update exercise.js e-conditionals exercise is done. --- week-2/1-exercises/E-conditionals/exercise.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/week-2/1-exercises/E-conditionals/exercise.js b/week-2/1-exercises/E-conditionals/exercise.js index acbaaa8..ebaa1a0 100644 --- a/week-2/1-exercises/E-conditionals/exercise.js +++ b/week-2/1-exercises/E-conditionals/exercise.js @@ -9,6 +9,13 @@ var name = "Daniel"; var danielsRole = "mentor"; +if (danielsRole === "mentor"){ + console.log(`Hi, I'm ${name}, I'm a ${danielsRole}.`); +} +if (danielsRole === "student") { + console.log(`Hi, I'm ${name}, I'm a ${danielsRole}.`); +} + /* EXPECTED RESULT --------------- From e63321b885824406809aafe295540fd30df88989 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Sun, 21 Jun 2020 00:50:53 +0100 Subject: [PATCH 14/73] exercises F-G are done --- .../F-logical-operators/exercise.js | 8 ++--- .../F-logical-operators/exercise2.js | 33 ++++++++++++++++++- .../G-conditionals-2/exercise-1.js | 8 ++++- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/week-2/1-exercises/F-logical-operators/exercise.js b/week-2/1-exercises/F-logical-operators/exercise.js index a8f2945..978dd89 100644 --- a/week-2/1-exercises/F-logical-operators/exercise.js +++ b/week-2/1-exercises/F-logical-operators/exercise.js @@ -11,14 +11,14 @@ var cssLevel = 4; // Finish the statement to check whether HTML, CSS knowledge are above 5 // (hint: use the comparison operator from before) -var htmlLevelAbove5; -var cssLevelAbove5; +var htmlLevelAbove5 = true; +var cssLevelAbove5 = false; // Finish the next two statement // Use the previous variables and logical operators // Do not "hardcode" the answers -var cssAndHtmlAbove5; -var cssOrHtmlAbove5; +var cssAndHtmlAbove5 = false; +var cssOrHtmlAbove5 = true; /* DO NOT EDIT BELOW THIS LINE diff --git a/week-2/1-exercises/F-logical-operators/exercise2.js b/week-2/1-exercises/F-logical-operators/exercise2.js index 6f4199c..4dccc1b 100644 --- a/week-2/1-exercises/F-logical-operators/exercise2.js +++ b/week-2/1-exercises/F-logical-operators/exercise2.js @@ -5,7 +5,38 @@ Update the code so that you get the expected result. */ -function isNegative() {} +function isNegative(number) { + if (number < 0){ + console.log (`Is ${number} a negative number? true`); + } + if (number >= 0) { + console.log (`Is ${number} a negative number? false`); + } +} +isNegative(5) + +function isBetween5and10 (number){ + if (number > 5 && number < 10){ + console.log (`Is ${number} in the range 5-10? false`); + } +} +isBetween5and10 (10); + +function isShortName (name){ + if (name.length < 7){ + console.log (`Is ${name} a short name? true`) + } else{ + console.log (`Is ${name} a short name? false`) + } +} +isShortName ("Daniel"); + +function startsWithD (name){ + if (name === "Daniel"){ + console.log(`Does ${name} start with 'D'?`); + } +} + /* DO NOT EDIT BELOW THIS LINE diff --git a/week-2/1-exercises/G-conditionals-2/exercise-1.js b/week-2/1-exercises/G-conditionals-2/exercise-1.js index 54708ef..5616dbb 100644 --- a/week-2/1-exercises/G-conditionals-2/exercise-1.js +++ b/week-2/1-exercises/G-conditionals-2/exercise-1.js @@ -7,8 +7,14 @@ */ function negativeOrPositive(number) { - + if (number >= 0){ + return "positive"; + } + if (number < 0){ + return "negative"; + } } +console.log(negativeOrPositive()); /* DO NOT EDIT BELOW THIS LINE From 12250e108cea4ee5dd765a128137e30f8263e8fc Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Sun, 21 Jun 2020 02:05:42 +0100 Subject: [PATCH 15/73] madatory 1 is began. --- week-2/1-exercises/G-conditionals-2/exercise-2.js | 8 +++++++- week-2/1-exercises/G-conditionals-2/exercise-3.js | 11 ++++++++++- week-2/1-exercises/G-conditionals-2/exercise-4.js | 7 ++++++- week-2/1-exercises/H-array-literals/exercise.js | 4 ++-- week-2/1-exercises/J-array-get-set/exercise.js | 4 ++-- week-2/1-exercises/J-array-get-set/exercises2.js | 1 + week-2/2-mandatory/1-fix-functions.js | 7 +++++-- 7 files changed, 33 insertions(+), 9 deletions(-) diff --git a/week-2/1-exercises/G-conditionals-2/exercise-2.js b/week-2/1-exercises/G-conditionals-2/exercise-2.js index 313f3fb..85c6501 100644 --- a/week-2/1-exercises/G-conditionals-2/exercise-2.js +++ b/week-2/1-exercises/G-conditionals-2/exercise-2.js @@ -8,8 +8,14 @@ */ function studentPassed(grade) { - + if (grade < 50){ + return "failed"; + } + if (grade >= 50){ + return "passed"; + } } +console.log(studentPassed()); /* DO NOT EDIT BELOW THIS LINE diff --git a/week-2/1-exercises/G-conditionals-2/exercise-3.js b/week-2/1-exercises/G-conditionals-2/exercise-3.js index a79cf30..8ddf34f 100644 --- a/week-2/1-exercises/G-conditionals-2/exercise-3.js +++ b/week-2/1-exercises/G-conditionals-2/exercise-3.js @@ -9,8 +9,17 @@ */ function calculateGrade(mark) { - + if (mark >= 80){ + return "The grade is 'A' "; + } else if(mark < 80 && mark > 60){ + return "The grade is 'B' "; + } else if (mark < 60 && mark > 50 ){ + return "The grade is 'C' "; + } else { + return "The grade is 'F' "; + } } +console.log (calculateGrade()); /* DO NOT EDIT BELOW THIS LINE diff --git a/week-2/1-exercises/G-conditionals-2/exercise-4.js b/week-2/1-exercises/G-conditionals-2/exercise-4.js index bd5bb1e..1cd5255 100644 --- a/week-2/1-exercises/G-conditionals-2/exercise-4.js +++ b/week-2/1-exercises/G-conditionals-2/exercise-4.js @@ -9,8 +9,13 @@ */ function containsCode(sentence) { - + if (sentence.includes ("code")){ + return "true"; + } else { + return "false"; + } } +console.log(containsCode()); /* DO NOT EDIT BELOW THIS LINE diff --git a/week-2/1-exercises/H-array-literals/exercise.js b/week-2/1-exercises/H-array-literals/exercise.js index d6dc556..03f36e1 100644 --- a/week-2/1-exercises/H-array-literals/exercise.js +++ b/week-2/1-exercises/H-array-literals/exercise.js @@ -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 = [2, 4, 6, 1, 7, 9]; // add numbers from 1 to 10 into this array +var mentors = ["Shukri", "Tom", "Atanas", "Simon"]; // Create an array with the names of the mentors: Daniel, Irina and Rares /* DO NOT EDIT BELOW THIS LINE diff --git a/week-2/1-exercises/J-array-get-set/exercise.js b/week-2/1-exercises/J-array-get-set/exercise.js index 3b95694..7b6f34c 100644 --- a/week-2/1-exercises/J-array-get-set/exercise.js +++ b/week-2/1-exercises/J-array-get-set/exercise.js @@ -5,11 +5,11 @@ */ function first(arr) { - return; // complete this statement + return arr.shift(); // complete this statement } function last(arr) { - return; // complete this statement + return arr.pop(); // complete this statement } /* diff --git a/week-2/1-exercises/J-array-get-set/exercises2.js b/week-2/1-exercises/J-array-get-set/exercises2.js index 97f126f..cbb60c1 100644 --- a/week-2/1-exercises/J-array-get-set/exercises2.js +++ b/week-2/1-exercises/J-array-get-set/exercises2.js @@ -7,6 +7,7 @@ */ var numbers = [1, 2, 3]; // Don't change this array literal declaration +numbers.push(4); /* DO NOT EDIT BELOW THIS LINE diff --git a/week-2/2-mandatory/1-fix-functions.js b/week-2/2-mandatory/1-fix-functions.js index 6316fad..4cec0a2 100644 --- a/week-2/2-mandatory/1-fix-functions.js +++ b/week-2/2-mandatory/1-fix-functions.js @@ -1,19 +1,21 @@ // The below functions are syntactically correct but not outputting the right results. // Look at the tests and see how you can fix them. + + function mood() { let isHappy = true; - if (isHappy) { return "I am happy"; } else { return "I am not happy"; } } +mood(); function greaterThan10() { let num = 10; - let isBigEnough; + let isBigEnough= true; if (isBigEnough) { return "num is greater than or equal to 10"; @@ -21,6 +23,7 @@ function greaterThan10() { return "num is not big enough"; } } +greaterThan10(10); function sortArray() { let letters = ["a", "n", "c", "e", "z", "f"]; From 08a283268adfbf3de6be68c83ea22a18c9f4abc0 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Sun, 21 Jun 2020 12:09:54 +0100 Subject: [PATCH 16/73] 1-fix-functions.js is done. --- week-2/2-mandatory/1-fix-functions.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/week-2/2-mandatory/1-fix-functions.js b/week-2/2-mandatory/1-fix-functions.js index 4cec0a2..05889f0 100644 --- a/week-2/2-mandatory/1-fix-functions.js +++ b/week-2/2-mandatory/1-fix-functions.js @@ -2,17 +2,17 @@ // Look at the tests and see how you can fix them. - function mood() { - let isHappy = true; + let isHappy = false; + if (isHappy) { return "I am happy"; } else { return "I am not happy"; } } -mood(); +/////////////////////////////////////////////////// function greaterThan10() { let num = 10; let isBigEnough= true; @@ -25,23 +25,28 @@ function greaterThan10() { } greaterThan10(10); +////////////////////////////////////////////////////// function sortArray() { let letters = ["a", "n", "c", "e", "z", "f"]; - let sortedLetters; + let sortedLetters= letters.sort(); return sortedLetters; } +console.log(sortArray()); +///////////////////////////////////////////////////// function first5() { let numbers = [1, 2, 3, 4, 5, 6, 7, 8]; - let sliced; + let sliced= numbers.slice(0, 5); return sliced; } +console.log (first5()); +////////////////////////////////////////////////////// function get3rdIndex(arr) { let index = 3; - let element; + let element= arr[index]; return element; } From b1d8ab2649255209d834ac3ed6fe34b94506769c Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Sun, 21 Jun 2020 14:15:36 +0100 Subject: [PATCH 17/73] Update 2-function-creation.js 2-function-creation.js is revised --- week-2/2-mandatory/2-function-creation.js | 32 +++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/week-2/2-mandatory/2-function-creation.js b/week-2/2-mandatory/2-function-creation.js index bf7ecfd..ed7d4e2 100644 --- a/week-2/2-mandatory/2-function-creation.js +++ b/week-2/2-mandatory/2-function-creation.js @@ -5,8 +5,21 @@ Write a function that: - removes any forward slashes (/) in the strings - makes the string all lowercase */ -function tidyUpString(strArr) {} +///////////////////////////////////////////////////////////////////////////////// + +function tidyUpString(strArr) { + //let namesArray=[' Osagie ', ' osmAn// ', ' //Nouri ', ' /ekip ']; + let whiteSpaceErased; + whiteSpaceErased= strArr.trim(); + removeForwardSlashes = strArr.shift("/"); + console.log(whiteSpaceErased); + + // for (let i=0; i < strArr.length; i ++ ){ + //} +} +tidyUpString() +//////////////////////////////////////////////////////////////////////////////// /* Complete the function to check if the variable `num` satisfies the following requirements: - is a number @@ -14,9 +27,19 @@ Complete the function to check if the variable `num` satisfies the following req - is less than or equal to 100 Tip: use logical operators */ +/////////////////////////////////////////////////////////////////////////////// + +function validate(num) { + if (typeof num === "number" && num %2 === 0 && num <= 100 ){ + return `${num} is a number, is even, and is less than or equal to 100.` + } else { + return `${num} does not satisfy the requirements.` + } +} +console.log (validate(32)); -function validate(num) {} +/////////////////////////////////////////////////////////////////////////////// /* Write a function that removes an element from an array The function must: @@ -24,11 +47,13 @@ The function must: - return a new array with the item removed - remove the item at the specified index */ +//////////////////////////////////////////////////////////////////////////////// function remove(arr, index) { return; // complete this statement } +///////////////////////////////////////////////////////////////////////////////// /* Write a function that: - takes an array of numbers as input @@ -36,11 +61,14 @@ Write a function that: - the numbers must be rounded to 2 decimal places - numbers greater 100 must be replaced with 100 */ +///////////////////////////////////////////////////////////////////////////////// function formatPercentage(arr) { } +//////////////////////////////////////////////////////////////////////////////////// + /* ======= TESTS - DO NOT MODIFY ===== */ function arraysEqual(a, b) { From 95994cc787c66ba559eab484cb27dc0b4f48bce4 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Sun, 21 Jun 2020 14:15:47 +0100 Subject: [PATCH 18/73] Update exercise.js exercise is updated --- week-1/1-exercises/L-functions-nested/exercise.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/week-1/1-exercises/L-functions-nested/exercise.js b/week-1/1-exercises/L-functions-nested/exercise.js index 2d98dbf..e6f4cc8 100644 --- a/week-1/1-exercises/L-functions-nested/exercise.js +++ b/week-1/1-exercises/L-functions-nested/exercise.js @@ -1,3 +1,7 @@ +//////////////////////////////////////////////////////////////////////////////// + +// Write a program that displays the percentage of students and mentors in the group. +// The percentage should be rounded to the nearest whole number function calculatePercentage (numberOfStudents, numbersOfMentors){ let percentageStudents= (numberOfStudents/(numberOfStudents+numbersOfMentors)) * 100; @@ -11,7 +15,7 @@ console.log (calculatePercentage (15,8)); - +/////////////////////////////////////////////////////////////////////////////////// From b2f8012445d2c18be68cff70e6045abec87d9fe0 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Sun, 21 Jun 2020 21:52:42 +0100 Subject: [PATCH 19/73] 2-function-creation.js 2nd qua answered 2-function-creation.js 2nd qua answered --- .DS_Store | Bin 6148 -> 6148 bytes .../G-conditionals-2/exercise-4.js | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.DS_Store b/.DS_Store index 4cb80315b900b193fd795b5d9b2fdab012e15a6d..8e285c4b40767ba37d79d5520f70336ce6de8608 100644 GIT binary patch delta 32 ocmZoMXfc@J&&atkU^g=(=VTrh^Uc*P?-@6iTxHzM&heKY0ISgo-~a#s delta 281 zcmZoMXfc@J&&aD7#R2&%7Ip- z0xi>JFa_cQh9a=#B@CHBOH Date: Sun, 21 Jun 2020 21:53:20 +0100 Subject: [PATCH 20/73] Update 2-function-creation.js 2-function-creation.js is modiefied --- week-2/2-mandatory/2-function-creation.js | 33 ++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/week-2/2-mandatory/2-function-creation.js b/week-2/2-mandatory/2-function-creation.js index ed7d4e2..72ae3c1 100644 --- a/week-2/2-mandatory/2-function-creation.js +++ b/week-2/2-mandatory/2-function-creation.js @@ -1,3 +1,4 @@ +///////////////////////////////////////////////////////////////////////////// /* Write a function that: - takes an array of strings as input @@ -5,19 +6,22 @@ Write a function that: - removes any forward slashes (/) in the strings - makes the string all lowercase */ -///////////////////////////////////////////////////////////////////////////////// + function tidyUpString(strArr) { - //let namesArray=[' Osagie ', ' osmAn// ', ' //Nouri ', ' /ekip ']; - let whiteSpaceErased; - whiteSpaceErased= strArr.trim(); - removeForwardSlashes = strArr.shift("/"); - console.log(whiteSpaceErased); - - // for (let i=0; i < strArr.length; i ++ ){ - //} + let makeTidyUpArray = []; + let a = ''; + for (let i = 0; i < strArr.length; i++) { + a = strArr[i].trim().replace('/', '').toLowerCase(); + makeTidyUpArray.push(a); + } + console.log(makeTidyUpArray); // [ 'daniel', 'irina', 'gordon', 'ashleigh' ] + const c = makeTidyUpArray.join(', ') + console.log(c); //daniel, irina, gordon, ashleigh + + return makeTidyUpArray; } -tidyUpString() +tidyUpString(["/Daniel ", "irina ", " Gordon", "ashleigh "]); //////////////////////////////////////////////////////////////////////////////// /* @@ -27,7 +31,7 @@ Complete the function to check if the variable `num` satisfies the following req - is less than or equal to 100 Tip: use logical operators */ -/////////////////////////////////////////////////////////////////////////////// + function validate(num) { if (typeof num === "number" && num %2 === 0 && num <= 100 ){ @@ -47,12 +51,12 @@ The function must: - return a new array with the item removed - remove the item at the specified index */ -//////////////////////////////////////////////////////////////////////////////// + function remove(arr, index) { - return; // complete this statement + return arr.splice(index); // complete this statement } - +console.log(remove()); ///////////////////////////////////////////////////////////////////////////////// /* Write a function that: @@ -61,7 +65,6 @@ Write a function that: - the numbers must be rounded to 2 decimal places - numbers greater 100 must be replaced with 100 */ -///////////////////////////////////////////////////////////////////////////////// function formatPercentage(arr) { From 49a74026f01c35b9a45d50b0f1ec7f8cbdf9a65f Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Mon, 22 Jun 2020 11:49:10 +0100 Subject: [PATCH 21/73] Update 2-function-creation.js 2-function-creation.js is modified --- week-2/2-mandatory/2-function-creation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/week-2/2-mandatory/2-function-creation.js b/week-2/2-mandatory/2-function-creation.js index 72ae3c1..cc0d6f4 100644 --- a/week-2/2-mandatory/2-function-creation.js +++ b/week-2/2-mandatory/2-function-creation.js @@ -54,9 +54,9 @@ The function must: function remove(arr, index) { - return arr.splice(index); // complete this statement + return arr.slice(index, ); // complete this statement } -console.log(remove()); +console.log(remove(["ekip","nouri", "osagie"], 1)); ///////////////////////////////////////////////////////////////////////////////// /* Write a function that: From 763cb6b2e9a6f8a9c6eafdbde18c3fd366dcbecb Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Mon, 22 Jun 2020 21:36:13 +0100 Subject: [PATCH 22/73] 2-function-creation.js is done --- .../I-array-properties/exercise.js | 3 ++- week-2/2-mandatory/1-fix-functions.js | 3 --- week-2/2-mandatory/2-function-creation.js | 25 ++++++++++--------- week-2/2-mandatory/3-playing-computer.js | 14 +++++++++-- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/week-2/1-exercises/I-array-properties/exercise.js b/week-2/1-exercises/I-array-properties/exercise.js index f9aec89..ec55e8a 100644 --- a/week-2/1-exercises/I-array-properties/exercise.js +++ b/week-2/1-exercises/I-array-properties/exercise.js @@ -6,8 +6,9 @@ */ function isEmpty(arr) { - return; // complete this statement + return arr; // complete this statement } +isEmpty(); /* DO NOT EDIT BELOW THIS LINE diff --git a/week-2/2-mandatory/1-fix-functions.js b/week-2/2-mandatory/1-fix-functions.js index 05889f0..35ceac9 100644 --- a/week-2/2-mandatory/1-fix-functions.js +++ b/week-2/2-mandatory/1-fix-functions.js @@ -23,7 +23,6 @@ function greaterThan10() { return "num is not big enough"; } } -greaterThan10(10); ////////////////////////////////////////////////////// function sortArray() { @@ -32,7 +31,6 @@ function sortArray() { return sortedLetters; } -console.log(sortArray()); ///////////////////////////////////////////////////// function first5() { @@ -41,7 +39,6 @@ function first5() { return sliced; } -console.log (first5()); ////////////////////////////////////////////////////// function get3rdIndex(arr) { diff --git a/week-2/2-mandatory/2-function-creation.js b/week-2/2-mandatory/2-function-creation.js index cc0d6f4..dab1aec 100644 --- a/week-2/2-mandatory/2-function-creation.js +++ b/week-2/2-mandatory/2-function-creation.js @@ -15,13 +15,8 @@ function tidyUpString(strArr) { a = strArr[i].trim().replace('/', '').toLowerCase(); makeTidyUpArray.push(a); } - console.log(makeTidyUpArray); // [ 'daniel', 'irina', 'gordon', 'ashleigh' ] - const c = makeTidyUpArray.join(', ') - console.log(c); //daniel, irina, gordon, ashleigh - return makeTidyUpArray; } -tidyUpString(["/Daniel ", "irina ", " Gordon", "ashleigh "]); //////////////////////////////////////////////////////////////////////////////// /* @@ -32,15 +27,13 @@ Complete the function to check if the variable `num` satisfies the following req Tip: use logical operators */ - function validate(num) { if (typeof num === "number" && num %2 === 0 && num <= 100 ){ - return `${num} is a number, is even, and is less than or equal to 100.` + return true; } else { - return `${num} does not satisfy the requirements.` + return false; } } -console.log (validate(32)); /////////////////////////////////////////////////////////////////////////////// @@ -52,11 +45,9 @@ The function must: - remove the item at the specified index */ - function remove(arr, index) { return arr.slice(index, ); // complete this statement } -console.log(remove(["ekip","nouri", "osagie"], 1)); ///////////////////////////////////////////////////////////////////////////////// /* Write a function that: @@ -67,7 +58,17 @@ Write a function that: */ function formatPercentage(arr) { - + + for (let i =0; i < arr.length; i++ ){ + + if (arr[i] > 100){ + arr[i]= 100; + }else{ + arr[i] = Math.round(arr[i]*100)/100; + } + arr[i] += "%"; + } + return arr; } //////////////////////////////////////////////////////////////////////////////////// diff --git a/week-2/2-mandatory/3-playing-computer.js b/week-2/2-mandatory/3-playing-computer.js index 0fa7c04..da29f49 100644 --- a/week-2/2-mandatory/3-playing-computer.js +++ b/week-2/2-mandatory/3-playing-computer.js @@ -7,12 +7,21 @@ Answer the following questions: 1. This program throws an error. Why? (If you can't find it, try executing it). + A: We do not need to assign variable b and assign value initially. + 2. Remove the line that throws the error. + A: //console.log(b); + 3. What is printed to the console? + A: 2,6,4,9,6,13,8 4. How many times is "f1" called? + A: 5. How many times is "f2" called? + A: 6. What value does the "a" parameter take in the first "f1" call? + A: 7. What is the value of the "a" outer variable when "f1" is called for the first time? + A: */ let x = 2; @@ -28,9 +37,9 @@ const f2 = function(a, b) { console.log(x); console.log(a); -console.log(b); +//console.log(b); -for (let i = 0; i < 5; ++i) { +for (let i = 0; i < 5; i++) { a = a + 1; if (i % 2 === 0) { const d = f2(i, x); @@ -39,4 +48,5 @@ for (let i = 0; i < 5; ++i) { const e = f1(i, a); console.log(e); } + } From 7a7aced5590958bd5d33a2609fc5c7c13303ef9f Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Mon, 22 Jun 2020 22:55:06 +0100 Subject: [PATCH 23/73] wee-1 and wee-2 exercises revised --- week-1/1-exercises/F-strings-methods/exercise2.js | 3 +-- week-2/1-exercises/I-array-properties/exercise.js | 3 +-- week-2/1-exercises/J-array-get-set/exercises2.js | 1 + week-2/2-mandatory/3-playing-computer.js | 10 +++++----- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/week-1/1-exercises/F-strings-methods/exercise2.js b/week-1/1-exercises/F-strings-methods/exercise2.js index ff67013..d846326 100644 --- a/week-1/1-exercises/F-strings-methods/exercise2.js +++ b/week-1/1-exercises/F-strings-methods/exercise2.js @@ -2,7 +2,6 @@ let myName= " Ekip "; let whiteSpaceDelated= myName.trim(); console.log(whiteSpaceDelated); let lengthOfName= myName.length; -let msg= ` My name is ${myName} and my name is ${lengthOfName} characters long. `; - +let msg= `My name is ${whiteSpaceDelated} and my name is ${lengthOfName} characters long.`; console.log(msg.trim()); diff --git a/week-2/1-exercises/I-array-properties/exercise.js b/week-2/1-exercises/I-array-properties/exercise.js index ec55e8a..39ecbe9 100644 --- a/week-2/1-exercises/I-array-properties/exercise.js +++ b/week-2/1-exercises/I-array-properties/exercise.js @@ -6,9 +6,8 @@ */ function isEmpty(arr) { - return arr; // complete this statement + return arr.length; // complete this statement } -isEmpty(); /* DO NOT EDIT BELOW THIS LINE diff --git a/week-2/1-exercises/J-array-get-set/exercises2.js b/week-2/1-exercises/J-array-get-set/exercises2.js index cbb60c1..10b284e 100644 --- a/week-2/1-exercises/J-array-get-set/exercises2.js +++ b/week-2/1-exercises/J-array-get-set/exercises2.js @@ -8,6 +8,7 @@ var numbers = [1, 2, 3]; // Don't change this array literal declaration numbers.push(4); +numbers[0]=1; /* DO NOT EDIT BELOW THIS LINE diff --git a/week-2/2-mandatory/3-playing-computer.js b/week-2/2-mandatory/3-playing-computer.js index da29f49..fb5f4a4 100644 --- a/week-2/2-mandatory/3-playing-computer.js +++ b/week-2/2-mandatory/3-playing-computer.js @@ -15,13 +15,13 @@ 3. What is printed to the console? A: 2,6,4,9,6,13,8 4. How many times is "f1" called? - A: + A: 2 times 5. How many times is "f2" called? - A: + A: 3 times 6. What value does the "a" parameter take in the first "f1" call? - A: + A: 7 7. What is the value of the "a" outer variable when "f1" is called for the first time? - A: + A: 7 */ let x = 2; @@ -39,7 +39,7 @@ console.log(x); console.log(a); //console.log(b); -for (let i = 0; i < 5; i++) { +for (let i = 0; i < 5; ++i) { a = a + 1; if (i % 2 === 0) { const d = f2(i, x); From e78e0608d83fe1c979ae0772e6be102a7185fafe Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Mon, 22 Jun 2020 23:43:30 +0100 Subject: [PATCH 24/73] Update 4-sorting-algorithm.js 4-sorting-algorithm is revised --- week-2/2-mandatory/4-sorting-algorithm.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/week-2/2-mandatory/4-sorting-algorithm.js b/week-2/2-mandatory/4-sorting-algorithm.js index 3603942..54fa4ef 100644 --- a/week-2/2-mandatory/4-sorting-algorithm.js +++ b/week-2/2-mandatory/4-sorting-algorithm.js @@ -14,7 +14,10 @@ You don't have to worry about making this algorithm work fast! The idea is to ge "think" like a computer and practice your knowledge of basic JavaScript. */ -function sortAges(arr) {} +function sortAges(arr) { + + +} /* ======= TESTS - DO NOT MODIFY ===== */ From ebec3a50a9677b611a9284f581510c1367fb64ac Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 23 Jun 2020 17:03:49 +0100 Subject: [PATCH 25/73] 3-playing-computer is done --- week-2/2-mandatory/2-function-creation.js | 2 +- week-2/2-mandatory/3-playing-computer.js | 2 +- week-2/2-mandatory/4-sorting-algorithm.js | 27 ++++++++++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/week-2/2-mandatory/2-function-creation.js b/week-2/2-mandatory/2-function-creation.js index dab1aec..261b3d3 100644 --- a/week-2/2-mandatory/2-function-creation.js +++ b/week-2/2-mandatory/2-function-creation.js @@ -46,7 +46,7 @@ The function must: */ function remove(arr, index) { - return arr.slice(index, ); // complete this statement + return arr.slice(0, index).concat(arr.slice(index+1,arr.length)); // complete this statement } ///////////////////////////////////////////////////////////////////////////////// /* diff --git a/week-2/2-mandatory/3-playing-computer.js b/week-2/2-mandatory/3-playing-computer.js index fb5f4a4..f60f052 100644 --- a/week-2/2-mandatory/3-playing-computer.js +++ b/week-2/2-mandatory/3-playing-computer.js @@ -37,7 +37,7 @@ const f2 = function(a, b) { console.log(x); console.log(a); -//console.log(b); +console.log(b); for (let i = 0; i < 5; ++i) { a = a + 1; diff --git a/week-2/2-mandatory/4-sorting-algorithm.js b/week-2/2-mandatory/4-sorting-algorithm.js index 54fa4ef..a3e24c8 100644 --- a/week-2/2-mandatory/4-sorting-algorithm.js +++ b/week-2/2-mandatory/4-sorting-algorithm.js @@ -16,8 +16,33 @@ You don't have to worry about making this algorithm work fast! The idea is to ge function sortAges(arr) { - +let sortingArray=[]; +let maximum; + + for ( let i = 0; i< arr.length; i++){ + + if (typeof arr[i]!== "number"){ + + arr.splice(i, 1); + + } else if (arr[i] === "number"){ + + if (arr[i] > maximum [i]){ + sortingArray = sortingArray.push(arr[i]); + } else { + sortingArray = sortingArray.push(maximum[i]); + } + } + } + return sortingArray; } +console.log(sortAges()); +/* + +let numbers = [1, 2, 3]; +let numbersDoubled = numbers.map((number) => number * 2); + +*/ /* ======= TESTS - DO NOT MODIFY ===== */ From 5fa1a98ab187f0140ee3331af2635668f4313a3f Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 23 Jun 2020 19:02:37 +0100 Subject: [PATCH 26/73] 4-sorting-algorithm.js is done. --- week-2/2-mandatory/2-function-creation.js | 2 +- week-2/2-mandatory/3-playing-computer.js | 2 +- week-2/2-mandatory/4-sorting-algorithm.js | 57 ++++++++++++++++------- 3 files changed, 42 insertions(+), 19 deletions(-) diff --git a/week-2/2-mandatory/2-function-creation.js b/week-2/2-mandatory/2-function-creation.js index 261b3d3..78e4fe1 100644 --- a/week-2/2-mandatory/2-function-creation.js +++ b/week-2/2-mandatory/2-function-creation.js @@ -46,7 +46,7 @@ The function must: */ function remove(arr, index) { - return arr.slice(0, index).concat(arr.slice(index+1,arr.length)); // complete this statement + return arr.slice(0, index).concat(arr.slice(index+1, arr.length)); // complete this statement } ///////////////////////////////////////////////////////////////////////////////// /* diff --git a/week-2/2-mandatory/3-playing-computer.js b/week-2/2-mandatory/3-playing-computer.js index f60f052..b93643f 100644 --- a/week-2/2-mandatory/3-playing-computer.js +++ b/week-2/2-mandatory/3-playing-computer.js @@ -37,7 +37,7 @@ const f2 = function(a, b) { console.log(x); console.log(a); -console.log(b); +// console.log(b); for (let i = 0; i < 5; ++i) { a = a + 1; diff --git a/week-2/2-mandatory/4-sorting-algorithm.js b/week-2/2-mandatory/4-sorting-algorithm.js index a3e24c8..3dcc06f 100644 --- a/week-2/2-mandatory/4-sorting-algorithm.js +++ b/week-2/2-mandatory/4-sorting-algorithm.js @@ -14,29 +14,52 @@ You don't have to worry about making this algorithm work fast! The idea is to ge "think" like a computer and practice your knowledge of basic JavaScript. */ +/* function sortAges(arr) { + let maximum = 0; + for (let i = 0; i < arr.length; i++) { + for (let i = 0; i < arr.length; i++) { + if (typeof arr[i] !== "number") { + arr.splice(i, 1); i--; + } + if (arr[i] > arr[i + 1]) { + let tmp = arr[i]; + arr[i] = arr[i + 1]; + arr[i + 1] = tmp; + } + } + } + console.log(arr); + return arr; +} +console.log(sortAges()); -let sortingArray=[]; -let maximum; +*/ - for ( let i = 0; i< arr.length; i++){ +function sortAges(arr) { + let done = false; + while (!done) { + done = true; + for (let i = 0; i < arr.length; i++) { + if (typeof arr[i] !== "number") { + //removes one element from the index i and + // to check the next number, decreases the index -- + arr.splice(i, 1); i--; + } + if (arr[i] > arr[i + 1]) { + done = false; + let tmp = arr[i]; + arr[i] = arr[i + 1]; + arr[i + 1] = tmp; + } + } + } + console.log(arr); + return arr; +} - if (typeof arr[i]!== "number"){ - arr.splice(i, 1); - - } else if (arr[i] === "number"){ - if (arr[i] > maximum [i]){ - sortingArray = sortingArray.push(arr[i]); - } else { - sortingArray = sortingArray.push(maximum[i]); - } - } - } - return sortingArray; -} -console.log(sortAges()); /* let numbers = [1, 2, 3]; From 50df84bfb16bcf7d44db341ca54793baaef417b0 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 23 Jun 2020 23:06:33 +0100 Subject: [PATCH 27/73] Update 1-radio-stations.js 1-radio-stations.js first part done --- week-2/3-extra/1-radio-stations.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/week-2/3-extra/1-radio-stations.js b/week-2/3-extra/1-radio-stations.js index 95c0e56..038d736 100644 --- a/week-2/3-extra/1-radio-stations.js +++ b/week-2/3-extra/1-radio-stations.js @@ -14,6 +14,16 @@ */ // `getAllFrequencies` goes here + function getAllFrequencies (){ + let allFrequencies=[]; + for (let i = 87; i < 108; i++){ + allFrequencies[i]= allFrequencies[i+1]; + //console.log(allFrequencies[i]); + return allFrequencies[i]; + } + + } + getAllFrequencies (); /** * Next, let's write a function that gives us only the frequencies that are radio stations. From 00d2d389e090dce22e82166e9585755f1b30835b Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Wed, 24 Jun 2020 01:21:29 +0100 Subject: [PATCH 28/73] 1-fix-functions.js is revised --- week-2/2-mandatory/1-fix-functions.js | 11 +++++------ week-2/3-extra/1-radio-stations.js | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/week-2/2-mandatory/1-fix-functions.js b/week-2/2-mandatory/1-fix-functions.js index 689e28b..a93bb7a 100644 --- a/week-2/2-mandatory/1-fix-functions.js +++ b/week-2/2-mandatory/1-fix-functions.js @@ -3,9 +3,9 @@ function mood() { - let isHappy = false; + let isHappy = true; - if (isHappy) { + if (isHappy === true ) { return "I am happy"; } else { return "I am not happy"; @@ -14,11 +14,10 @@ function mood() { /////////////////////////////////////////////////// -function greaterThan10() { - let num = 10; - let isBigEnough= true; +function greaterThan10(num) { + let isBigEnough=10; - if (isBigEnough) { + if (isBigEnough < num) { return "num is greater than 10"; } else { return "num is not big enough"; diff --git a/week-2/3-extra/1-radio-stations.js b/week-2/3-extra/1-radio-stations.js index 038d736..8fbe3a7 100644 --- a/week-2/3-extra/1-radio-stations.js +++ b/week-2/3-extra/1-radio-stations.js @@ -21,7 +21,7 @@ //console.log(allFrequencies[i]); return allFrequencies[i]; } - + } getAllFrequencies (); From b6136a1bb77a228929b77cfe1113c87b7330809b Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Wed, 24 Jun 2020 14:25:37 +0100 Subject: [PATCH 29/73] Update 1-fix-functions.js 1-fix-functions.js is revised --- week-2/2-mandatory/1-fix-functions.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/week-2/2-mandatory/1-fix-functions.js b/week-2/2-mandatory/1-fix-functions.js index a93bb7a..932c7c3 100644 --- a/week-2/2-mandatory/1-fix-functions.js +++ b/week-2/2-mandatory/1-fix-functions.js @@ -3,12 +3,13 @@ function mood() { - let isHappy = true; + let isHappy = false; - if (isHappy === true ) { - return "I am happy"; - } else { + if (isHappy) { return "I am not happy"; + } + else { + return "I am happy"; } } From 35b896ba32649d30c262fdb137e4ac921ef8e59e Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Wed, 24 Jun 2020 14:25:52 +0100 Subject: [PATCH 30/73] Update 1-radio-stations.js 1-radio-stations is revised --- week-2/3-extra/1-radio-stations.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/week-2/3-extra/1-radio-stations.js b/week-2/3-extra/1-radio-stations.js index 8fbe3a7..d320518 100644 --- a/week-2/3-extra/1-radio-stations.js +++ b/week-2/3-extra/1-radio-stations.js @@ -36,6 +36,12 @@ */ // `getStations` goes here +function getStations (){ + let isRadioFrequency; + + +} + /* ======= TESTS - DO NOT MODIFY ======= */ From 0159a37d262475ab156e7010ada37e38e42cadf6 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Wed, 24 Jun 2020 16:16:35 +0100 Subject: [PATCH 31/73] 1-radio algorithm is modified --- week-2/3-extra/1-radio-stations.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/week-2/3-extra/1-radio-stations.js b/week-2/3-extra/1-radio-stations.js index d320518..20e5fc7 100644 --- a/week-2/3-extra/1-radio-stations.js +++ b/week-2/3-extra/1-radio-stations.js @@ -16,12 +16,10 @@ // `getAllFrequencies` goes here function getAllFrequencies (){ let allFrequencies=[]; - for (let i = 87; i < 108; i++){ - allFrequencies[i]= allFrequencies[i+1]; - //console.log(allFrequencies[i]); - return allFrequencies[i]; + for (let i = 87; i < 109; i++){ + allFrequencies.push(i); } - + return allFrequencies; } getAllFrequencies (); @@ -36,11 +34,24 @@ */ // `getStations` goes here -function getStations (){ - let isRadioFrequency; - - +function getStations(f) { + let resultArr=[]; + //let arr=f; + function isRadioFrequency (f){ + if (f < 108 && f > 87){ + return true; + } + return false; + } + for (let i=0; i< f.length; i++){ + if (isRadioFrequency(f[i])){ + resultArr.push(f[i]); + } + } + return resultArr; } +// getStations (getAllFrequencies()); +getStations (getAllFrequencies ()); /* ======= TESTS - DO NOT MODIFY ======= */ From 81df60e3b84808778d6e307fc2ded00041e318e4 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Thu, 25 Jun 2020 00:03:07 +0100 Subject: [PATCH 32/73] 1-radio-stations.js is done. --- week-2/2-mandatory/1-fix-functions.js | 8 ++++---- week-2/3-extra/1-radio-stations.js | 24 +++++++++++++----------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/week-2/2-mandatory/1-fix-functions.js b/week-2/2-mandatory/1-fix-functions.js index 932c7c3..1a537d5 100644 --- a/week-2/2-mandatory/1-fix-functions.js +++ b/week-2/2-mandatory/1-fix-functions.js @@ -3,13 +3,13 @@ function mood() { - let isHappy = false; + let isHappy = true; - if (isHappy) { - return "I am not happy"; + if (isHappy && true) { + return "I am happy" ; } else { - return "I am happy"; + return "I am not happy"; } } diff --git a/week-2/3-extra/1-radio-stations.js b/week-2/3-extra/1-radio-stations.js index 20e5fc7..55bc6b1 100644 --- a/week-2/3-extra/1-radio-stations.js +++ b/week-2/3-extra/1-radio-stations.js @@ -16,6 +16,7 @@ // `getAllFrequencies` goes here function getAllFrequencies (){ let allFrequencies=[]; + for (let i = 87; i < 109; i++){ allFrequencies.push(i); } @@ -34,24 +35,25 @@ */ // `getStations` goes here -function getStations(f) { +function getStations() { + let channelFrequencies = getAllFrequencies (); let resultArr=[]; - //let arr=f; - function isRadioFrequency (f){ - if (f < 108 && f > 87){ - return true; - } - return false; + + function isRadioStation (frequency){ + return channelFrequencies.includes(frequency); } - for (let i=0; i< f.length; i++){ - if (isRadioFrequency(f[i])){ - resultArr.push(f[i]); + + let a = getAvailableStations (); + + for (let i = 0; i < a.length; i ++){ + if (isRadioStation(a[i])){ + resultArr.push(a[i]); } } return resultArr; } // getStations (getAllFrequencies()); -getStations (getAllFrequencies ()); +getStations (); /* ======= TESTS - DO NOT MODIFY ======= */ From 45d23e5699dfda89063342fb1ffbd44c0a74104c Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Thu, 25 Jun 2020 00:13:13 +0100 Subject: [PATCH 33/73] Update 4-sorting-algorithm.js 4-sorting-algorithm.js is modified --- week-2/2-mandatory/4-sorting-algorithm.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/week-2/2-mandatory/4-sorting-algorithm.js b/week-2/2-mandatory/4-sorting-algorithm.js index 3dcc06f..88e7a0c 100644 --- a/week-2/2-mandatory/4-sorting-algorithm.js +++ b/week-2/2-mandatory/4-sorting-algorithm.js @@ -14,7 +14,7 @@ You don't have to worry about making this algorithm work fast! The idea is to ge "think" like a computer and practice your knowledge of basic JavaScript. */ -/* +/* function sortAges(arr) { let maximum = 0; for (let i = 0; i < arr.length; i++) { @@ -59,7 +59,6 @@ function sortAges(arr) { } - /* let numbers = [1, 2, 3]; From a1a515656caaa9cc983307b8560ee3feaf572965 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Thu, 25 Jun 2020 13:28:09 +0100 Subject: [PATCH 34/73] 4-sorting-algorithm more solution added --- week-2/2-mandatory/4-sorting-algorithm.js | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/week-2/2-mandatory/4-sorting-algorithm.js b/week-2/2-mandatory/4-sorting-algorithm.js index 88e7a0c..de57d3c 100644 --- a/week-2/2-mandatory/4-sorting-algorithm.js +++ b/week-2/2-mandatory/4-sorting-algorithm.js @@ -58,6 +58,36 @@ function sortAges(arr) { return arr; } +/* +function sortAges(arr) { + let newArray=[]; + let new_Array=[]; + let index; + for(let i=0;i 7 && name.charAt(0) === "A"; + } + + let longNameThatStartsWithA = names.find (findTheNames); +//var longNameThatStartsWithA = findLongNameThatStartsWithA(names[i]){ + // return names[i].length > 7 && names[i].charAt(0) === "A"; +//} console.log(longNameThatStartsWithA); From 326420f8239d5d254e95e222cd8a6275ead4f8ff Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 12:27:24 +0100 Subject: [PATCH 36/73] Update exercise.js the name of the array is , so should be corrected as --- week-3/1-exercises/A-array-find/exercise.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/week-3/1-exercises/A-array-find/exercise.js b/week-3/1-exercises/A-array-find/exercise.js index 57915a0..99d9532 100644 --- a/week-3/1-exercises/A-array-find/exercise.js +++ b/week-3/1-exercises/A-array-find/exercise.js @@ -13,8 +13,8 @@ var names = ["Rakesh", "Antonio", "Alexandra", "Andronicus", "Annam", "Mikey", " } let longNameThatStartsWithA = names.find (findTheNames); -//var longNameThatStartsWithA = findLongNameThatStartsWithA(names[i]){ - // return names[i].length > 7 && names[i].charAt(0) === "A"; +//var longNameThatStartsWithA = findLongNameThatStartsWithA(names){ + // return names.length > 7 && names.charAt(0) === "A"; //} console.log(longNameThatStartsWithA); From 2ddf177e3dbda4600aa81b6563a28234c3f0da77 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 12:28:58 +0100 Subject: [PATCH 37/73] Update exercise.js b-array-some is modified --- week-3/1-exercises/B-array-some/exercise.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/week-3/1-exercises/B-array-some/exercise.js b/week-3/1-exercises/B-array-some/exercise.js index 965c052..6a4e932 100644 --- a/week-3/1-exercises/B-array-some/exercise.js +++ b/week-3/1-exercises/B-array-some/exercise.js @@ -15,6 +15,12 @@ var pairsByIndex = [[0, 3], [1, 2], [2, 1], null, [3, 0]]; var students = ["Islam", "Lesley", "Harun", "Rukmini"]; var mentors = ["Daniel", "Irina", "Mozafar", "Luke"]; +function checkTheIndexForNull (index){ + return index==="null"; +} +var exitProgram= pairsByIndex.some(checkTheIndexForNull); +process.exit(1); + var pairs = pairsByIndex.map(function(indexes) { var student = students[indexes[0]]; var mentor = mentors[indexes[1]]; From 7a6575d0770683522564b28bd3a0bcfe1bf8b4e0 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 12:29:37 +0100 Subject: [PATCH 38/73] Update README.md the name of the array at line 24 should be in stead of --- week-3/1-exercises/B-array-some/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-3/1-exercises/B-array-some/README.md b/week-3/1-exercises/B-array-some/README.md index ecfcac4..e7e0962 100644 --- a/week-3/1-exercises/B-array-some/README.md +++ b/week-3/1-exercises/B-array-some/README.md @@ -21,7 +21,7 @@ To check your array of numbers, you'd have to run this function against every nu _Searches through an array and returns true if at least one array item satisifies the predicate function you provided._ ```js -var containsNegative = ages.some(isNegative); +var containsNegative = numbers.some(isNegative); console.log(containsNegative); // logs true ``` From bb70df3d496077156dc3591b623109d46c43a025 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 12:39:02 +0100 Subject: [PATCH 39/73] Update exercise.js a-array-some is modified. --- week-3/1-exercises/B-array-some/exercise.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/week-3/1-exercises/B-array-some/exercise.js b/week-3/1-exercises/B-array-some/exercise.js index 6a4e932..16b36e6 100644 --- a/week-3/1-exercises/B-array-some/exercise.js +++ b/week-3/1-exercises/B-array-some/exercise.js @@ -16,9 +16,10 @@ var students = ["Islam", "Lesley", "Harun", "Rukmini"]; var mentors = ["Daniel", "Irina", "Mozafar", "Luke"]; function checkTheIndexForNull (index){ - return index==="null"; + return index === "null"; } var exitProgram= pairsByIndex.some(checkTheIndexForNull); +//https://nodejs.org/api/process.html#process_process_exit_code process.exit(1); var pairs = pairsByIndex.map(function(indexes) { From ede70ed4e75bb538d4533c2bed861c8af3fbd79a Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 12:44:59 +0100 Subject: [PATCH 40/73] Update exercise.js a-array-some is modiefied --- week-3/1-exercises/B-array-some/exercise.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/week-3/1-exercises/B-array-some/exercise.js b/week-3/1-exercises/B-array-some/exercise.js index 16b36e6..fff9280 100644 --- a/week-3/1-exercises/B-array-some/exercise.js +++ b/week-3/1-exercises/B-array-some/exercise.js @@ -16,9 +16,10 @@ var students = ["Islam", "Lesley", "Harun", "Rukmini"]; var mentors = ["Daniel", "Irina", "Mozafar", "Luke"]; function checkTheIndexForNull (index){ - return index === "null"; + return index === null; } -var exitProgram= pairsByIndex.some(checkTheIndexForNull); +var exitProgram = pairsByIndex.some(checkTheIndexForNull); +console.log(exitProgram); //https://nodejs.org/api/process.html#process_process_exit_code process.exit(1); From 7ab8307b0122a9efd0ba5fcc7d76cec1c5541cf1 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 14:36:58 +0100 Subject: [PATCH 41/73] Update exercise.js c-array-every is modified --- week-3/1-exercises/C-array-every/exercise.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/week-3/1-exercises/C-array-every/exercise.js b/week-3/1-exercises/C-array-every/exercise.js index b515e94..510619d 100644 --- a/week-3/1-exercises/C-array-every/exercise.js +++ b/week-3/1-exercises/C-array-every/exercise.js @@ -7,6 +7,13 @@ var group = ["Austine", "Dany", "Swathi", "Daniel"]; var groupIsOnlyStudents; // complete this statement +/// +//function groupIsOnlyStudents (name){ + //return group[i] === students[i]; +//} +//let checkNames= group.every(groupIsOnlyStudents); +////// + if (groupIsOnlyStudents) { console.log("The group contains only students"); } else { From 89f6146e3106b0803e5c70afcabf7ae76f90da05 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 14:37:14 +0100 Subject: [PATCH 42/73] Update exercise.js d-array-filter is modified --- week-3/1-exercises/D-array-filter/exercise.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/week-3/1-exercises/D-array-filter/exercise.js b/week-3/1-exercises/D-array-filter/exercise.js index 6e32cc6..c89c087 100644 --- a/week-3/1-exercises/D-array-filter/exercise.js +++ b/week-3/1-exercises/D-array-filter/exercise.js @@ -8,7 +8,11 @@ var pairsByIndexRaw = [[0, 3], [1, 2], [2, 1], null, [1], false, "whoops"]; -var pairsByIndex; // Complete this statement +var pairsByIndex = pairsByIndexRaw.filter(filterOut); ; // Complete this statement + +function filterOut(index){ + return index[number, number] !== [number, number]; +} var students = ["Islam", "Lesley", "Harun", "Rukmini"]; var mentors = ["Daniel", "Irina", "Mozafar", "Luke"]; From 48e6fdf224964c2c99450a98691474a9fbb673bc Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 14:37:31 +0100 Subject: [PATCH 43/73] Update exercise.js e-array-map is done --- week-3/1-exercises/E-array-map/exercise.js | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/week-3/1-exercises/E-array-map/exercise.js b/week-3/1-exercises/E-array-map/exercise.js index 2835e92..3b247b1 100644 --- a/week-3/1-exercises/E-array-map/exercise.js +++ b/week-3/1-exercises/E-array-map/exercise.js @@ -3,3 +3,31 @@ var numbers = [0.1, 0.2, 0.3, 0.4, 0.5]; +function multipleWith100 (number){ + return number *100; +} + +var multiple100NewArray= numbers.map(multipleWith100); +/*01 +var multiple100NewArray =numbers.map(function multipleWith100 (number){ + return number * 100; +}); +*/ + +/*02 +var multiple100NewArray =numbers.map(function (number){ + return number * 100; +}); +*/ + +/*03 +var multiple100NewArray =numbers.map( number => { + return number * 100; +}); +*/ + +/*04 +var multiple100NewArray =numbers.map(number => number * 100); +*/ + +console.log (multiple100NewArray); \ No newline at end of file From 9540ca770fb8525b48bef5ad705a5e41cf80d3da Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 15:08:17 +0100 Subject: [PATCH 44/73] f-array-forEach is done --- week-3/1-exercises/F-array-forEach/exercise.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/week-3/1-exercises/F-array-forEach/exercise.js b/week-3/1-exercises/F-array-forEach/exercise.js index e83e2df..7624b7c 100644 --- a/week-3/1-exercises/F-array-forEach/exercise.js +++ b/week-3/1-exercises/F-array-forEach/exercise.js @@ -9,6 +9,22 @@ var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; +function sorting3And5Remainer (number){ + if (number%3 === 0 ){ + return "Fizz"; + } if (number%5 === 0){ + return "Buzz"; + } if (number%3 === 0 && number%5 === 0){ + return "FizzBuzz"; + } else{ + return number; + } +} + +let sortedRemainer = arr.map(sorting3And5Remainer); + +console.log (sortedRemainer); + /* EXPECTED OUTPUT */ /* From 6755d8b8ea83c9dad692dc4142752756f4f6ee04 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 15:27:36 +0100 Subject: [PATCH 45/73] Update exercise.js F-array-forEach is done. --- week-3/1-exercises/F-array-forEach/exercise.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/week-3/1-exercises/F-array-forEach/exercise.js b/week-3/1-exercises/F-array-forEach/exercise.js index 7624b7c..95967ed 100644 --- a/week-3/1-exercises/F-array-forEach/exercise.js +++ b/week-3/1-exercises/F-array-forEach/exercise.js @@ -21,9 +21,15 @@ function sorting3And5Remainer (number){ } } -let sortedRemainer = arr.map(sorting3And5Remainer); +function log(number){ + console.log (number); +} + +//let sortedRemainer = + +arr.map(sorting3And5Remainer).forEach(log); -console.log (sortedRemainer); +//console.log (sortedRemainer); /* EXPECTED OUTPUT */ From 22a840896b6b09018a554c33189a5a3f7ec5a7f9 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 15:27:57 +0100 Subject: [PATCH 46/73] Update exercise.js G-array-methods is done --- week-3/1-exercises/G-array-methods/exercise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-3/1-exercises/G-array-methods/exercise.js b/week-3/1-exercises/G-array-methods/exercise.js index 44e9c80..5dc3c88 100644 --- a/week-3/1-exercises/G-array-methods/exercise.js +++ b/week-3/1-exercises/G-array-methods/exercise.js @@ -4,7 +4,7 @@ */ var numbers = [3, 2, 1]; -var sortedNumbers; // complete this statement +var sortedNumbers=numbers.sort(); // complete this statement /* DO NOT EDIT BELOW THIS LINE From 0c78bbfbe9f522f602551518e81594f73eb00183 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 15:34:09 +0100 Subject: [PATCH 47/73] G-array-methods second part is done --- week-3/1-exercises/G-array-methods/exercise2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-3/1-exercises/G-array-methods/exercise2.js b/week-3/1-exercises/G-array-methods/exercise2.js index 3dd24a1..3b401c7 100644 --- a/week-3/1-exercises/G-array-methods/exercise2.js +++ b/week-3/1-exercises/G-array-methods/exercise2.js @@ -7,7 +7,7 @@ var mentors = ["Daniel", "Irina", "Rares"]; var students = ["Rukmini", "Abdul", "Austine", "Swathi"]; -var everyone; // complete this statement +var everyone= mentors.concat(students); // complete this statement /* DO NOT EDIT BELOW THIS LINE From ff172d6487c1a70bcab9628289313f1ad2879c99 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 15:44:32 +0100 Subject: [PATCH 48/73] Update exercise.js there is a typo on line 30 --- week-3/1-exercises/H-array-methods-2/exercise.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/week-3/1-exercises/H-array-methods-2/exercise.js b/week-3/1-exercises/H-array-methods-2/exercise.js index d36303b..ec3babc 100644 --- a/week-3/1-exercises/H-array-methods-2/exercise.js +++ b/week-3/1-exercises/H-array-methods-2/exercise.js @@ -15,8 +15,8 @@ var everyone = [ "Swathi" ]; -var firstFive; // complete this statement -var lastFive; // complete this statement +var firstFive =everyone.slice(0, 5) ; // complete this statement +var lastFive = everyone.slice(2); // complete this statement /* DO NOT EDIT BELOW THIS LINE From 56602895dbe0248ace5aa55fa7959a94a80f1e06 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 15:45:09 +0100 Subject: [PATCH 49/73] Update README.md there is a typo on line 30 --- week-3/1-exercises/H-array-methods-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-3/1-exercises/H-array-methods-2/README.md b/week-3/1-exercises/H-array-methods-2/README.md index 507de31..00d4451 100644 --- a/week-3/1-exercises/H-array-methods-2/README.md +++ b/week-3/1-exercises/H-array-methods-2/README.md @@ -27,7 +27,7 @@ function isAMentor(name) { return mentors.includes(name); } -consooe.log("Is Rukmuni a mentor?"); +console.log("Is Rukmuni a mentor?"); console.log(isAMentor("Rukmini")); // logs false ``` From 7c3869633ecd721e2afafd99bf3fccff333c7bb0 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 17:08:01 +0100 Subject: [PATCH 50/73] Update exercise3.js H-array-methods-2 exersice.3 is done --- week-3/1-exercises/H-array-methods-2/exercise3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-3/1-exercises/H-array-methods-2/exercise3.js b/week-3/1-exercises/H-array-methods-2/exercise3.js index 82e9dd8..75a6b76 100644 --- a/week-3/1-exercises/H-array-methods-2/exercise3.js +++ b/week-3/1-exercises/H-array-methods-2/exercise3.js @@ -7,7 +7,7 @@ var ukNations = ["Scotland", "Wales", "England", "Northern Ireland"]; function isInUK(country) { - return; // complete this statement + return ukNations.includes(country); // complete this statement } /* From d118c9d2c11208b36e5b1306ee02368119b76b62 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 17:08:35 +0100 Subject: [PATCH 51/73] Update exercise2.js H-array-methods exercise 2 is partily done --- week-3/1-exercises/H-array-methods-2/exercise2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/week-3/1-exercises/H-array-methods-2/exercise2.js b/week-3/1-exercises/H-array-methods-2/exercise2.js index b7be576..4434556 100644 --- a/week-3/1-exercises/H-array-methods-2/exercise2.js +++ b/week-3/1-exercises/H-array-methods-2/exercise2.js @@ -7,7 +7,9 @@ Tip: use the string method .split() and the array method .join() */ -function capitalise(str) {} +function capitalise(str) { + return str.charAt(0).toUpperCase() + str.slice(1); +} /* DO NOT EDIT BELOW THIS LINE From f9979cc019027b2ccd6467668d99f2b19aa4da9e Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 17:08:57 +0100 Subject: [PATCH 52/73] Update exercise.js C-array-every is done --- week-3/1-exercises/C-array-every/exercise.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/week-3/1-exercises/C-array-every/exercise.js b/week-3/1-exercises/C-array-every/exercise.js index 510619d..619b374 100644 --- a/week-3/1-exercises/C-array-every/exercise.js +++ b/week-3/1-exercises/C-array-every/exercise.js @@ -5,14 +5,14 @@ var students = ["Omar", "Austine", "Dany", "Swathi", "Lesley", "Rukmini"]; var group = ["Austine", "Dany", "Swathi", "Daniel"]; -var groupIsOnlyStudents; // complete this statement +var groupIsOnlyStudents = group.every(studentsIncludeNames); // complete this statement + +function studentsIncludeNames (name){ + return students.includes(name) +} -/// -//function groupIsOnlyStudents (name){ - //return group[i] === students[i]; -//} //let checkNames= group.every(groupIsOnlyStudents); -////// + if (groupIsOnlyStudents) { console.log("The group contains only students"); From d27c5429e686b955a32c5efd45009ab8c9e17020 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Tue, 30 Jun 2020 17:09:17 +0100 Subject: [PATCH 53/73] Update exercise.js D-array-filter is modified --- week-3/1-exercises/D-array-filter/exercise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-3/1-exercises/D-array-filter/exercise.js b/week-3/1-exercises/D-array-filter/exercise.js index c89c087..a5ac7a2 100644 --- a/week-3/1-exercises/D-array-filter/exercise.js +++ b/week-3/1-exercises/D-array-filter/exercise.js @@ -11,7 +11,7 @@ var pairsByIndexRaw = [[0, 3], [1, 2], [2, 1], null, [1], false, "whoops"]; var pairsByIndex = pairsByIndexRaw.filter(filterOut); ; // Complete this statement function filterOut(index){ - return index[number, number] !== [number, number]; + return index[number, number] === [number, number]; } var students = ["Islam", "Lesley", "Harun", "Rukmini"]; From 1b42631188f1d142256b24f52782b7ec7fc4e36d Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Wed, 1 Jul 2020 01:05:21 +0100 Subject: [PATCH 54/73] Update 2-bush-berries.js 2-bush-berries is done --- week-3/2-mandatory/2-bush-berries.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/week-3/2-mandatory/2-bush-berries.js b/week-3/2-mandatory/2-bush-berries.js index d900323..4ec3463 100644 --- a/week-3/2-mandatory/2-bush-berries.js +++ b/week-3/2-mandatory/2-bush-berries.js @@ -9,15 +9,23 @@ Use the tests to confirm which message to return */ - -function bushChecker() { - +let bushBerryColours1 = ["pink", "pink", "pink", "neon", "pink", "transparent"]; +let bushBerryColours2 = ["pink", "pink", "pink", "pink"]; + +function bushChecker(berry) { + if (berry.some(color => color !== "pink")){ + return "Toxic! Leave bush alone!"; + } else { + return "Bush is safe to eat from"; + } } +bushChecker(bushBerryColours1); + /* ======= TESTS - DO NOT MODIFY ===== */ -let bushBerryColours1 = ["pink", "pink", "pink", "neon", "pink", "transparent"] -let bushBerryColours2 = ["pink", "pink", "pink", "pink"] +// let bushBerryColours1 = ["pink", "pink", "pink", "neon", "pink", "transparent"] +// let bushBerryColours2 = ["pink", "pink", "pink", "pink"] function test(test_name, expr) { let status; From ee2d7c64968d3aa5a2a11e357d87e36daad5b674 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Wed, 1 Jul 2020 01:25:44 +0100 Subject: [PATCH 55/73] Update 3-space-colonies.js 1-oxygen-level is partily done --- week-3/2-mandatory/3-space-colonies.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/week-3/2-mandatory/3-space-colonies.js b/week-3/2-mandatory/3-space-colonies.js index f99891a..1120f99 100644 --- a/week-3/2-mandatory/3-space-colonies.js +++ b/week-3/2-mandatory/3-space-colonies.js @@ -8,6 +8,8 @@ NOTE: don't include any element that is not a "family". */ + + function colonisers() { } From 3bd33a3c018e2209c11ab8218e7ac5a348ded2f9 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Wed, 1 Jul 2020 01:26:06 +0100 Subject: [PATCH 56/73] Update 1-oxygen-levels.js 1-oxygen-levels is partially done --- week-3/2-mandatory/1-oxygen-levels.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/week-3/2-mandatory/1-oxygen-levels.js b/week-3/2-mandatory/1-oxygen-levels.js index 3c02135..07817d2 100644 --- a/week-3/2-mandatory/1-oxygen-levels.js +++ b/week-3/2-mandatory/1-oxygen-levels.js @@ -9,14 +9,21 @@ To be safe, they need to land on the first unamed planet that has Oxygen levels Write a function that finds the oxygen level of the first safe planet - Oxygen between 19.5% and 23.5% */ -function safeLevels() { +const oxygenLevels1 = ["24.2%", "11.3%", "19.9%", "23.1%", "29.3%", "20.2%"] +const oxygenLevels2 = ["30.8%", "23.5%", "18.8%", "19.5%", "20.2%", "31.6%"] + +function safeLevels(oxygen) { + return oxygen.find(level => level > "19.5%" && level < "23.5%"); } +safeLevels(oxygenLevels1); + + /* ======= TESTS - DO NOT MODIFY ===== */ -const oxygenLevels1 = ["24.2%", "11.3%", "19.9%", "23.1%", "29.3%", "20.2%"] -const oxygenLevels2 = ["30.8%", "23.5%", "18.8%", "19.5%", "20.2%", "31.6%"] +// const oxygenLevels1 = ["24.2%", "11.3%", "19.9%", "23.1%", "29.3%", "20.2%"] +// const oxygenLevels2 = ["30.8%", "23.5%", "18.8%", "19.5%", "20.2%", "31.6%"] function test(test_name, expr) { let status; From 6715f7266ee1cafea673a321c3251ab9277214e3 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Wed, 1 Jul 2020 11:01:57 +0100 Subject: [PATCH 57/73] Update 3-space-colonies.js 3-space-colonies is modified --- week-3/2-mandatory/3-space-colonies.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/week-3/2-mandatory/3-space-colonies.js b/week-3/2-mandatory/3-space-colonies.js index 1120f99..4aa0181 100644 --- a/week-3/2-mandatory/3-space-colonies.js +++ b/week-3/2-mandatory/3-space-colonies.js @@ -10,13 +10,17 @@ -function colonisers() { - +function colonisers(item) { + let newColonisers=[]; + item.filter("family").includes("A"); + newColonisers.push(item) + return newColonisers; } +colonisers(); /* ======= TESTS - DO NOT MODIFY ===== */ -const voyagers = [ + const voyagers = [ "Adam family", "Potter family", "Eric", @@ -29,7 +33,7 @@ const voyagers = [ "Oscar family", "Avery family", "Archer family" -]; +]; function arraysEqual(a, b) { if (a === b) return true; From 63e15a57a244cb374140313c7586c33cbc6cfc03 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Wed, 1 Jul 2020 14:30:04 +0100 Subject: [PATCH 58/73] Update exercise.js D-array-filter is modified --- week-3/1-exercises/D-array-filter/exercise.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/week-3/1-exercises/D-array-filter/exercise.js b/week-3/1-exercises/D-array-filter/exercise.js index a5ac7a2..7bd21b7 100644 --- a/week-3/1-exercises/D-array-filter/exercise.js +++ b/week-3/1-exercises/D-array-filter/exercise.js @@ -11,7 +11,8 @@ var pairsByIndexRaw = [[0, 3], [1, 2], [2, 1], null, [1], false, "whoops"]; var pairsByIndex = pairsByIndexRaw.filter(filterOut); ; // Complete this statement function filterOut(index){ - return index[number, number] === [number, number]; + let i= []; + return index[i].length > 1; } var students = ["Islam", "Lesley", "Harun", "Rukmini"]; From 07c1db8ab6dbdafa9bdea04041b617f8df609301 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Wed, 1 Jul 2020 14:31:18 +0100 Subject: [PATCH 59/73] Update 3-space-colonies.js 3-space-colonies is modified --- week-3/2-mandatory/3-space-colonies.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/week-3/2-mandatory/3-space-colonies.js b/week-3/2-mandatory/3-space-colonies.js index 4aa0181..1a70a0c 100644 --- a/week-3/2-mandatory/3-space-colonies.js +++ b/week-3/2-mandatory/3-space-colonies.js @@ -7,17 +7,22 @@ NOTE: don't include any element that is not a "family". */ - - + function colonisers(item) { let newColonisers=[]; - item.filter("family").includes("A"); - newColonisers.push(item) - return newColonisers; + + if(item.includes("family")){ + newColonisers = item.filter("A"); + //console.log(newColonisers); + return newColonisers; + } else{ + return "Go in search for a new planet"; + } + //console.log(newColonisers); } -colonisers(); - +colonisers(voyagers); +console.log(colonisers); /* ======= TESTS - DO NOT MODIFY ===== */ const voyagers = [ From 2b37a11dffb8a6f09a70706c7cd7d047949d698e Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Wed, 1 Jul 2020 14:31:42 +0100 Subject: [PATCH 60/73] Update 4-eligible-students.js 4-elifible-students is modified --- week-3/2-mandatory/4-eligible-students.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/week-3/2-mandatory/4-eligible-students.js b/week-3/2-mandatory/4-eligible-students.js index 6424b01..8ada0d5 100644 --- a/week-3/2-mandatory/4-eligible-students.js +++ b/week-3/2-mandatory/4-eligible-students.js @@ -6,10 +6,23 @@ (see tests to confirm how this data will be structured) - Returns an array containing only the names of the who have attended AT LEAST 8 classes */ +/* +const attendances = [ + ["Ahmed", 8], + ["Clement", 10], + ["Elamin", 6], + ["Adam", 7], + ["Tayoa", 11], + ["Nina", 10] +] +*/ -function eligibleStudents() { +let attendOver8=[]; +function eligibleStudents(arr) { + return arr [i][i] > 8; } +console.log(eligibleStudents); /* ======= TESTS - DO NOT MODIFY ===== */ @@ -20,7 +33,7 @@ const attendances = [ ["Adam", 7], ["Tayoa", 11], ["Nina", 10] -] +] function arraysEqual(a, b) { if (a === b) return true; From f14573e0be4422d7855e3298cb91f30d0bfc4caa Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Wed, 1 Jul 2020 22:55:29 +0100 Subject: [PATCH 61/73] 5-journey-planner.js is done --- .DS_Store | Bin 6148 -> 8196 bytes week-3/.DS_Store | Bin 6148 -> 6148 bytes week-3/2-mandatory/1-oxygen-levels.js | 9 ++--- week-3/2-mandatory/2-bush-berries.js | 7 +--- week-3/2-mandatory/3-space-colonies.js | 16 ++------ week-3/2-mandatory/4-eligible-students.js | 44 ++++++++++++++-------- week-3/2-mandatory/5-journey-planner.js | 6 ++- week-3/2-mandatory/6-lane-names.js | 10 ++++- 8 files changed, 49 insertions(+), 43 deletions(-) diff --git a/.DS_Store b/.DS_Store index 8e285c4b40767ba37d79d5520f70336ce6de8608..c52aa40948ed4d97e59b561be2d7adc331255590 100644 GIT binary patch literal 8196 zcmeHM%WD%s82=`X?It4TAhaIDy@*<(WZkw1BBU`vs@N8{RPaHP?S^D=lMQ(oG)8jm z!GFNV$!m{ZJa|!0qGu8OS46*gG~L-`LrDW14C}F`yVw3@8Q^1B!vag#o;?Y0)C?eJ)k4 zVn8wQUot??2OTTLtiT~hc64CFQUJs_4zq&&6zw4D0sd*O@wyEJxKU1{4G14A9&?4i}*cE_9^)J%0U1P*(Tz zdE4`C9Mdv;Z*Sb({;(>`ovHF>E%0vObO}viZhu~=K^JUkc7VI%8o@Q}7MH&`>ue1n zKXw0LCDB^adibG}gj-O6b=ZOpxD6Jrt`5$c=kJJp)1&1I)^opD!5%;YH4Cr`d1gDo zg3O03W}yca{5*sUV94HyH%(XOr}Z9nC0{{y7T>MxvlG%e;3i5(VkWkU)5!BYvRVz# zZ&Y!d9>zicmqPpbgz~ciwj^D7KYOpkzJmMNef3@cxxu0>`H*5Ap(F1{$7$p>PuY(t z?i3?WX6pJDJQk5}S!1nVr+Lq?SCEd|=i5p4BOLy6s%Kb&r1A zEO%r_zX{vEgB_`RIpZ8&Y_$KnD_OK6E= z>SVufEN9ZXVJ;2Qdf&*HMp|E4G6#c%Hh;#rx>l+`e$szBc=m$Qfq@j)DjetEN9{}O z1sONxsJ(d}mItHu@$2PDPoWu%T9l3)HFm2@>j*_n-T$MIsg7dcPz=m)tp%F@7oy+) zAIg_fQVb{t{!Io*Ja6T5xc2=Y0pV@XTwBLl!b%I(8**eO*sydQk)`8^qdyF>ucIop W$qF2D#1Sm&MF68gHHv{h%D`{rR4lFl delta 213 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{Mvv5sJ6q~50D9Qcq3gY4Xxc!O~Qf^jLe diff --git a/week-3/.DS_Store b/week-3/.DS_Store index 7db7cc1e281647226e44b608a65874f8c62b6f04..e1e1a5e341fcc554807a6a7c659bce74f112c5be 100644 GIT binary patch literal 6148 zcmeHK&2G~`5T0#Q;v@nhRH+<&LE;dQO{&rhk{beo0|?0o4uD!aHjO3Q8`%z_gn%!+ z1H1x{05?uOaOcjGF#FTiCb6Pi5P}_P_gk-Lc4xkccd`ILdSlN7Xaj(TjbW{c-2!3n zS(}qJIdch-@HKq!VE`07L?wy=#lYXr0Q+_?fC1OwB_#OOo_)Uqa3F$Fcxc)K8jVCC z8()^`N3`E}L+YZQw)^wuckki1z2!FE$~L26(Jyv>K?_Wb!-v<{5wBe=I+ zty%Q_!Ta44-z(OQ=$Y5cwM+gIL->0G{f&_47*9+GGCVmGIC3ZHNHTcrj=~_#4C4n` zTd!@Lt7}?QYo2euu!nSFXHGUwdrtCx3{KKqobRqG3)44)99KVeP_Enn>DnpE9R~H z2hq`+>D$@6k1QN40$2sOT$FeMpK#EEh0&I?bNzF*W-&WgzZSByaNS~dmTQ-?13B}% z!rxbR5{EQCL=6^g9lG*2mtpRlay0e3^BTn{J{+G$@!L8@@2j=SUhBBoN+PqRwN|oH z%8CKS!2iGiJ0Emx3@wSdKz?*!$FBg0HJs*xV_u69bvA)$Nz4V}3QE<2rI@B5x>!?~e02R|jGVRJ~$AF;He;T|Bl~{l8Ov|1TSZl$a)dmh6)qrE1@m_6o zG0Lh7ZAV?gp>YIPT6LP`BP9R&oufH^Jgl|4$#_cMYvefNB#P`?D&5{JcJH4a>Lh=_ z>wSwi9ev&BWotHxlgW_%aOU^1ln&T8S1K>%)BA_^4tNKC(gB$t0;XVSF*T^C4ixwMJTTC6i7D$B{T1*YHh2eh$v<<%S4*aSEFOA!qIRF3v diff --git a/week-3/2-mandatory/1-oxygen-levels.js b/week-3/2-mandatory/1-oxygen-levels.js index 07817d2..79ebc01 100644 --- a/week-3/2-mandatory/1-oxygen-levels.js +++ b/week-3/2-mandatory/1-oxygen-levels.js @@ -9,21 +9,18 @@ To be safe, they need to land on the first unamed planet that has Oxygen levels Write a function that finds the oxygen level of the first safe planet - Oxygen between 19.5% and 23.5% */ -const oxygenLevels1 = ["24.2%", "11.3%", "19.9%", "23.1%", "29.3%", "20.2%"] -const oxygenLevels2 = ["30.8%", "23.5%", "18.8%", "19.5%", "20.2%", "31.6%"] - function safeLevels(oxygen) { return oxygen.find(level => level > "19.5%" && level < "23.5%"); } -safeLevels(oxygenLevels1); + /* ======= TESTS - DO NOT MODIFY ===== */ -// const oxygenLevels1 = ["24.2%", "11.3%", "19.9%", "23.1%", "29.3%", "20.2%"] -// const oxygenLevels2 = ["30.8%", "23.5%", "18.8%", "19.5%", "20.2%", "31.6%"] +const oxygenLevels1 = ["24.2%", "11.3%", "19.9%", "23.1%", "29.3%", "20.2%"] +const oxygenLevels2 = ["30.8%", "23.5%", "18.8%", "19.5%", "20.2%", "31.6%"] function test(test_name, expr) { let status; diff --git a/week-3/2-mandatory/2-bush-berries.js b/week-3/2-mandatory/2-bush-berries.js index 4ec3463..b96ae72 100644 --- a/week-3/2-mandatory/2-bush-berries.js +++ b/week-3/2-mandatory/2-bush-berries.js @@ -9,8 +9,6 @@ Use the tests to confirm which message to return */ -let bushBerryColours1 = ["pink", "pink", "pink", "neon", "pink", "transparent"]; -let bushBerryColours2 = ["pink", "pink", "pink", "pink"]; function bushChecker(berry) { if (berry.some(color => color !== "pink")){ @@ -19,13 +17,12 @@ function bushChecker(berry) { return "Bush is safe to eat from"; } } -bushChecker(bushBerryColours1); /* ======= TESTS - DO NOT MODIFY ===== */ -// let bushBerryColours1 = ["pink", "pink", "pink", "neon", "pink", "transparent"] -// let bushBerryColours2 = ["pink", "pink", "pink", "pink"] +let bushBerryColours1 = ["pink", "pink", "pink", "neon", "pink", "transparent"] +let bushBerryColours2 = ["pink", "pink", "pink", "pink"] function test(test_name, expr) { let status; diff --git a/week-3/2-mandatory/3-space-colonies.js b/week-3/2-mandatory/3-space-colonies.js index 1a70a0c..9c2892f 100644 --- a/week-3/2-mandatory/3-space-colonies.js +++ b/week-3/2-mandatory/3-space-colonies.js @@ -8,21 +8,11 @@ NOTE: don't include any element that is not a "family". */ - function colonisers(item) { - let newColonisers=[]; - - if(item.includes("family")){ - newColonisers = item.filter("A"); - //console.log(newColonisers); - return newColonisers; - } else{ - return "Go in search for a new planet"; - } - //console.log(newColonisers); + return item.filter(x => x.includes('family') && x[0] == 'A'); } -colonisers(voyagers); -console.log(colonisers); + + /* ======= TESTS - DO NOT MODIFY ===== */ const voyagers = [ diff --git a/week-3/2-mandatory/4-eligible-students.js b/week-3/2-mandatory/4-eligible-students.js index 8ada0d5..6de5ca4 100644 --- a/week-3/2-mandatory/4-eligible-students.js +++ b/week-3/2-mandatory/4-eligible-students.js @@ -6,34 +6,46 @@ (see tests to confirm how this data will be structured) - Returns an array containing only the names of the who have attended AT LEAST 8 classes */ -/* + + +// function studentsNamesWithGrades (item){ +// let arr =[]; +// arr.push(item[i][1] >= 8); +// return arr; +// } + + +// function eligibleStudents (item){ +// let namesArr=[]; +// item.map(item[i][1] => item[i]); +// } const attendances = [ ["Ahmed", 8], ["Clement", 10], ["Elamin", 6], ["Adam", 7], ["Tayoa", 11], - ["Nina", 10] -] -*/ + ["Nina", 10], +]; -let attendOver8=[]; +function eligibleStudents() { + console.log( + attendances.filter((subarray) => (subarray[1] >= 8 ? subarray[1]:'')).map(a=>a[0]) -function eligibleStudents(arr) { - return arr [i][i] > 8; + ); } -console.log(eligibleStudents); +eligibleStudents(); /* ======= TESTS - DO NOT MODIFY ===== */ -const attendances = [ - ["Ahmed", 8], - ["Clement", 10], - ["Elamin", 6], - ["Adam", 7], - ["Tayoa", 11], - ["Nina", 10] -] +// const attendances = [ +// ["Ahmed", 8], +// ["Clement", 10], +// ["Elamin", 6], +// ["Adam", 7], +// ["Tayoa", 11], +// ["Nina", 10] +// ] function arraysEqual(a, b) { if (a === b) return true; diff --git a/week-3/2-mandatory/5-journey-planner.js b/week-3/2-mandatory/5-journey-planner.js index 53499c3..0af8092 100644 --- a/week-3/2-mandatory/5-journey-planner.js +++ b/week-3/2-mandatory/5-journey-planner.js @@ -7,7 +7,11 @@ NOTE: only the names should be returned, not the means of transport. */ -function journeyPlanner() { +function journeyPlanner(item) { + let newArr=[]; + for(i = 0; i < item.length; i++){ + + } } diff --git a/week-3/2-mandatory/6-lane-names.js b/week-3/2-mandatory/6-lane-names.js index eddfe44..be9a94d 100644 --- a/week-3/2-mandatory/6-lane-names.js +++ b/week-3/2-mandatory/6-lane-names.js @@ -4,8 +4,14 @@ Write a function that will return all street names which contain 'Lane' in their name. */ -function getLanes() { - +function getLanes(item) { + let streetNamesWithLanes=[]; + if (item.includes("Lane")){ + streetNamesWithLanes.push(item); + } else{ + return "Does not include Lane"; + } + return streetNamesWithLanes; } /* ======= TESTS - DO NOT MODIFY ===== */ From 5fc425dae948f2f56bdad396aea0849be32738c4 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Thu, 2 Jul 2020 00:05:55 +0100 Subject: [PATCH 62/73] Update 4-eligible-students.js 4-eligible-studnets.js is done --- week-3/2-mandatory/4-eligible-students.js | 30 +++++++---------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/week-3/2-mandatory/4-eligible-students.js b/week-3/2-mandatory/4-eligible-students.js index 6de5ca4..5074f21 100644 --- a/week-3/2-mandatory/4-eligible-students.js +++ b/week-3/2-mandatory/4-eligible-students.js @@ -19,33 +19,21 @@ // let namesArr=[]; // item.map(item[i][1] => item[i]); // } + +function eligibleStudents(item) { + return item.filter(x => x[1] >= 8).map(x => x[0]); +} + +/* ======= TESTS - DO NOT MODIFY ===== */ + const attendances = [ ["Ahmed", 8], ["Clement", 10], ["Elamin", 6], ["Adam", 7], ["Tayoa", 11], - ["Nina", 10], -]; - -function eligibleStudents() { - console.log( - attendances.filter((subarray) => (subarray[1] >= 8 ? subarray[1]:'')).map(a=>a[0]) - - ); -} -eligibleStudents(); - -/* ======= TESTS - DO NOT MODIFY ===== */ - -// const attendances = [ -// ["Ahmed", 8], -// ["Clement", 10], -// ["Elamin", 6], -// ["Adam", 7], -// ["Tayoa", 11], -// ["Nina", 10] -// ] + ["Nina", 10] + ] function arraysEqual(a, b) { if (a === b) return true; From 97ee7729712dd8dcaeb4578d64e9dd0ba2bb864a Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Thu, 2 Jul 2020 00:09:22 +0100 Subject: [PATCH 63/73] Update 5-journey-planner.js 5-journey-planner.js is done --- week-3/2-mandatory/5-journey-planner.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/week-3/2-mandatory/5-journey-planner.js b/week-3/2-mandatory/5-journey-planner.js index 0af8092..44c623f 100644 --- a/week-3/2-mandatory/5-journey-planner.js +++ b/week-3/2-mandatory/5-journey-planner.js @@ -7,12 +7,8 @@ NOTE: only the names should be returned, not the means of transport. */ -function journeyPlanner(item) { - let newArr=[]; - for(i = 0; i < item.length; i++){ - - } - +function journeyPlanner(item, vehicle) { + return item.filter(x => x.includes(vehicle)).map(x => x[0]) } /* ======= TESTS - DO NOT MODIFY ===== */ From c73998d279db11fc52bf9a877cda953d6df54d0a Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Thu, 2 Jul 2020 00:13:32 +0100 Subject: [PATCH 64/73] Update 6-lane-names.js 6-lane-names.js is done --- week-3/2-mandatory/6-lane-names.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/week-3/2-mandatory/6-lane-names.js b/week-3/2-mandatory/6-lane-names.js index be9a94d..5db3d1e 100644 --- a/week-3/2-mandatory/6-lane-names.js +++ b/week-3/2-mandatory/6-lane-names.js @@ -4,7 +4,7 @@ Write a function that will return all street names which contain 'Lane' in their name. */ -function getLanes(item) { +/* function getLanes(item) { let streetNamesWithLanes=[]; if (item.includes("Lane")){ streetNamesWithLanes.push(item); @@ -12,6 +12,10 @@ function getLanes(item) { return "Does not include Lane"; } return streetNamesWithLanes; +} */ + +function getLanes(item) { + return item.filter(x => x.includes('Lane')); } /* ======= TESTS - DO NOT MODIFY ===== */ From 165266b21fe22602d5773ca1acb3d483755c94ed Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Thu, 2 Jul 2020 00:15:57 +0100 Subject: [PATCH 65/73] Update 7-password-validator.js 7-password.validator.js is partially done --- week-3/2-mandatory/7-password-validator.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/week-3/2-mandatory/7-password-validator.js b/week-3/2-mandatory/7-password-validator.js index 57b3d53..e62f316 100644 --- a/week-3/2-mandatory/7-password-validator.js +++ b/week-3/2-mandatory/7-password-validator.js @@ -23,7 +23,8 @@ PasswordValidationResult= [false, false, false, false, true] */ function validatePasswords(passwords) { - + let conditions = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; + return passwords.map(x => (x.length >= 5 && conditions.some(y => x.includes(y)) && x.toLowerCase() != x && x.toUpperCase() != x && (x.indexOf('!') != -1 || x.indexOf('#') != -1 || x.indexOf('$') != -1 || x.indexOf('%') != -1 || x.indexOf('.') != -1)) ? true : false) } /* ======= TESTS - DO NOT MODIFY ===== */ From 0f3e1814df1f0d345a9ad08fbe58074ef72ddd67 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Thu, 2 Jul 2020 21:55:51 +0100 Subject: [PATCH 66/73] Update 1-oxygen-levels.js 1-oxygen-levels.js is done --- week-3/2-mandatory/1-oxygen-levels.js | 1 + 1 file changed, 1 insertion(+) diff --git a/week-3/2-mandatory/1-oxygen-levels.js b/week-3/2-mandatory/1-oxygen-levels.js index 79ebc01..5ab0507 100644 --- a/week-3/2-mandatory/1-oxygen-levels.js +++ b/week-3/2-mandatory/1-oxygen-levels.js @@ -22,6 +22,7 @@ function safeLevels(oxygen) { const oxygenLevels1 = ["24.2%", "11.3%", "19.9%", "23.1%", "29.3%", "20.2%"] const oxygenLevels2 = ["30.8%", "23.5%", "18.8%", "19.5%", "20.2%", "31.6%"] + function test(test_name, expr) { let status; if (expr) { From 99888c2e8b62df28894f18523132b7db63b7c8f0 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Thu, 2 Jul 2020 21:56:08 +0100 Subject: [PATCH 67/73] Update 2-bush-berries.js 2-bush-berries.js is done --- week-3/2-mandatory/2-bush-berries.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/week-3/2-mandatory/2-bush-berries.js b/week-3/2-mandatory/2-bush-berries.js index b96ae72..2cf55ec 100644 --- a/week-3/2-mandatory/2-bush-berries.js +++ b/week-3/2-mandatory/2-bush-berries.js @@ -13,9 +13,7 @@ function bushChecker(berry) { if (berry.some(color => color !== "pink")){ return "Toxic! Leave bush alone!"; - } else { - return "Bush is safe to eat from"; - } + } return "Bush is safe to eat from"; } From 43b1332e9f21d3df45934283c10296ee4ceb0ed8 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Thu, 2 Jul 2020 21:56:25 +0100 Subject: [PATCH 68/73] Update 3-space-colonies.js 3-space-colonies is done --- week-3/2-mandatory/3-space-colonies.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/week-3/2-mandatory/3-space-colonies.js b/week-3/2-mandatory/3-space-colonies.js index 9c2892f..25ed1b2 100644 --- a/week-3/2-mandatory/3-space-colonies.js +++ b/week-3/2-mandatory/3-space-colonies.js @@ -9,9 +9,24 @@ */ function colonisers(item) { - return item.filter(x => x.includes('family') && x[0] == 'A'); + return item.filter(x => x.includes('family') && x[0] === 'A'); } +const voyagers2 = [ + "Adam family", + "Potter family", + "Eric", + "Aldous", + "Button family", + "Jude", + "Carmichael", + "Bunny", + "Asimov", + "Oscar family", + "Avery family", + "Archer family" +]; +console.log(colonisers(voyagers2)); /* ======= TESTS - DO NOT MODIFY ===== */ From 2e52f4c59494074d6e80130580586ced89337a36 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Thu, 2 Jul 2020 21:56:49 +0100 Subject: [PATCH 69/73] Update 4-eligible-students.js 4-eligible-studnets.js is done --- week-3/2-mandatory/4-eligible-students.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/week-3/2-mandatory/4-eligible-students.js b/week-3/2-mandatory/4-eligible-students.js index 5074f21..f067969 100644 --- a/week-3/2-mandatory/4-eligible-students.js +++ b/week-3/2-mandatory/4-eligible-students.js @@ -23,6 +23,15 @@ function eligibleStudents(item) { return item.filter(x => x[1] >= 8).map(x => x[0]); } +/* let arr = [ + ["Ahmed", 8], + ["Clement", 10], + ["Elamin", 6], + ["Adam", 7], + ["Tayoa", 11], + ["Nina", 10] + ] +console.log(eligibleStudents(arr)); */ /* ======= TESTS - DO NOT MODIFY ===== */ From 4599f90ab6165492550dc6747fa21b31f9e3dd4f Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Sat, 4 Jul 2020 21:06:03 +0100 Subject: [PATCH 70/73] 1-cedit-car-validator is modified --- week-3/1-exercises/C-array-every/exercise.js | 2 +- week-3/1-exercises/D-array-filter/exercise.js | 5 +++-- week-3/3-extra/1-credit-card-validator.js | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 week-3/3-extra/1-credit-card-validator.js diff --git a/week-3/1-exercises/C-array-every/exercise.js b/week-3/1-exercises/C-array-every/exercise.js index 619b374..795b5a6 100644 --- a/week-3/1-exercises/C-array-every/exercise.js +++ b/week-3/1-exercises/C-array-every/exercise.js @@ -8,7 +8,7 @@ var group = ["Austine", "Dany", "Swathi", "Daniel"]; var groupIsOnlyStudents = group.every(studentsIncludeNames); // complete this statement function studentsIncludeNames (name){ - return students.includes(name) + return students.includes(name); } //let checkNames= group.every(groupIsOnlyStudents); diff --git a/week-3/1-exercises/D-array-filter/exercise.js b/week-3/1-exercises/D-array-filter/exercise.js index 7bd21b7..1d0545d 100644 --- a/week-3/1-exercises/D-array-filter/exercise.js +++ b/week-3/1-exercises/D-array-filter/exercise.js @@ -11,8 +11,9 @@ var pairsByIndexRaw = [[0, 3], [1, 2], [2, 1], null, [1], false, "whoops"]; var pairsByIndex = pairsByIndexRaw.filter(filterOut); ; // Complete this statement function filterOut(index){ - let i= []; - return index[i].length > 1; + + let notFiltered = index.filter(a => a === "null" && a === "false" && a === "string"); + return index.length > 1; } var students = ["Islam", "Lesley", "Harun", "Rukmini"]; diff --git a/week-3/3-extra/1-credit-card-validator.js b/week-3/3-extra/1-credit-card-validator.js new file mode 100644 index 0000000..269ee22 --- /dev/null +++ b/week-3/3-extra/1-credit-card-validator.js @@ -0,0 +1,8 @@ + +function validateCardNumber (arr){ + if (arr.length === 16 && arr.forEach( x => x !== string ) && (arr.reduce((a, b) => a +b) > 16) { + + } + +} + From 9b64ef379f4083777a76a8506be249584922f413 Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Sat, 4 Jul 2020 23:02:16 +0100 Subject: [PATCH 71/73] Update exercise.js d-array-filter.js is done --- week-3/1-exercises/D-array-filter/exercise.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/week-3/1-exercises/D-array-filter/exercise.js b/week-3/1-exercises/D-array-filter/exercise.js index 1d0545d..f2ff285 100644 --- a/week-3/1-exercises/D-array-filter/exercise.js +++ b/week-3/1-exercises/D-array-filter/exercise.js @@ -11,9 +11,8 @@ var pairsByIndexRaw = [[0, 3], [1, 2], [2, 1], null, [1], false, "whoops"]; var pairsByIndex = pairsByIndexRaw.filter(filterOut); ; // Complete this statement function filterOut(index){ - - let notFiltered = index.filter(a => a === "null" && a === "false" && a === "string"); - return index.length > 1; + //return Array.isArray(index) && index.length == 2; + return index instanceof Array && index.length == 2 } var students = ["Islam", "Lesley", "Harun", "Rukmini"]; From 8b4f42e8b9ee1b41d8fd5c07d1dd982fc136f76d Mon Sep 17 00:00:00 2001 From: ISTANBULBEKLE Date: Sat, 4 Jul 2020 23:02:22 +0100 Subject: [PATCH 72/73] Update .DS_Store ds --- .DS_Store | Bin 8196 -> 8196 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.DS_Store b/.DS_Store index c52aa40948ed4d97e59b561be2d7adc331255590..2f5873bddee3e2b1e9b658ecefad88e57193248a 100644 GIT binary patch delta 195 zcmZp1XmQw}CJ=kYi-CcGg+Y%YogtH|sB;24bR$Xmqs-s|JRI8&zR;SSyf$ATQ_|&kBB_ujLAA8a!kw9C;Nz`P5vV!C}3O`T$GoSpO+3amJx_IUl1|j F1^`;fHTwVn delta 183 zcmZp1XmQw}CJ^g>hk=2Cg+Y%YogtHtYM`TFXlzoeqfl*VU~H(PU}j=mTg%BI vu4-uOnUGsqRb5kCH)}Gdh& Date: Sat, 4 Jul 2020 23:02:28 +0100 Subject: [PATCH 73/73] Update .DS_Store ds st --- week-3/.DS_Store | Bin 6148 -> 8196 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/week-3/.DS_Store b/week-3/.DS_Store index e1e1a5e341fcc554807a6a7c659bce74f112c5be..67dc2dd23a476b2ffbb181d2c0e4ae0f207eb955 100644 GIT binary patch delta 338 zcmZoMXmOBWU|?W$DortDU;r^WfEYvza8E20o2aMAD6%nNH}hr%jz7$c**Q2SHn1>? zOfFzin5@Hch$pGMxF9JfKMAP*_~ccr4enyq)rO`z3Pwh?IttYm=9W4N=B5UVshbG?^ zZ0ka?ETZE~%M99!!NkXe%#iYOqMB9m{6@G&Y(EHqfm&cPwb3^sv5fE!4= ef?T_?@H_Klei=`Y+ZmW3{s4K6VRJms9A*I406RVa