From 32cc4d31cdaa854e68edd5e6e200261e59febf34 Mon Sep 17 00:00:00 2001 From: carterd888 <62474051+carterd888@users.noreply.github.com> Date: Tue, 30 Jun 2020 10:19:15 +0100 Subject: [PATCH 01/14] completed 2 exercises --- week-3/1-exercises/A-array-find/exercise.js | 7 ++++++- week-3/1-exercises/E-array-map/exercise.js | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/week-3/1-exercises/A-array-find/exercise.js b/week-3/1-exercises/A-array-find/exercise.js index d7fd51f..1f7b837 100644 --- a/week-3/1-exercises/A-array-find/exercise.js +++ b/week-3/1-exercises/A-array-find/exercise.js @@ -7,7 +7,12 @@ var names = ["Rakesh", "Antonio", "Alexandra", "Andronicus", "Annam", "Mikey", "Anastasia", "Karim", "Ahmed"]; -var longNameThatStartsWithA = findLongNameThatStartsWithA(names); +var longNameThatStartsWithA = names.find(findLongNameThatStartsWithA); + + +function findLongNameThatStartsWithA(name) { + return name.length > 7 && name[0] === "A"; +} console.log(longNameThatStartsWithA); diff --git a/week-3/1-exercises/E-array-map/exercise.js b/week-3/1-exercises/E-array-map/exercise.js index 2835e92..33d835c 100644 --- a/week-3/1-exercises/E-array-map/exercise.js +++ b/week-3/1-exercises/E-array-map/exercise.js @@ -3,3 +3,22 @@ var numbers = [0.1, 0.2, 0.3, 0.4, 0.5]; +function multiply100(number) { + return number * 100; +} + +var numbersBy100 = numbers.map(multiply100); + +var numbersBy100 = numbers.map(function multiply100(number) { + return number * 100; +}); + +var numbersBy100 = numbers.map(function (number) { + return number * 100; +}); + +var numbersBy100 = numbers.map(number => { + return number * 100; +}); + +var numbersBy100 = numbers.map(number => number * 100); \ No newline at end of file From f502e723ad98a90c6440be35ffef6292fd1fcd5a Mon Sep 17 00:00:00 2001 From: carterd888 <62474051+carterd888@users.noreply.github.com> Date: Tue, 30 Jun 2020 12:27:49 +0100 Subject: [PATCH 02/14] work in progress --- week-3/2-mandatory/1-oxygen-levels.js | 6 +++++- week-3/2-mandatory/2-bush-berries.js | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/week-3/2-mandatory/1-oxygen-levels.js b/week-3/2-mandatory/1-oxygen-levels.js index f9d745f..72b34fd 100644 --- a/week-3/2-mandatory/1-oxygen-levels.js +++ b/week-3/2-mandatory/1-oxygen-levels.js @@ -9,7 +9,11 @@ To be safe to land on, a planet needs to have an Oxygen level between 19.5% and Write a function that finds the first safe oxygen level in the array - Oxygen between 19.5% and 23.5% */ -function safeLevels() { +function safeLevels(oxygen) { + for(let i =0; i < oxygen.length; i++) + if (oxygen[i] >= 19.5 && oxygen[i] <= 23.5) { + return oxygen[i]; + } } diff --git a/week-3/2-mandatory/2-bush-berries.js b/week-3/2-mandatory/2-bush-berries.js index aca45ad..95bccc3 100644 --- a/week-3/2-mandatory/2-bush-berries.js +++ b/week-3/2-mandatory/2-bush-berries.js @@ -10,10 +10,14 @@ Use the tests to confirm which message to return */ -function bushChecker() { +function bushChecker(berry) { + for(let i=0; i < berry.length; i++) { +if(berry[i] !== "pink") { + return `Toxic! Leave bush alone!`; + } return `Bush is safe to eat from` } - +} /* ======= TESTS - DO NOT MODIFY ===== */ let bushBerryColours1 = ["pink", "pink", "pink", "neon", "pink", "transparent"] From 4d2c01ee2702b587672eb40a6b5884ed7495b8ff Mon Sep 17 00:00:00 2001 From: carterd888 <62474051+carterd888@users.noreply.github.com> Date: Tue, 30 Jun 2020 19:40:35 +0100 Subject: [PATCH 03/14] completed mandatory 1 --- week-3/2-mandatory/1-oxygen-levels.js | 18 +++++++++++++----- week-3/2-mandatory/2-bush-berries.js | 7 +------ week-3/2-mandatory/3-space-colonies.js | 7 +++++-- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/week-3/2-mandatory/1-oxygen-levels.js b/week-3/2-mandatory/1-oxygen-levels.js index 72b34fd..e85681b 100644 --- a/week-3/2-mandatory/1-oxygen-levels.js +++ b/week-3/2-mandatory/1-oxygen-levels.js @@ -9,11 +9,19 @@ To be safe to land on, a planet needs to have an Oxygen level between 19.5% and Write a function that finds the first safe oxygen level in the array - Oxygen between 19.5% and 23.5% */ -function safeLevels(oxygen) { - for(let i =0; i < oxygen.length; i++) - if (oxygen[i] >= 19.5 && oxygen[i] <= 23.5) { - return oxygen[i]; - } +function findRightPlanet (oxygenLevelOfPlanet) { + if (parseFloat(oxygenLevelOfPlanet) > 19.50 && parseFloat(oxygenLevelOfPlanet) < 23.50) { + + return `${oxygenLevelOfPlanet}%`; + } + else { +return; + } +} + +function safeLevels(oxygenLevel) { +return oxygenLevel.find(findRightPlanet); + } diff --git a/week-3/2-mandatory/2-bush-berries.js b/week-3/2-mandatory/2-bush-berries.js index 95bccc3..2c9d7a9 100644 --- a/week-3/2-mandatory/2-bush-berries.js +++ b/week-3/2-mandatory/2-bush-berries.js @@ -10,13 +10,8 @@ Use the tests to confirm which message to return */ -function bushChecker(berry) { - for(let i=0; i < berry.length; i++) { -if(berry[i] !== "pink") { - return `Toxic! Leave bush alone!`; - } return `Bush is safe to eat from` +function bushChecker(allBushBerryColours) { -} } /* ======= TESTS - DO NOT MODIFY ===== */ diff --git a/week-3/2-mandatory/3-space-colonies.js b/week-3/2-mandatory/3-space-colonies.js index 239eddd..0c64b02 100644 --- a/week-3/2-mandatory/3-space-colonies.js +++ b/week-3/2-mandatory/3-space-colonies.js @@ -7,9 +7,12 @@ NOTE: don't include any element that is not a "family". */ +let newArray = []; -function colonisers() { - +function colonisers(name) { +if(name.includes("family") === true && name.startsWith("A")=== true) { + newArray.push(name); +} } /* ======= TESTS - DO NOT MODIFY ===== */ From 098d7895595a0feb43dc069013abbbf4264c9082 Mon Sep 17 00:00:00 2001 From: carterd888 <62474051+carterd888@users.noreply.github.com> Date: Tue, 30 Jun 2020 20:09:32 +0100 Subject: [PATCH 04/14] completed mandatory 2 --- week-3/2-mandatory/2-bush-berries.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/week-3/2-mandatory/2-bush-berries.js b/week-3/2-mandatory/2-bush-berries.js index 2c9d7a9..66ef591 100644 --- a/week-3/2-mandatory/2-bush-berries.js +++ b/week-3/2-mandatory/2-bush-berries.js @@ -9,9 +9,19 @@ Use the tests to confirm which message to return */ +function checkColourPink(berryColour) { +if(berryColour === "pink") { + return true; +} +} function bushChecker(allBushBerryColours) { - +let colourResult = allBushBerryColours.every(checkColourPink); +if(colourResult === true) { + return "Bush is safe to eat from"; +} else { + return "Toxic! Leave bush alone!"; +} } /* ======= TESTS - DO NOT MODIFY ===== */ From e5b2c38aeec8f84101b52147517ff0a9cf048d0a Mon Sep 17 00:00:00 2001 From: carterd888 <62474051+carterd888@users.noreply.github.com> Date: Thu, 2 Jul 2020 09:14:57 +0100 Subject: [PATCH 05/14] completed mandatory 3 --- week-3/2-mandatory/3-space-colonies.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/week-3/2-mandatory/3-space-colonies.js b/week-3/2-mandatory/3-space-colonies.js index 0c64b02..7b9dc98 100644 --- a/week-3/2-mandatory/3-space-colonies.js +++ b/week-3/2-mandatory/3-space-colonies.js @@ -7,14 +7,17 @@ NOTE: don't include any element that is not a "family". */ -let newArray = []; -function colonisers(name) { -if(name.includes("family") === true && name.startsWith("A")=== true) { - newArray.push(name); -} +//filter to remove non family and non A start + +function colonisers(arr) { + return arr.filter(function(el) { + return el.startsWith("A") && el.includes("family"); + }) } + + /* ======= TESTS - DO NOT MODIFY ===== */ const voyagers = [ From faa340f83400381b215f4c3619ec6dd106656156 Mon Sep 17 00:00:00 2001 From: carterd888 <62474051+carterd888@users.noreply.github.com> Date: Thu, 2 Jul 2020 10:36:45 +0100 Subject: [PATCH 06/14] completed mandatory 4 --- week-3/2-mandatory/4-eligible-students.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/week-3/2-mandatory/4-eligible-students.js b/week-3/2-mandatory/4-eligible-students.js index d8fe052..46bdc79 100644 --- a/week-3/2-mandatory/4-eligible-students.js +++ b/week-3/2-mandatory/4-eligible-students.js @@ -7,9 +7,17 @@ - Returns an array containing only the names of the who have attended AT LEAST 8 classes */ -function eligibleStudents() { +//nested array [0] name [1] attendance, return array with just index [0] if [1] is >= 8 +function eligibleStudents(arr) { + let newArr = []; + for(let i= 0; i < arr.length; i++) { + if (arr[i][1] >= 8) { + newArr.push(arr[i][0]); + } + } return newArr; +}; + -} /* ======= TESTS - DO NOT MODIFY ===== */ From 75c94a994c96bcd1cc38a97f3309f564d126e282 Mon Sep 17 00:00:00 2001 From: carterd888 <62474051+carterd888@users.noreply.github.com> Date: Thu, 2 Jul 2020 13:20:34 +0100 Subject: [PATCH 07/14] solved mandatory 5 --- week-3/2-mandatory/5-journey-planner.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/week-3/2-mandatory/5-journey-planner.js b/week-3/2-mandatory/5-journey-planner.js index 816637d..e1cf98c 100644 --- a/week-3/2-mandatory/5-journey-planner.js +++ b/week-3/2-mandatory/5-journey-planner.js @@ -6,10 +6,16 @@ NOTE: only the names should be returned, not the means of transport. */ - -function journeyPlanner() { +// return[0] index value if incudes string "transport" +function journeyPlanner(arr, transport) { + let newArr =[]; +for(let i = 0; i < arr.length; i++) { + if (arr[i].includes(transport)) { + newArr.push(arr[i][0]); + } + } return newArr; + } - /* ======= TESTS - DO NOT MODIFY ===== */ const londonLocations = [ From 53971c4daaee80d498bb102ebc07705a390a47ba Mon Sep 17 00:00:00 2001 From: carterd888 <62474051+carterd888@users.noreply.github.com> Date: Thu, 2 Jul 2020 14:34:29 +0100 Subject: [PATCH 08/14] solved mandatory 6 --- week-3/2-mandatory/6-lane-names.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/week-3/2-mandatory/6-lane-names.js b/week-3/2-mandatory/6-lane-names.js index ef4e1c5..53d029e 100644 --- a/week-3/2-mandatory/6-lane-names.js +++ b/week-3/2-mandatory/6-lane-names.js @@ -4,8 +4,13 @@ Write a function that will return all street names which contain 'Lane' in their name. */ -function getLanes() { + function checkLanes(string) { + return string.includes("Lane"); + } + +function getLanes(arr) { + return arr.filter(checkLanes); } /* ======= TESTS - DO NOT MODIFY ===== */ From 1dc6894fd2c9b0c5863dce2312f986d2de944357 Mon Sep 17 00:00:00 2001 From: carterd888 <62474051+carterd888@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:28:50 +0100 Subject: [PATCH 09/14] mandatory 7 wip --- week-3/2-mandatory/7-password-validator.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/week-3/2-mandatory/7-password-validator.js b/week-3/2-mandatory/7-password-validator.js index d408ba6..805b1fd 100644 --- a/week-3/2-mandatory/7-password-validator.js +++ b/week-3/2-mandatory/7-password-validator.js @@ -21,6 +21,17 @@ Expected Result: PasswordValidationResult= [false, false, false, false, true] */ +function fiveOrMoreCharacters(password) { + return password.length >= 5; +} + +function containsUpperCase(password) { + return password.includes(/^[A-Z]+$/); +} + +function containsLowerCase(password) { + return password.includes(/^[a-z]+$/); +} function validatePasswords(passwords) { From 456e41159ff4c24d9bd5962ea72b5e114a551a23 Mon Sep 17 00:00:00 2001 From: carterd888 <62474051+carterd888@users.noreply.github.com> Date: Thu, 2 Jul 2020 19:07:49 +0100 Subject: [PATCH 10/14] added descriptive names --- week-3/2-mandatory/3-space-colonies.js | 6 +++--- week-3/2-mandatory/4-eligible-students.js | 12 ++++++------ week-3/2-mandatory/5-journey-planner.js | 12 ++++++------ week-3/2-mandatory/6-lane-names.js | 8 ++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/week-3/2-mandatory/3-space-colonies.js b/week-3/2-mandatory/3-space-colonies.js index 7b9dc98..5fa18a6 100644 --- a/week-3/2-mandatory/3-space-colonies.js +++ b/week-3/2-mandatory/3-space-colonies.js @@ -10,9 +10,9 @@ //filter to remove non family and non A start -function colonisers(arr) { - return arr.filter(function(el) { - return el.startsWith("A") && el.includes("family"); +function colonisers(voyagersArray) { + return voyagersArray.filter(function(voyagerName) { + return voyagerName.startsWith("A") && voyagerName.includes("family"); }) } diff --git a/week-3/2-mandatory/4-eligible-students.js b/week-3/2-mandatory/4-eligible-students.js index 46bdc79..296b3aa 100644 --- a/week-3/2-mandatory/4-eligible-students.js +++ b/week-3/2-mandatory/4-eligible-students.js @@ -8,13 +8,13 @@ */ //nested array [0] name [1] attendance, return array with just index [0] if [1] is >= 8 -function eligibleStudents(arr) { - let newArr = []; - for(let i= 0; i < arr.length; i++) { - if (arr[i][1] >= 8) { - newArr.push(arr[i][0]); +function eligibleStudents(attendancesArray) { + let namesArray = []; + for(let i= 0; i < attendancesArray.length; i++) { + if (attendancesArray[i][1] >= 8) { + namesArray.push(attendancesArray[i][0]); } - } return newArr; + } return namesArray; }; diff --git a/week-3/2-mandatory/5-journey-planner.js b/week-3/2-mandatory/5-journey-planner.js index e1cf98c..c50cd4a 100644 --- a/week-3/2-mandatory/5-journey-planner.js +++ b/week-3/2-mandatory/5-journey-planner.js @@ -7,13 +7,13 @@ NOTE: only the names should be returned, not the means of transport. */ // return[0] index value if incudes string "transport" -function journeyPlanner(arr, transport) { - let newArr =[]; -for(let i = 0; i < arr.length; i++) { - if (arr[i].includes(transport)) { - newArr.push(arr[i][0]); +function journeyPlanner(londonLocationsArray, transportMethod) { + let locationsAvailableArray =[]; +for(let i = 0; i < londonLocationsArray.length; i++) { + if (londonLocationsArray[i].includes(transportMethod)) { + locationsAvailableArray.push(londonLocationsArray[i][0]); } - } return newArr; + } return locationsAvailableArray; } /* ======= TESTS - DO NOT MODIFY ===== */ diff --git a/week-3/2-mandatory/6-lane-names.js b/week-3/2-mandatory/6-lane-names.js index 53d029e..b8bf309 100644 --- a/week-3/2-mandatory/6-lane-names.js +++ b/week-3/2-mandatory/6-lane-names.js @@ -5,12 +5,12 @@ */ - function checkLanes(string) { - return string.includes("Lane"); + function checkLanes(streetNameAsString) { + return streetNameAsString.includes("Lane"); } -function getLanes(arr) { - return arr.filter(checkLanes); +function getLanes(streetNamesArray) { + return streetNamesArray.filter(checkLanes); } /* ======= TESTS - DO NOT MODIFY ===== */ From ed0f5dd4c8cad6583bbe7eed8d5db3cb87d73656 Mon Sep 17 00:00:00 2001 From: carterd888 <62474051+carterd888@users.noreply.github.com> Date: Thu, 2 Jul 2020 21:12:24 +0100 Subject: [PATCH 11/14] wip mandatory 7 --- week-3/2-mandatory/7-password-validator.js | 70 ++++++++++++++++++++-- 1 file changed, 65 insertions(+), 5 deletions(-) diff --git a/week-3/2-mandatory/7-password-validator.js b/week-3/2-mandatory/7-password-validator.js index 90cd7b9..bfb273a 100644 --- a/week-3/2-mandatory/7-password-validator.js +++ b/week-3/2-mandatory/7-password-validator.js @@ -21,22 +21,82 @@ Expected Result: PasswordValidationResult= [false, false, false, false, true] */ -function fiveOrMoreCharacters(password) { - return password.length >= 5; +let test1 = ["Se%5", "TktE.TJTU", "384#HsHF", "dvyyeyy!5", "tryT3729"] + +function fiveOrMoreCharacters(passwordString) { + if (passwordString.length >= 5) { + console.log(true); + } else { + console.log(false); + + }; } + function containsUpperCase(password) { - return password.includes(/^[A-Z]+$/); + if (password.includes("A", "B", "C")) { + console.log(true); + } else { + console.log(false); + + }; } function containsLowerCase(password) { - return password.includes(/^[a-z]+$/); + if (password.includes("a", "b", "c")) { + console.log(true); + } else { + console.log(false); + + }; } -function validatePasswords(passwords) { +function containsNumbers(password) { + if (password.includes("0", "1", 2, "3")) { + console.log(true); + } else { + console.log(false); + + }; +} + +function containsSymbols(password) { + if (password.includes("!", "#", "$", "%", ".", "*", "&")) { + console.log(true); + } else { + console.log(false); + + }; +} +function allPass(password) { + if(fiveOrMoreCharacters === true) { + if(containsUpperCase === true) { + if(containsLowerCase === true) { + if(containsNumbers === true) { + if(containsSymbols === true) { + return true; +} return false; + } + } + } + } +} + + +function validatePasswords(passwords) { + let returnArray = []; + for(let i =0; i < passwords.length; i++) { + if (fiveOrMoreCharacters === true && containsUpperCase === true && containsLowerCase === true && containsNumbers === true && containsSymbols === true) { + returnArray.push(true); + } else { + returnArray.push(false); + } + } return returnArray; } + + /* ======= TESTS - DO NOT MODIFY ===== */ const passwords1 = ["Se%5", "TktE.TJTU", "384#HsHF", "dvyyeyy!5", "tryT3729"] From c6a8c0ee839566578b4cb0de094c0cc42f06d4a2 Mon Sep 17 00:00:00 2001 From: carterd888 <62474051+carterd888@users.noreply.github.com> Date: Fri, 3 Jul 2020 18:49:32 +0100 Subject: [PATCH 12/14] passed test 1 --- week-3/2-mandatory/7-password-validator.js | 70 +++++----------------- 1 file changed, 16 insertions(+), 54 deletions(-) diff --git a/week-3/2-mandatory/7-password-validator.js b/week-3/2-mandatory/7-password-validator.js index bfb273a..8b04d03 100644 --- a/week-3/2-mandatory/7-password-validator.js +++ b/week-3/2-mandatory/7-password-validator.js @@ -21,82 +21,44 @@ Expected Result: PasswordValidationResult= [false, false, false, false, true] */ -let test1 = ["Se%5", "TktE.TJTU", "384#HsHF", "dvyyeyy!5", "tryT3729"] function fiveOrMoreCharacters(passwordString) { - if (passwordString.length >= 5) { - console.log(true); - } else { - console.log(false); - - }; + return passwordString.length >= 5; } function containsUpperCase(password) { - if (password.includes("A", "B", "C")) { - console.log(true); - } else { - console.log(false); - - }; + let regex = /[A-Z]/; + return regex.test(password); } function containsLowerCase(password) { - if (password.includes("a", "b", "c")) { - console.log(true); - } else { - console.log(false); - - }; + let regex = /[a-z]/; + return regex.test(password); } function containsNumbers(password) { - if (password.includes("0", "1", 2, "3")) { - console.log(true); - } else { - console.log(false); - - }; + let regex = /[0-9]/; + return regex.test(password); } function containsSymbols(password) { - if (password.includes("!", "#", "$", "%", ".", "*", "&")) { - console.log(true); - } else { - console.log(false); - - }; + let regex = /[!#$%.*&]/; + return regex.test(password); } -function allPass(password) { - if(fiveOrMoreCharacters === true) { - if(containsUpperCase === true) { - if(containsLowerCase === true) { - if(containsNumbers === true) { - if(containsSymbols === true) { - return true; -} return false; - } - } - } - } -} +function containsRepeat(passwords) { +} function validatePasswords(passwords) { - let returnArray = []; - for(let i =0; i < passwords.length; i++) { - if (fiveOrMoreCharacters === true && containsUpperCase === true && containsLowerCase === true && containsNumbers === true && containsSymbols === true) { - returnArray.push(true); - } else { - returnArray.push(false); - } - } return returnArray; + return passwords.map(password => fiveOrMoreCharacters(password) + && containsUpperCase(password) + && containsLowerCase(password) + && containsNumbers(password) + && containsSymbols(password)); } - - /* ======= TESTS - DO NOT MODIFY ===== */ const passwords1 = ["Se%5", "TktE.TJTU", "384#HsHF", "dvyyeyy!5", "tryT3729"] From 7712d1492d9b48c644d130e1b2b2a655109232b8 Mon Sep 17 00:00:00 2001 From: carterd888 <62474051+carterd888@users.noreply.github.com> Date: Sun, 5 Jul 2020 12:02:14 +0100 Subject: [PATCH 13/14] completed mandatory 7 --- week-3/2-mandatory/7-password-validator.js | 48 ++++++++++++++-------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/week-3/2-mandatory/7-password-validator.js b/week-3/2-mandatory/7-password-validator.js index 8b04d03..45eba65 100644 --- a/week-3/2-mandatory/7-password-validator.js +++ b/week-3/2-mandatory/7-password-validator.js @@ -27,36 +27,48 @@ function fiveOrMoreCharacters(passwordString) { } -function containsUpperCase(password) { +function containsUpperCase(passwordString) { let regex = /[A-Z]/; - return regex.test(password); + return regex.test(passwordString); } -function containsLowerCase(password) { +function containsLowerCase(passwordString) { let regex = /[a-z]/; - return regex.test(password); + return regex.test(passwordString); } -function containsNumbers(password) { +function containsNumbers(passwordString) { let regex = /[0-9]/; - return regex.test(password); + return regex.test(passwordString); } -function containsSymbols(password) { +function containsSymbols(passwordString) { let regex = /[!#$%.*&]/; - return regex.test(password); + return regex.test(passwordString); } -function containsRepeat(passwords) { - -} - -function validatePasswords(passwords) { - return passwords.map(password => fiveOrMoreCharacters(password) - && containsUpperCase(password) - && containsLowerCase(password) - && containsNumbers(password) - && containsSymbols(password)); +function validatePasswords(passwordsArray) { + return passwordsArray.map((passwordString, index, passwordsArray) => { + let notRepeated = true; + for (let j = 0; j < passwordsArray.length; j++) { + if (index !== j) { + if (passwordsArray[index] === passwordsArray[j]) { + notRepeated = false; + if (index < j) { notRepeated = true } + break; + } + } + if (!notRepeated) { + break; + } + } + return fiveOrMoreCharacters(passwordString) + && containsUpperCase(passwordString) + && containsLowerCase(passwordString) + && containsNumbers(passwordString) + && containsSymbols(passwordString) + && notRepeated + }) } /* ======= TESTS - DO NOT MODIFY ===== */ From 7d6016ca53e1c42715db29f27995446e52f8485d Mon Sep 17 00:00:00 2001 From: carterd888 <62474051+carterd888@users.noreply.github.com> Date: Sun, 5 Jul 2020 13:46:27 +0100 Subject: [PATCH 14/14] completed exercises - some not working fully --- week-3/1-exercises/B-array-some/exercise.js | 3 +++ week-3/1-exercises/C-array-every/exercise.js | 2 +- week-3/1-exercises/D-array-filter/exercise.js | 5 ++++- week-3/1-exercises/F-array-forEach/exercise.js | 12 ++++++++++++ week-3/1-exercises/G-array-methods/exercise.js | 2 +- week-3/1-exercises/G-array-methods/exercise2.js | 2 +- week-3/1-exercises/H-array-methods-2/exercise.js | 4 ++-- week-3/1-exercises/H-array-methods-2/exercise2.js | 6 +++++- week-3/1-exercises/H-array-methods-2/exercise3.js | 2 +- 9 files changed, 30 insertions(+), 8 deletions(-) diff --git a/week-3/1-exercises/B-array-some/exercise.js b/week-3/1-exercises/B-array-some/exercise.js index 965c052..964f06e 100644 --- a/week-3/1-exercises/B-array-some/exercise.js +++ b/week-3/1-exercises/B-array-some/exercise.js @@ -16,6 +16,9 @@ var students = ["Islam", "Lesley", "Harun", "Rukmini"]; var mentors = ["Daniel", "Irina", "Mozafar", "Luke"]; var pairs = pairsByIndex.map(function(indexes) { + if(indexes === null) { + process.exit(1); + } var student = students[indexes[0]]; var mentor = mentors[indexes[1]]; return [student, mentor]; diff --git a/week-3/1-exercises/C-array-every/exercise.js b/week-3/1-exercises/C-array-every/exercise.js index b515e94..884c01a 100644 --- a/week-3/1-exercises/C-array-every/exercise.js +++ b/week-3/1-exercises/C-array-every/exercise.js @@ -5,7 +5,7 @@ var students = ["Omar", "Austine", "Dany", "Swathi", "Lesley", "Rukmini"]; var group = ["Austine", "Dany", "Swathi", "Daniel"]; -var groupIsOnlyStudents; // complete this statement +var groupIsOnlyStudents = group.includes(students); // complete this statement if (groupIsOnlyStudents) { console.log("The group contains only students"); diff --git a/week-3/1-exercises/D-array-filter/exercise.js b/week-3/1-exercises/D-array-filter/exercise.js index 6e32cc6..aedf402 100644 --- a/week-3/1-exercises/D-array-filter/exercise.js +++ b/week-3/1-exercises/D-array-filter/exercise.js @@ -8,7 +8,10 @@ var pairsByIndexRaw = [[0, 3], [1, 2], [2, 1], null, [1], false, "whoops"]; -var pairsByIndex; // Complete this statement +function isNumber(obj) { + return obj !== undefined && typeof (obj) === 'number' && !isNaN(obj) +} +var pairsByIndex = pairsByIndexRaw.filter(isNumber); // Complete this statement var students = ["Islam", "Lesley", "Harun", "Rukmini"]; var mentors = ["Daniel", "Irina", "Mozafar", "Luke"]; diff --git a/week-3/1-exercises/F-array-forEach/exercise.js b/week-3/1-exercises/F-array-forEach/exercise.js index e83e2df..6f17c5c 100644 --- a/week-3/1-exercises/F-array-forEach/exercise.js +++ b/week-3/1-exercises/F-array-forEach/exercise.js @@ -9,6 +9,18 @@ var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; +function printFizzBuzz (number) { + if(number % 3 === 0 && number % 5 === 0) { + return "FizzBuzz"; + } else if(number % 3 === 0) { + return "Fizz"; + } else if(number % 5=== 0) { + return "Buzz"; + } return number; +} +arr.map(printFizzBuzz).forEach(index => console.log(index)); + + /* EXPECTED OUTPUT */ /* diff --git a/week-3/1-exercises/G-array-methods/exercise.js b/week-3/1-exercises/G-array-methods/exercise.js index 44e9c80..b16182b 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 diff --git a/week-3/1-exercises/G-array-methods/exercise2.js b/week-3/1-exercises/G-array-methods/exercise2.js index 3dd24a1..dd87089 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 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..b31cd58 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, 7); // complete this statement /* DO NOT EDIT BELOW THIS LINE 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..d4f7c2c 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,11 @@ Tip: use the string method .split() and the array method .join() */ -function capitalise(str) {} +function capitalise(str) { + let firstLetter = str.split(0,1); + firstLetter.toUpperCase(); +return firstLetter.join(); +} /* DO NOT EDIT BELOW THIS LINE 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 } /*