Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions 1-exercises/A-array-find/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

// write your code here


let names = [
"Rakesh",
"Antonio",
Expand All @@ -17,6 +18,14 @@ let names = [
"Ahmed",
];

function isLongNameAndStartsWithA(name) {
return name.length > 7 && name[0] == "A";
}
function findLongNameThatStartsWithA(names){
return names.find(isLongNameAndStartsWithA);

}

let longNameThatStartsWithA = findLongNameThatStartsWithA(names);

console.log(longNameThatStartsWithA);
Expand Down
9 changes: 9 additions & 0 deletions 1-exercises/B-array-some/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@

let pairsByIndex = [[0, 3], [1, 2], [2, 1], null, [3, 0]];

//***************************************************

function isNullvalue(!number) {
return !number;
}

//***************************************************

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we don't use ! in our arguments. Also the error code still needs to be returned (in the comments below).

// If there is a null value in the array exit the program with the error code
// https://nodejs.org/api/process.html#process_process_exit_code
// process.exit(1);


let students = ["Islam", "Lesley", "Harun", "Rukmini"];
let mentors = ["Daniel", "Irina", "Mozafar", "Luke"];

Expand Down
6 changes: 5 additions & 1 deletion 1-exercises/C-array-every/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
let students = ["Omar", "Austine", "Dany", "Swathi", "Lesley", "Rukmini"];
let group = ["Austine", "Dany", "Swathi", "Daniel"];

let groupIsOnlyStudents; // complete this statement
let groupIsOnlyStudents = group.every(any);{
return students.includes(any);
}
console.log(groupIsOnlyStudents);

Copy link
Copy Markdown

@ButcherDing ButcherDing Apr 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'any' isn't defined anywhere, and maybe rethink what is going to go inside .every().
.every() takes an array and gives us back 'true' if every element passes a certain test - this test can be a function - It looks like this is what you were trying to do.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 🙏 I see


if (groupIsOnlyStudents) {
console.log("The group contains only students");
Expand Down
5 changes: 4 additions & 1 deletion 1-exercises/D-array-filter/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

let pairsByIndexRaw = [[0, 3], [1, 2], [2, 1], null, [1], false, "whoops"];

let pairsByIndex; // Complete this statement
let pairsByIndex = pairsByIndexRaw.filter( item => item.length === 2);


// Complete this statement

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

let students = ["Islam", "Lesley", "Harun", "Rukmini"];
let mentors = ["Daniel", "Irina", "Mozafar", "Luke"];
Expand Down
2 changes: 1 addition & 1 deletion 1-exercises/E-array-map/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

let numbers = [0.1, 0.2, 0.3, 0.4, 0.5];

let numbersMultipliedByOneHundred; // complete this statement
let numbersMultipliedByOneHundred = numbers.map(number => number * 100); // complete this statement

console.log(numbersMultipliedByOneHundred);

Expand Down
2 changes: 1 addition & 1 deletion 1-exercises/G-array-methods/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

let numbers = [3, 2, 1];
let sortedNumbers; // complete this statement
let sortedNumbers = numbers.sort(); // complete this statement

/*
DO NOT EDIT BELOW THIS LINE
Expand Down
3 changes: 1 addition & 2 deletions 1-exercises/G-array-methods/exercise2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
let mentors = ["Daniel", "Irina", "Rares"];
let students = ["Rukmini", "Abdul", "Austine", "Swathi"];

let everyone; // complete this statement

let everyone = mentors.concat(students);
/*
DO NOT EDIT BELOW THIS LINE
--------------------------- */
Expand Down
4 changes: 2 additions & 2 deletions 1-exercises/H-array-methods-2/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ let everyone = [
"Swathi",
];

let firstFive; // complete this statement
let lastFive; // complete this statement
let firstFive = everyone.slice(0, 5);// complete this statement
let lastFive = everyone.slice(2, 7);// complete this statement

/*
DO NOT EDIT BELOW THIS LINE
Expand Down
10 changes: 9 additions & 1 deletion 1-exercises/H-array-methods-2/exercise2.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@
For example, capitailise("hello") should return "Hello"
Tip: use the string method .split() and the array method .join()
*/
//******
//originanl:
//function capitalise(str) {}
//*******

function capitalise(str) {}
function capitalise(str){
let uppercase = str.split("");
uppercase[0] = uppercase[0].toUpperCase();
return uppercase.join("");
}

/*
DO NOT EDIT BELOW THIS LINE
Expand Down
2 changes: 1 addition & 1 deletion 1-exercises/H-array-methods-2/exercise3.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let ukNations = ["Scotland", "Wales", "England", "Northern Ireland"];

function isInUK(country) {
return; // complete this statement
return ukNations.includes(country); // complete this statement
}

/*
Expand Down
3 changes: 2 additions & 1 deletion 1-exercises/I-string-replace/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
let story =
"I like dogs. One day I went to the park and I saw 10 dogs. It was a great day.";

let result = story.replace("", "");
let result = story.replace("dogs");
console.log(result);

/* EXPECTED OUTPUT */

Expand Down
4 changes: 2 additions & 2 deletions 1-exercises/J-string-substring/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

let statement = "I like programming and dogs";

statement = statement.substring();
let newStatement = statement.substring(0, 19);

console.log(statement);
console.log(newStatement);

/* EXPECTED OUTPUT

Expand Down
14 changes: 8 additions & 6 deletions 1-exercises/J-string-substring/exercise2.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

You should log only the peoples first names.

For example, if the name is "John Smith" you should return "John"
For example, if the name is "John Smith" you

should return "John"
*/

let names = [
Expand All @@ -14,11 +16,11 @@ let names = [
"Arron Graham",
];

names[0] = names[0].substring();
names[1] = names[1].substring();
names[2] = names[2].substring();
names[3] = names[3].substring();
names[4] = names[4].substring();
names[0] = names[0].substring(0, 6);
names[1] = names[1].substring(0, 6);
names[2] = names[2].substring(0, 5);
names[3] = names[3].substring(0, 5);
names[4] = names[4].substring(0, 5);

names.forEach((name) => {
console.log(name);
Expand Down
2 changes: 1 addition & 1 deletion 1-exercises/J-string-substring/exercise3.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

let statement = "I do not like programming";

let result = "";
let result = statement.substring(0, 4)+statement.substring(8, statement.length);

console.log(result);

Expand Down