From 37a878230fc49afb895b479c11b9974a3e2c8892 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Wed, 23 Feb 2022 19:25:09 +0100 Subject: [PATCH 001/117] adding the information for the correct file --- week-1/.vscode/settings.json | 3 +++ week-1/InClass/exercise-A.js | 1 + week-1/InClass/exercise-B.js | 11 +++++++++++ 3 files changed, 15 insertions(+) create mode 100644 week-1/.vscode/settings.json diff --git a/week-1/.vscode/settings.json b/week-1/.vscode/settings.json new file mode 100644 index 00000000..6f3a2913 --- /dev/null +++ b/week-1/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/week-1/InClass/exercise-A.js b/week-1/InClass/exercise-A.js index e69de29b..019c0f4b 100644 --- a/week-1/InClass/exercise-A.js +++ b/week-1/InClass/exercise-A.js @@ -0,0 +1 @@ +console.log("Hello World!"); diff --git a/week-1/InClass/exercise-B.js b/week-1/InClass/exercise-B.js index e69de29b..8f6ec366 100644 --- a/week-1/InClass/exercise-B.js +++ b/week-1/InClass/exercise-B.js @@ -0,0 +1,11 @@ +console.log("Hello World!"); +console.log("Olá mundo! // Brasil"); +console.log("Holá mundo! // España"); +console.log("Hei Verden // Noruego"); +console.log("Ciao World // Italia"); +console.log("Hallo Weld // Alemania"); +console.log("Hej världen // Sueco"); +console.log("Witaj świecie // Polaco"); +console.log("नमस्ते दुनिया // Hindi"); +console.log("Aloha Honua // Hawaiano") +console.log("Helló Világ // Hungaro"); \ No newline at end of file From 347d27274559be9dd38dc4f1653af3e7f27f49b7 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Wed, 23 Feb 2022 19:27:21 +0100 Subject: [PATCH 002/117] adding the exercise-C answer --- week-1/InClass/exercise-C.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/week-1/InClass/exercise-C.js b/week-1/InClass/exercise-C.js index e69de29b..4cb831e6 100644 --- a/week-1/InClass/exercise-C.js +++ b/week-1/InClass/exercise-C.js @@ -0,0 +1,5 @@ +let greeting = "Hello World" + +console.log(greeting); +console.log(greeting); +console.log(greeting); From 292239c7b048aa56ac56e3322fd7797da3582714 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Wed, 23 Feb 2022 19:54:48 +0100 Subject: [PATCH 003/117] adding the exercise D --- week-1/InClass/exercise-D.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/week-1/InClass/exercise-D.js b/week-1/InClass/exercise-D.js index e69de29b..2caf9ff9 100644 --- a/week-1/InClass/exercise-D.js +++ b/week-1/InClass/exercise-D.js @@ -0,0 +1,3 @@ +const colors = "blue,yellow"; + +console.log(typeof colors); From c9e8e5c42ff9bb670d11c9ad962098c353db0809 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Wed, 23 Feb 2022 20:07:35 +0100 Subject: [PATCH 004/117] adding the exercise D --- week-1/InClass/exercise-E.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/week-1/InClass/exercise-E.js b/week-1/InClass/exercise-E.js index e69de29b..fd3debb9 100644 --- a/week-1/InClass/exercise-E.js +++ b/week-1/InClass/exercise-E.js @@ -0,0 +1,9 @@ +const greetingStart = "Hello, my name is "; +const nameUser = "Cristiane"; + +const greeting = greetingStart + nameUser; + + +console.log(greeting); + +console.log(greetingStart + nameUser); \ No newline at end of file From 640b82f57215453a6c1e605a0cc20f5608cacde9 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Wed, 23 Feb 2022 20:08:53 +0100 Subject: [PATCH 005/117] adding the exercise E --- week-1/InClass/exercise-E.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-1/InClass/exercise-E.js b/week-1/InClass/exercise-E.js index fd3debb9..225db0f6 100644 --- a/week-1/InClass/exercise-E.js +++ b/week-1/InClass/exercise-E.js @@ -6,4 +6,4 @@ const greeting = greetingStart + nameUser; console.log(greeting); -console.log(greetingStart + nameUser); \ No newline at end of file +console.log(greetingStart + nameUser); From cf1e78cdde05dac3dfaa2e99ac10f271c55e65ab Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Wed, 23 Feb 2022 20:33:07 +0100 Subject: [PATCH 006/117] adding the exercise D --- week-1/InClass/exercise-D.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/week-1/InClass/exercise-D.js b/week-1/InClass/exercise-D.js index 2caf9ff9..94842728 100644 --- a/week-1/InClass/exercise-D.js +++ b/week-1/InClass/exercise-D.js @@ -1,3 +1,5 @@ -const colors = "blue,yellow"; +const colors = "blue, yellow"; console.log(typeof colors); + +console.log(colors); From b4fb1f11d2245aba1ddd8a76d72e4972486a31ff Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Wed, 23 Feb 2022 20:48:13 +0100 Subject: [PATCH 007/117] adding the exercise F --- week-1/InClass/exercise-F.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/week-1/InClass/exercise-F.js b/week-1/InClass/exercise-F.js index e69de29b..14484a34 100644 --- a/week-1/InClass/exercise-F.js +++ b/week-1/InClass/exercise-F.js @@ -0,0 +1,9 @@ +const numberOfStudents = 15; + +const numberofMentors = 8; + +console.log(`Number of students: ${numberOfStudents}.`); + +console.log(`Number of mentors: ${numberofMentors}.`); + +console.log(`Total number of students and mentors: ${numberOfStudents +numberofMentors}.`); From fa1a0e6efd9199c0e22f76ddc2ea2b6731e658cf Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Wed, 23 Feb 2022 21:03:49 +0100 Subject: [PATCH 008/117] adding extra way to see on console the exercise F --- week-1/InClass/exercise-F.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/week-1/InClass/exercise-F.js b/week-1/InClass/exercise-F.js index 14484a34..5602cf61 100644 --- a/week-1/InClass/exercise-F.js +++ b/week-1/InClass/exercise-F.js @@ -2,8 +2,13 @@ const numberOfStudents = 15; const numberofMentors = 8; +const totalNumberOfClass = numberOfStudents + numberofMentors; + + console.log(`Number of students: ${numberOfStudents}.`); console.log(`Number of mentors: ${numberofMentors}.`); -console.log(`Total number of students and mentors: ${numberOfStudents +numberofMentors}.`); +console.log(`Total number of students and mentors: ${numberOfStudents + numberofMentors}.`); + +console.log('Total number of students and mentors:' + totalNumberOfClass ); \ No newline at end of file From dba633afc11a6c9c454b910ddc6dae55d4b5d45e Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Fri, 25 Feb 2022 21:03:58 +0100 Subject: [PATCH 009/117] adding the exercise G --- week-1/InClass/exercise-G.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/week-1/InClass/exercise-G.js b/week-1/InClass/exercise-G.js index e69de29b..a7ce83c4 100644 --- a/week-1/InClass/exercise-G.js +++ b/week-1/InClass/exercise-G.js @@ -0,0 +1,13 @@ +const numberOfStudents = 15; + +const numberofMentors = 8; + +const totalNumberOfClass = numberOfStudents + numberofMentors; + +const percentageOfStudents = (100 * numberOfStudents /totalNumberOfClass); + +const percentageOfMentors = (100 * numberofMentors / totalNumberOfClass); + +console.log(Math.round(percentageOfStudents)); + +console.log(Math.round(percentageOfMentors)); From e09cfa1a9af417edd8893f4bda3fdc04b268af18 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Fri, 25 Feb 2022 22:11:50 +0100 Subject: [PATCH 010/117] adding the answer of the exercise B --- week-1/InClass/exercise-B.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-1/InClass/exercise-B.js b/week-1/InClass/exercise-B.js index 8f6ec366..13fb5234 100644 --- a/week-1/InClass/exercise-B.js +++ b/week-1/InClass/exercise-B.js @@ -8,4 +8,4 @@ console.log("Hej världen // Sueco"); console.log("Witaj świecie // Polaco"); console.log("नमस्ते दुनिया // Hindi"); console.log("Aloha Honua // Hawaiano") -console.log("Helló Világ // Hungaro"); \ No newline at end of file +console.log("Helló Világ // Hungaro"); From 3326647cf955eb5e0b7121e17b2194c53a9aea33 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Fri, 25 Feb 2022 22:29:12 +0100 Subject: [PATCH 011/117] adding the correct answer of the exercise G with percentage symbol and Math.round --- week-1/InClass/exercise-G.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/week-1/InClass/exercise-G.js b/week-1/InClass/exercise-G.js index a7ce83c4..91be474c 100644 --- a/week-1/InClass/exercise-G.js +++ b/week-1/InClass/exercise-G.js @@ -4,10 +4,10 @@ const numberofMentors = 8; const totalNumberOfClass = numberOfStudents + numberofMentors; -const percentageOfStudents = (100 * numberOfStudents /totalNumberOfClass); +const percentageOfStudents = (100 * numberOfStudents) /totalNumberOfClass; -const percentageOfMentors = (100 * numberofMentors / totalNumberOfClass); +const percentageOfMentors = (100 * numberofMentors) / totalNumberOfClass; -console.log(Math.round(percentageOfStudents)); +console.log("Percentage students: " + Math.round(percentageOfStudents) + "%"); -console.log(Math.round(percentageOfMentors)); +console.log("Percentage mentors: " + Math.round(percentageOfMentors) + "%"); From 488fc320003ee03652cb4f922d90ed8159a82574 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Fri, 25 Feb 2022 23:08:15 +0100 Subject: [PATCH 012/117] adding the function exercise-H --- week-1/InClass/exercise-H.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/week-1/InClass/exercise-H.js b/week-1/InClass/exercise-H.js index e69de29b..b60d5478 100644 --- a/week-1/InClass/exercise-H.js +++ b/week-1/InClass/exercise-H.js @@ -0,0 +1,3 @@ +function names (nameA, nameB){ + return nameA + nameB; +} \ No newline at end of file From d7303ef4d17fea6391b466dd855269605f0f3ebe Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Fri, 25 Feb 2022 23:21:00 +0100 Subject: [PATCH 013/117] adding the answer of the questions of exercise-H --- week-1/InClass/exercise-H.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/week-1/InClass/exercise-H.js b/week-1/InClass/exercise-H.js index b60d5478..7fd30ddc 100644 --- a/week-1/InClass/exercise-H.js +++ b/week-1/InClass/exercise-H.js @@ -1,3 +1,20 @@ -function names (nameA, nameB){ - return nameA + nameB; -} \ No newline at end of file +function numbers (num1, num2){ + return num1 + num2; +} + +// The function it get the num1 and add numb2 + +const randomNumbers = numbers(5, 10) + +console.log(randomNumbers) + +/* What's the difference between a return and console.log? + + - the return is a way to get the type of the paramethers, modify it for some specific value and also to execute some extra work in action of the function. + - console.log - prints the result on the screen + + When would you choose to use functions over the way we have been scripting so far? + + -We choose the functions ( is a kind of block of codes)when we need to execute it repetitive times, so we do not need to write every single line and let the function do the job after giving it the correcter parameters. + +*/ \ No newline at end of file From 7e8fec40c69bfe5eeb8d5970566a616b2d302f08 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 00:33:33 +0100 Subject: [PATCH 014/117] adding first part of exercise-I --- week-1/InClass/exercise-I.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/week-1/InClass/exercise-I.js b/week-1/InClass/exercise-I.js index e69de29b..36928ec6 100644 --- a/week-1/InClass/exercise-I.js +++ b/week-1/InClass/exercise-I.js @@ -0,0 +1,26 @@ +function age(thisYears, yearsOld){ + return thisYears - yearsOld; +} + +const myBirthYear = age(2022, 34); +console.log(myBirthYear); // prints 1988 + + +// function createGreeting(name, year) { +// let nascimento = age(34); +// let message = "Hello " + name + " You've born in " + nascimento + "."; +// return message; +// } + +// let helloMessage = createGreeting(Cristiane, 1987) + +// console.log(helloMessage); + +// function greetings(name, year){ +// let ageinYears = age(2022, 34); +// let message = " My name is $(name) and I was born in $(age)."; +// return message; +// } + +// let helloGreetings = greetings("cristiane", 1987); +// console.log(greetings); \ No newline at end of file From 3afd1f414ae2474508d3213818037b88a7963069 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 00:52:47 +0100 Subject: [PATCH 015/117] adding the second part of the exercise -I --- week-1/InClass/exercise-I.js | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/week-1/InClass/exercise-I.js b/week-1/InClass/exercise-I.js index 36928ec6..d8d65626 100644 --- a/week-1/InClass/exercise-I.js +++ b/week-1/InClass/exercise-I.js @@ -5,22 +5,12 @@ function age(thisYears, yearsOld){ const myBirthYear = age(2022, 34); console.log(myBirthYear); // prints 1988 +// Second part of the excercise: -// function createGreeting(name, year) { -// let nascimento = age(34); -// let message = "Hello " + name + " You've born in " + nascimento + "."; -// return message; -// } +function greetings(name, year){ + return message = ` Hello, my name is ${name} and I've born in ${year}.` +}; -// let helloMessage = createGreeting(Cristiane, 1987) +let greetingsFromBarcelona = greetings("Cristiane", myBirthYear); -// console.log(helloMessage); - -// function greetings(name, year){ -// let ageinYears = age(2022, 34); -// let message = " My name is $(name) and I was born in $(age)."; -// return message; -// } - -// let helloGreetings = greetings("cristiane", 1987); -// console.log(greetings); \ No newline at end of file +console.log(greetingsFromBarcelona); // prints: Hello, my name is Cristiane and I've born in 1988. From b2bbdaa3f18550d061481693bf88e2c94134fac0 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 01:25:24 +0100 Subject: [PATCH 016/117] adding the answer of the exercise 1 F --- week-1/Homework/F-strings-methods/exercise.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/week-1/Homework/F-strings-methods/exercise.js b/week-1/Homework/F-strings-methods/exercise.js index 2cffa6a8..ee998203 100644 --- a/week-1/Homework/F-strings-methods/exercise.js +++ b/week-1/Homework/F-strings-methods/exercise.js @@ -1,3 +1,9 @@ // Start by creating a variable `message` +let nameUser = "Cristiane"; +let nameLength = nameUser.length; + +let message = `My name is ${nameUser} and my name have ${nameLength +} characters long.`; + console.log(message); From efdadda7924d472f55d02a2ba10d45343ae7c68f Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 01:41:00 +0100 Subject: [PATCH 017/117] adding the answer of the exercise 1 F --- week-1/Homework/F-strings-methods/exercise2.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/week-1/Homework/F-strings-methods/exercise2.js b/week-1/Homework/F-strings-methods/exercise2.js index b4b46943..a0fe9c3f 100644 --- a/week-1/Homework/F-strings-methods/exercise2.js +++ b/week-1/Homework/F-strings-methods/exercise2.js @@ -1,3 +1,8 @@ -const name = " Daniel "; +const nameUser = " Cristiane "; +let nameLength = nameUser.length; + + +let message = `My name is ${nameUser.trim()} and my name have ${nameLength +} characters long.`; console.log(message); From edd63a3e94b80f68c20a6d529d2c4f9c67e7b1f8 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 01:44:12 +0100 Subject: [PATCH 018/117] adding the comment to the exercise 1 --- week-1/Homework/F-strings-methods/exercise.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/week-1/Homework/F-strings-methods/exercise.js b/week-1/Homework/F-strings-methods/exercise.js index ee998203..5ca15be3 100644 --- a/week-1/Homework/F-strings-methods/exercise.js +++ b/week-1/Homework/F-strings-methods/exercise.js @@ -7,3 +7,5 @@ let message = `My name is ${nameUser} and my name have ${nameLength } characters long.`; console.log(message); + +//Prints: My name is Cristiane and my name have 12 characters long. From b600274ae8684c5620282fef8b64e8bce238d8d6 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 01:44:31 +0100 Subject: [PATCH 019/117] adding the comment to the exercise 2 --- week-1/Homework/F-strings-methods/exercise2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/week-1/Homework/F-strings-methods/exercise2.js b/week-1/Homework/F-strings-methods/exercise2.js index a0fe9c3f..05d71857 100644 --- a/week-1/Homework/F-strings-methods/exercise2.js +++ b/week-1/Homework/F-strings-methods/exercise2.js @@ -5,4 +5,6 @@ let nameLength = nameUser.length; let message = `My name is ${nameUser.trim()} and my name have ${nameLength } characters long.`; -console.log(message); +console.log(message); + +// prints: My name is Cristiane and my name have 12 characters long. From 7b30dffe5999f847358486eb9f863be2803e0683 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 01:49:38 +0100 Subject: [PATCH 020/117] completed the exercise 1 of J 'functions' // comments added --- week-1/Homework/J-functions/exercise.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/week-1/Homework/J-functions/exercise.js b/week-1/Homework/J-functions/exercise.js index 0ae5850e..f7013056 100644 --- a/week-1/Homework/J-functions/exercise.js +++ b/week-1/Homework/J-functions/exercise.js @@ -1,7 +1,16 @@ function halve(number) { // complete the function here + return number / 2; } -var result = halve(12); +var result = halve(12); // prints 6 + +var result = halve(17); // print 8.5 + +var result = halve(1287); //prints 643.5 + +var result = halve(20); //prints 10 + +console.log(result); + -console.log(result); From 15e34d285bd6487cbbe3e92b804102946a3d6f5d Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 01:52:27 +0100 Subject: [PATCH 021/117] completed the exercise 2 of J 'functions' // comments added --- week-1/Homework/J-functions/exercise2.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/week-1/Homework/J-functions/exercise2.js b/week-1/Homework/J-functions/exercise2.js index 82ef5e78..6bb51505 100644 --- a/week-1/Homework/J-functions/exercise2.js +++ b/week-1/Homework/J-functions/exercise2.js @@ -1,7 +1,14 @@ function triple(number) { // complete function here + return number * 3; } -var result = triple(12); +var result = triple(12); // prints 6 -console.log(result); +var result = triple(22); // prints 66 + +var result = triple(222); // prints 666 + +var result = triple(2222); // prints 6666 + +console.log(result); From c3c4ef2a999b371d5d8cc2e4e1a9604a9100cc97 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 02:00:57 +0100 Subject: [PATCH 022/117] adding the information for the function works - K 1 --- week-1/Homework/K-functions-parameters/exercise.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/week-1/Homework/K-functions-parameters/exercise.js b/week-1/Homework/K-functions-parameters/exercise.js index 8d5db5e6..a4eed9d7 100644 --- a/week-1/Homework/K-functions-parameters/exercise.js +++ b/week-1/Homework/K-functions-parameters/exercise.js @@ -1,6 +1,7 @@ // Complete the function so that it takes input parameters -function multiply() { +function multiply(num1, num2) { // Calculate the result of the function and return it + return num1 * num2; } // Assign the result of calling the function the variable `result` From d6deec50b6332aaf2a38b05eca159fe6c84b8426 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 02:03:17 +0100 Subject: [PATCH 023/117] adding the information for the function works - K 2 --- week-1/Homework/K-functions-parameters/exercise2.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/week-1/Homework/K-functions-parameters/exercise2.js b/week-1/Homework/K-functions-parameters/exercise2.js index db7a8904..df0504d1 100644 --- a/week-1/Homework/K-functions-parameters/exercise2.js +++ b/week-1/Homework/K-functions-parameters/exercise2.js @@ -1,5 +1,8 @@ // Declare your function first +function divide(num1, num2){ + return num1 / num2; +} var result = divide(3, 4); -console.log(result); +console.log(result); // prints 0.75 From 255ed909348df94c7d3a3998c57665099b2ed067 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 02:06:34 +0100 Subject: [PATCH 024/117] adding the comment for the result --- week-1/Homework/K-functions-parameters/exercise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-1/Homework/K-functions-parameters/exercise.js b/week-1/Homework/K-functions-parameters/exercise.js index a4eed9d7..6f96d511 100644 --- a/week-1/Homework/K-functions-parameters/exercise.js +++ b/week-1/Homework/K-functions-parameters/exercise.js @@ -7,4 +7,4 @@ function multiply(num1, num2) { // Assign the result of calling the function the variable `result` var result = multiply(3, 4); -console.log(result); +console.log(result); // prints 12 From f2d6ca34431719ff5b31aa93ce95cc65c52480a7 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 02:07:13 +0100 Subject: [PATCH 025/117] adding the function and interpolation for exercise 3 - K --- week-1/Homework/K-functions-parameters/exercise3.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/week-1/Homework/K-functions-parameters/exercise3.js b/week-1/Homework/K-functions-parameters/exercise3.js index 537e9f4e..29810338 100644 --- a/week-1/Homework/K-functions-parameters/exercise3.js +++ b/week-1/Homework/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); +console.log(greeting); // Prints: Hello, my name is Daniel From acb49ef8128341b0fa68639a49571d0d716d385e Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 02:10:33 +0100 Subject: [PATCH 026/117] adding the function to the exercise - with comments - ex 4 - K --- week-1/Homework/K-functions-parameters/exercise4.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/week-1/Homework/K-functions-parameters/exercise4.js b/week-1/Homework/K-functions-parameters/exercise4.js index 7ab44589..5f7630aa 100644 --- a/week-1/Homework/K-functions-parameters/exercise4.js +++ b/week-1/Homework/K-functions-parameters/exercise4.js @@ -1,5 +1,10 @@ // Declare your function first +function numbers(num1, num2){ + return num1 + num2; +} // Call the function and assign to a variable `sum` -console.log(sum); +const sum = numbers(13, 124); + +console.log(sum); // prints 137 From 5db37f95ed2cef0bca0252b085cb01c29b17cd0c Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 02:14:18 +0100 Subject: [PATCH 027/117] adding the last exercise of K group - added comments - exercise 5 --- week-1/Homework/K-functions-parameters/exercise5.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/week-1/Homework/K-functions-parameters/exercise5.js b/week-1/Homework/K-functions-parameters/exercise5.js index 7c5bcd60..befd5429 100644 --- a/week-1/Homework/K-functions-parameters/exercise5.js +++ b/week-1/Homework/K-functions-parameters/exercise5.js @@ -1,5 +1,8 @@ // 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); +console.log(greeting); // prints: Hello, my name is Daniel and I'm 30years old. From 720426e4f13c6059a575e58df93041c62a40d587 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 02:29:04 +0100 Subject: [PATCH 028/117] adding first part of the function on exercise L - nested functions --- week-1/Homework/L-functions-nested/exercise.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/week-1/Homework/L-functions-nested/exercise.js b/week-1/Homework/L-functions-nested/exercise.js index a5d37744..3b776808 100644 --- a/week-1/Homework/L-functions-nested/exercise.js +++ b/week-1/Homework/L-functions-nested/exercise.js @@ -3,3 +3,15 @@ var mentor2 = "Irina"; var mentor3 = "Mimi"; var mentor4 = "Rob"; var mentor5 = "Yohannes"; + +function uperCaseName (name){ + return `Hello ${name.toUpperCase()}` +} +// function uperCaseGreetings + + +let greetings = uperCaseName("Daniel") + +console.log(greetings); // Prints Hi DANIEL + + From 5a708ed8bd62d2ff85f09213ac9c4ba75804a23c Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 12:00:14 +0100 Subject: [PATCH 029/117] correcting the first part of the exercise L --- week-1/Homework/L-functions-nested/exercise.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/week-1/Homework/L-functions-nested/exercise.js b/week-1/Homework/L-functions-nested/exercise.js index 3b776808..53cad2e0 100644 --- a/week-1/Homework/L-functions-nested/exercise.js +++ b/week-1/Homework/L-functions-nested/exercise.js @@ -9,9 +9,15 @@ function uperCaseName (name){ } // function uperCaseGreetings +function shouting(){ + return greeting.toUpperCase() + uperCaseName; +} let greetings = uperCaseName("Daniel") + console.log(greetings); // Prints Hi DANIEL +console.log(shouting); + From f2d7b6ba83b0cbe3a1fbab370e1eb7e8974d8864 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 12:43:51 +0100 Subject: [PATCH 030/117] adding the exercise L with comments of the prints --- .../Homework/L-functions-nested/exercise.js | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/week-1/Homework/L-functions-nested/exercise.js b/week-1/Homework/L-functions-nested/exercise.js index 53cad2e0..312e6343 100644 --- a/week-1/Homework/L-functions-nested/exercise.js +++ b/week-1/Homework/L-functions-nested/exercise.js @@ -4,20 +4,38 @@ var mentor3 = "Mimi"; var mentor4 = "Rob"; var mentor5 = "Yohannes"; -function uperCaseName (name){ - return `Hello ${name.toUpperCase()}` +function uperCaseName (mentor){ + return `Hello ${mentor.toUpperCase()}` } -// function uperCaseGreetings -function shouting(){ - return greeting.toUpperCase() + uperCaseName; -} +var greetings = uperCaseName(); -let greetings = uperCaseName("Daniel") + /*If I call thr function, it will prints: +Hello DANIEL + Hello IRINA + Hello MIMI + Hello ROB + Hello YOHANNES */ + //Second function -console.log(greetings); // Prints Hi DANIEL -console.log(shouting); +let shoutingOutLoud = greetings.toUpperCase(); +function uperCaseName (mentor){ + return `Hello ${mentor1.toUpperCase()} +Hello ${mentor2.toUpperCase()} +Hello ${mentor3.toUpperCase()} +Hello ${mentor4.toUpperCase()} +Hello ${mentor5.toUpperCase()}` +} +console.log(shoutingOutLoud); + +/* prints: +HELLO DANIEL +HELLO IRINA +HELLO MIMI +HELLO ROB +HELLO YOHANNES +*/ From 7237d3ffaea5a82aa50d490940b247d872e2817b Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 16:01:41 +0100 Subject: [PATCH 031/117] adding the correct space on the phrase --- week-1/Homework/K-functions-parameters/exercise5.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-1/Homework/K-functions-parameters/exercise5.js b/week-1/Homework/K-functions-parameters/exercise5.js index befd5429..9457d4ca 100644 --- a/week-1/Homework/K-functions-parameters/exercise5.js +++ b/week-1/Homework/K-functions-parameters/exercise5.js @@ -5,4 +5,4 @@ function createLongGreeting( name, age ){ const greeting = createLongGreeting("Daniel", 30); -console.log(greeting); // prints: Hello, my name is Daniel and I'm 30years old. +console.log(greeting); // prints: Hello, my name is Daniel and I'm 30 years old. From ee5ede0b03ea0cb97429400705b051225720cb5e Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 17:26:17 +0100 Subject: [PATCH 032/117] adding the global const Year --- week-1/InClass/exercise-I.js | 2 ++ week-1/InClass/practica.js | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 week-1/InClass/practica.js diff --git a/week-1/InClass/exercise-I.js b/week-1/InClass/exercise-I.js index d8d65626..e975cf74 100644 --- a/week-1/InClass/exercise-I.js +++ b/week-1/InClass/exercise-I.js @@ -1,3 +1,5 @@ +const year = 2022 // global variable + function age(thisYears, yearsOld){ return thisYears - yearsOld; } diff --git a/week-1/InClass/practica.js b/week-1/InClass/practica.js new file mode 100644 index 00000000..2bf090c7 --- /dev/null +++ b/week-1/InClass/practica.js @@ -0,0 +1,5 @@ +const max = 19; +const min =1; + +console.log(Math.floor(Math.random() * (max - min + 1) +1)); + From 08f4da2262d1d5c798e3b294c80fd77103cecab7 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 17:34:40 +0100 Subject: [PATCH 033/117] correcting the Inclass exercise I --- week-1/InClass/exercise-I.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/week-1/InClass/exercise-I.js b/week-1/InClass/exercise-I.js index e975cf74..2e5d2668 100644 --- a/week-1/InClass/exercise-I.js +++ b/week-1/InClass/exercise-I.js @@ -1,18 +1,18 @@ const year = 2022 // global variable -function age(thisYears, yearsOld){ - return thisYears - yearsOld; +function returnBornDate(yearsOld){ + return year - yearsOld; } -const myBirthYear = age(2022, 34); -console.log(myBirthYear); // prints 1988 +console.log(returnBornDate(34)); // prints 1988 -// Second part of the excercise: +//Second part of the excercise: -function greetings(name, year){ - return message = ` Hello, my name is ${name} and I've born in ${year}.` -}; +function greetings(name, age){ + return ` Hello, my name is ${name} and I've born in ${returnBornDate(age)}.` +// }; +} + +console.log(greetings("Cristiane", 34)); // prints: Hello, my name is Cristiane and I've born in 1988. -let greetingsFromBarcelona = greetings("Cristiane", myBirthYear); -console.log(greetingsFromBarcelona); // prints: Hello, my name is Cristiane and I've born in 1988. From cf99033a87771540114511630c6046b06ecff5df Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 17:50:36 +0100 Subject: [PATCH 034/117] making the code smaller using the better practice of the const variable --- week-1/Homework/F-strings-methods/exercise.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/week-1/Homework/F-strings-methods/exercise.js b/week-1/Homework/F-strings-methods/exercise.js index 5ca15be3..3c48c640 100644 --- a/week-1/Homework/F-strings-methods/exercise.js +++ b/week-1/Homework/F-strings-methods/exercise.js @@ -1,11 +1,9 @@ // Start by creating a variable `message` -let nameUser = "Cristiane"; -let nameLength = nameUser.length; +const nameUser = "Cristiane"; +const nameLength = nameUser.length; -let message = `My name is ${nameUser} and my name have ${nameLength -} characters long.`; - -console.log(message); +console.log(`My name is ${nameUser} and my name have ${nameLength +} characters long.`); //Prints: My name is Cristiane and my name have 12 characters long. From b1ae73fd0db78b2192db8876a685e1c0ce7e2d7a Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Feb 2022 18:15:19 +0100 Subject: [PATCH 035/117] correcting the variable of the L exercises --- .../Homework/L-functions-nested/exercise.js | 47 +++++++------------ 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/week-1/Homework/L-functions-nested/exercise.js b/week-1/Homework/L-functions-nested/exercise.js index 312e6343..1ff0bb4c 100644 --- a/week-1/Homework/L-functions-nested/exercise.js +++ b/week-1/Homework/L-functions-nested/exercise.js @@ -1,35 +1,24 @@ -var mentor1 = "Daniel"; -var mentor2 = "Irina"; -var mentor3 = "Mimi"; -var mentor4 = "Rob"; -var mentor5 = "Yohannes"; - -function uperCaseName (mentor){ - return `Hello ${mentor.toUpperCase()}` +const mentor1 = "Daniel"; +const mentor2 = "Irina"; +const mentor3 = "Mimi"; +const mentor4 = "Rob"; +const mentor5 = "Yohannes"; + +function mentors(mentor){ + const nameInUpperCase = mentor.toUpperCase(); + return nameInUpperCase; } +// segunda parte del ejercicio: -var greetings = uperCaseName(); - - /*If I call thr function, it will prints: -Hello DANIEL - Hello IRINA - Hello MIMI - Hello ROB - Hello YOHANNES */ - - //Second function - - -let shoutingOutLoud = greetings.toUpperCase(); - -function uperCaseName (mentor){ - return `Hello ${mentor1.toUpperCase()} -Hello ${mentor2.toUpperCase()} -Hello ${mentor3.toUpperCase()} -Hello ${mentor4.toUpperCase()} -Hello ${mentor5.toUpperCase()}` +function shoutingOutLoud (mentor){ + return `HELLO ${mentor.toUpperCase()}` } -console.log(shoutingOutLoud); + +console.log(shoutingOutLoud(mentor1)); +console.log(shoutingOutLoud(mentor2)); +console.log(shoutingOutLoud(mentor3)); +console.log(shoutingOutLoud(mentor4)); +console.log(shoutingOutLoud(mentor5)); /* prints: HELLO DANIEL From 2551b201ffa72f65726c965ee32577aba640f7b4 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 27 Feb 2022 16:29:04 +0100 Subject: [PATCH 036/117] changing the variable let to const --- week-1/Homework/F-strings-methods/exercise2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/week-1/Homework/F-strings-methods/exercise2.js b/week-1/Homework/F-strings-methods/exercise2.js index 05d71857..d8e21078 100644 --- a/week-1/Homework/F-strings-methods/exercise2.js +++ b/week-1/Homework/F-strings-methods/exercise2.js @@ -1,8 +1,8 @@ const nameUser = " Cristiane "; -let nameLength = nameUser.length; +const nameLength = nameUser.length; -let message = `My name is ${nameUser.trim()} and my name have ${nameLength +const message = `My name is ${nameUser.trim()} and my name have ${nameLength } characters long.`; console.log(message); From 595e1d0804b9449385341ad60bf1d00f74ee6cc4 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 27 Feb 2022 16:40:44 +0100 Subject: [PATCH 037/117] changing the var for let --- week-1/Homework/J-functions/exercise.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/week-1/Homework/J-functions/exercise.js b/week-1/Homework/J-functions/exercise.js index f7013056..defd07a4 100644 --- a/week-1/Homework/J-functions/exercise.js +++ b/week-1/Homework/J-functions/exercise.js @@ -3,13 +3,13 @@ function halve(number) { return number / 2; } -var result = halve(12); // prints 6 +let result = halve(12); // prints 6 -var result = halve(17); // print 8.5 +let result = halve(17); // print 8.5 -var result = halve(1287); //prints 643.5 +let result = halve(1287); //prints 643.5 -var result = halve(20); //prints 10 +let result = halve(20); //prints console.log(result); From e6a94907478588300a85ec7bf84aef4cf117faac Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 27 Feb 2022 16:40:52 +0100 Subject: [PATCH 038/117] changing the var for let --- week-1/Homework/J-functions/exercise2.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/week-1/Homework/J-functions/exercise2.js b/week-1/Homework/J-functions/exercise2.js index 6bb51505..0333c8df 100644 --- a/week-1/Homework/J-functions/exercise2.js +++ b/week-1/Homework/J-functions/exercise2.js @@ -3,12 +3,12 @@ function triple(number) { return number * 3; } -var result = triple(12); // prints 6 +let result = triple(12); // prints 6 -var result = triple(22); // prints 66 +let result = triple(22); // prints 66 -var result = triple(222); // prints 666 +let result = triple(222); // prints 666 -var result = triple(2222); // prints 6666 +let result = triple(2222); // prints 6666 console.log(result); From e134a6d4274fa424792d1017d8e0308a667a7f5f Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 27 Feb 2022 16:43:25 +0100 Subject: [PATCH 039/117] changing the var for const --- week-1/Homework/K-functions-parameters/exercise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-1/Homework/K-functions-parameters/exercise.js b/week-1/Homework/K-functions-parameters/exercise.js index 6f96d511..c35269da 100644 --- a/week-1/Homework/K-functions-parameters/exercise.js +++ b/week-1/Homework/K-functions-parameters/exercise.js @@ -5,6 +5,6 @@ function multiply(num1, num2) { } // Assign the result of calling the function the variable `result` -var result = multiply(3, 4); +const result = multiply(3, 4); console.log(result); // prints 12 From 61e6ed92cd18d9b019f5d141cae07d01483f402f Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 27 Feb 2022 16:44:04 +0100 Subject: [PATCH 040/117] changing the var for const --- week-1/Homework/K-functions-parameters/exercise2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-1/Homework/K-functions-parameters/exercise2.js b/week-1/Homework/K-functions-parameters/exercise2.js index df0504d1..36f4e306 100644 --- a/week-1/Homework/K-functions-parameters/exercise2.js +++ b/week-1/Homework/K-functions-parameters/exercise2.js @@ -3,6 +3,6 @@ function divide(num1, num2){ return num1 / num2; } -var result = divide(3, 4); +const result = divide(3, 4); console.log(result); // prints 0.75 From 0cc105e22bbf8a97017cb0bcebb00a4f898447a1 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 27 Feb 2022 16:45:52 +0100 Subject: [PATCH 041/117] changing the var for const and changing the name, adding a dot in the end of the sentence --- week-1/Homework/K-functions-parameters/exercise3.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/week-1/Homework/K-functions-parameters/exercise3.js b/week-1/Homework/K-functions-parameters/exercise3.js index 29810338..1928193b 100644 --- a/week-1/Homework/K-functions-parameters/exercise3.js +++ b/week-1/Homework/K-functions-parameters/exercise3.js @@ -1,8 +1,8 @@ // Write your function here function createGreeting(name){ - return `Hello, my name is ${name}`; + return `Hello, my name is ${name}.`; } -var greeting = createGreeting("Daniel"); +const greeting = createGreeting("Cristiane"); -console.log(greeting); // Prints: Hello, my name is Daniel +console.log(greeting); // Prints: Hello, my name is Cristiane. From de5c906f0935700c8a83bf0e940a44aecc6a5145 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 27 Feb 2022 17:16:41 +0100 Subject: [PATCH 042/117] updating the exercise --- week-1/InClass/ejercicio-sabado.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 week-1/InClass/ejercicio-sabado.js diff --git a/week-1/InClass/ejercicio-sabado.js b/week-1/InClass/ejercicio-sabado.js new file mode 100644 index 00000000..e3923dbc --- /dev/null +++ b/week-1/InClass/ejercicio-sabado.js @@ -0,0 +1,27 @@ +function resumen(texto) { + return texto.substring(0, 9); +} + +const resultadoTexto = resumen("Hola este es un texto de prueba"); + +console.log(resultadoTexto.slice(0,9)); // Recibimos el resultado: Hola este + +/* +console.log("hola esta es una prueba del slice".slice(1,3)); // printa ol +console.log("hola esta es una prueba del slice".substring(1,3)); // printa ol -- igual al .slice +console.log("hola esta es una prueba del slice".slice(0,9)); // printa hola esta +console.log("hola esta es una prueba del slice".substring(0,9)); // printa hol a esta --igual al .slice + +*/ + +// Second exercise + +function firstCapitalize(text){ + const firstChar = text.charAt(0); + const firstCharCapitalize = firstChar.toUpperCase(); + return firstCharCapitalize + text.slice(1); +} + +const resultadoEjercicioDos = firstCapitalize("mi mensagen bien escrito"); + +console.log(resultadoEjercicioDos); \ No newline at end of file From a039e6d1ec701bc6360f98b75aa39396a13d604c Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 27 Feb 2022 19:29:10 +0100 Subject: [PATCH 043/117] adding the correct answer about return statement --- week-1/InClass/exercise-H.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/week-1/InClass/exercise-H.js b/week-1/InClass/exercise-H.js index 7fd30ddc..8c63cd4d 100644 --- a/week-1/InClass/exercise-H.js +++ b/week-1/InClass/exercise-H.js @@ -10,8 +10,10 @@ console.log(randomNumbers) /* What's the difference between a return and console.log? - - the return is a way to get the type of the paramethers, modify it for some specific value and also to execute some extra work in action of the function. - - console.log - prints the result on the screen + - A return statement ends the execution of a function, and returns control to the calling function. + Execution resumes in the calling function at the point immediately following the call. + A return statement can return a value to the calling function. + - console.log - prints the result on the screen When would you choose to use functions over the way we have been scripting so far? From 99d9432e241ba8d2db41395d8693824a626c5ac3 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Thu, 3 Mar 2022 13:13:01 +0100 Subject: [PATCH 044/117] adding the exercise A inclass --- week-2/InClass/exercise-A.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/week-2/InClass/exercise-A.js b/week-2/InClass/exercise-A.js index e69de29b..b8fcd605 100644 --- a/week-2/InClass/exercise-A.js +++ b/week-2/InClass/exercise-A.js @@ -0,0 +1,9 @@ +// on VS CODE TERMINAL ( NODE REPL) + +1 + 2 // prints 3; + +"hello" // prints 'hello' + +let favoriteColour = "purple" ; // prints undefined - it means it is not showed on screen + +console.log(favoriteColour) // prints purple - undefined From 92383cce7bc0bb3659781ad8b6ed9eee55492a22 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Thu, 3 Mar 2022 13:49:37 +0100 Subject: [PATCH 045/117] adding the exercise B to week 2 --- week-2/InClass/exercise-B.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/week-2/InClass/exercise-B.js b/week-2/InClass/exercise-B.js index 30864992..48775f2f 100644 --- a/week-2/InClass/exercise-B.js +++ b/week-2/InClass/exercise-B.js @@ -1,9 +1,20 @@ function boolChecker(bool) { - if (typeof bool === ) { + const boolChecker = 'boolean'; + + if (typeof bool === bool) { return "You've given me a bool, thanks!"; } - return "No bool, not cool."; } -boolChecker(true); \ No newline at end of file +console.log(boolChecker()); // prints : Not bool, not cool + +/* +Node REPL: + +1- In a node REPL, what is the typeof a true or false? + The type of true and false are both 'boolean' - primitive type + +*/ + +// FALTA CORRIGIR, ESTA DANDO ERRADO From 557a76cb7c424627410da11d8f0c3eb37f4a4993 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Thu, 3 Mar 2022 15:19:47 +0100 Subject: [PATCH 046/117] exercise B completed, and answer for the questions added as coments --- week-2/InClass/exercise-B.js | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/week-2/InClass/exercise-B.js b/week-2/InClass/exercise-B.js index 48775f2f..6f8926a7 100644 --- a/week-2/InClass/exercise-B.js +++ b/week-2/InClass/exercise-B.js @@ -1,13 +1,12 @@ function boolChecker(bool) { - const boolChecker = 'boolean'; - if (typeof bool === bool) { + if (typeof bool === "boolean") { return "You've given me a bool, thanks!"; } return "No bool, not cool."; } -console.log(boolChecker()); // prints : Not bool, not cool +console.log(boolChecker(true)); // prints : You've given me a bool, thanks! /* Node REPL: @@ -15,6 +14,25 @@ Node REPL: 1- In a node REPL, what is the typeof a true or false? The type of true and false are both 'boolean' - primitive type -*/ +1.1 - As a class, can you step through the function and explain what each line does? + + +LINE 1 <---- ginving a name to a function and adding parameter to the function + +LINE 3 <---- IF the type of the parameter (bool ) is exactly like a boolean ( primitive type that is both trye or false) + +LINE 4 <---- It will return the message: You've given me a bool, thanks! + +LINE 5 <----- IF the type of the parameter isnt a boolean ( can be number / string / objetc, etc), + it will return : No bool, not cool -// FALTA CORRIGIR, ESTA DANDO ERRADO + +LINE 9 <----- We print to the console throught the command console.log, calling the funcion inside the parentheses. + inserting as an argument one of the results of a boolean to confirm if match or now in our funcion. + + As a result checked on Node REPL, it prints + +console.log(boolChecker(true)); // prints: You've given me a bool, thanks! + + +*/ From 1e9543b3b7d95e9660718bf46ffdca70b8d95719 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Thu, 3 Mar 2022 15:36:13 +0100 Subject: [PATCH 047/117] exercise B completed, and answer for the questions added as coments --- week-2/InClass/exercise-B.js | 13 ++++++----- week-2/InClass/exercise-C.js | 42 +++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/week-2/InClass/exercise-B.js b/week-2/InClass/exercise-B.js index 6f8926a7..88fc630a 100644 --- a/week-2/InClass/exercise-B.js +++ b/week-2/InClass/exercise-B.js @@ -17,18 +17,21 @@ Node REPL: 1.1 - As a class, can you step through the function and explain what each line does? -LINE 1 <---- ginving a name to a function and adding parameter to the function +LINE 1 <---- START: giving a name to a function (boolChecker )and adding parameter to the name function (bool) -LINE 3 <---- IF the type of the parameter (bool ) is exactly like a boolean ( primitive type that is both trye or false) +LINE 3 <---- IF the type of the parameter (bool) is exactly like a boolean ( primitive type that is both trye or false), -LINE 4 <---- It will return the message: You've given me a bool, thanks! +LINE 4 <---- it will return the message: You've given me a bool, thanks! LINE 5 <----- IF the type of the parameter isnt a boolean ( can be number / string / objetc, etc), - it will return : No bool, not cool + +LINE 6 <----- it will return : No bool, not cool. + +LINE 7 <----- End of the funcion. LINE 9 <----- We print to the console throught the command console.log, calling the funcion inside the parentheses. - inserting as an argument one of the results of a boolean to confirm if match or now in our funcion. + inserting as an argument after the name of the funcion inside another parentheses, one of the results of a boolean to confirm if match or now in our funcion. As a result checked on Node REPL, it prints diff --git a/week-2/InClass/exercise-C.js b/week-2/InClass/exercise-C.js index ee280d79..d2916b47 100644 --- a/week-2/InClass/exercise-C.js +++ b/week-2/InClass/exercise-C.js @@ -8,4 +8,44 @@ function numberChecker(num) { } else { return `${num} isn't even a number :(`; } -} \ No newline at end of file +} + +console.log(numberChecker("name")) + + +/* +Can you explain what this function does line by line? + What happens when you pass in a string? + + LINE 1 <---- Start: giving a name to a function (numberChecker) and adding a parameter to this namefunction (num); + + LINE 2 <---- If the parameter (num) is greater than 20, + + LINE 3 <----- it will return the message: (num) is greater than 20; + + LINE 4 <----- Else if the parameter (num) is equal type and value than 20, + + LINE 5 <----- it will return the message: (num)is greater than 20; + + LINE 6 <----- Else if the parameter (num) is less than 20, + + LINE 7 <----- it will return the message: (num)is less than 20; + + LINE 8 <----- Else the parameter (num) isnot a number ( string, object, etc), + + LINE 9 <----- it will return the message: (num)is not even a number :'(; + + LINE 11 <----- End of the funcion. + + LINE 13 <----- We print to the console throught the command console.log, calling the funcion inside the parentheses. + inserting as an argument what we need to know it matches with one of the conditions of the function. + + As a result checked on Node REPL, it prints + + + + + + +*/ + From 4340924963de034e67f002fae1548447974bddf1 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Thu, 3 Mar 2022 15:36:31 +0100 Subject: [PATCH 048/117] exercise C completed, and answer for the questions added as coments --- week-2/InClass/exercise-C.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/week-2/InClass/exercise-C.js b/week-2/InClass/exercise-C.js index d2916b47..a519e147 100644 --- a/week-2/InClass/exercise-C.js +++ b/week-2/InClass/exercise-C.js @@ -41,6 +41,8 @@ Can you explain what this function does line by line? inserting as an argument what we need to know it matches with one of the conditions of the function. As a result checked on Node REPL, it prints + + name isn't even a number :( From 824eeee7e205ae7e15bbdc1af6c58e331dd5362d Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Thu, 3 Mar 2022 15:39:00 +0100 Subject: [PATCH 049/117] exercise D completed --- week-2/InClass/exercise-D.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/week-2/InClass/exercise-D.js b/week-2/InClass/exercise-D.js index e69de29b..69b8bad2 100644 --- a/week-2/InClass/exercise-D.js +++ b/week-2/InClass/exercise-D.js @@ -0,0 +1,13 @@ +function moodOfTheDay(mood){ + if (mood === "happy"){ + return "Good job, you're doing great!" + } else if (mood === "sad"){ + return "Every cloud has a silver lining" + } else if (typeof mood === "number"){ + return "Beep beep boop" + } else { + return "I'm sorry, I'm still learning about feelings!" + } +} + +console.log(moodOfTheDay(1980)); // it prints: Beep beep boo \ No newline at end of file From 49cc7bb4ec62c1ec566428616cc2ee91ac9c3b16 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Thu, 3 Mar 2022 15:41:20 +0100 Subject: [PATCH 050/117] exercise E completed and the answer added to the comments --- week-2/InClass/exercise-E.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/week-2/InClass/exercise-E.js b/week-2/InClass/exercise-E.js index e69de29b..e0556e56 100644 --- a/week-2/InClass/exercise-E.js +++ b/week-2/InClass/exercise-E.js @@ -0,0 +1,8 @@ +let num = 10 +num > 5 && num < 15; //true +num < 10 || num === 10; // true; +false || true; // true; +!true // false +let greaterThan 5 = num > 5 // true; +!greaterThan5 /* ! implica lo contrario - falso; */ +!(num === 10); /* ! implica lo comtrario - falso; */ From 5c399de1c43e1499d43e8079d0fc0894935adce9 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Thu, 3 Mar 2022 15:57:34 +0100 Subject: [PATCH 051/117] exercise F completed --- week-2/InClass/exercise-F.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/week-2/InClass/exercise-F.js b/week-2/InClass/exercise-F.js index e69de29b..8bdda7cd 100644 --- a/week-2/InClass/exercise-F.js +++ b/week-2/InClass/exercise-F.js @@ -0,0 +1,15 @@ + +function validName(username,type ) { + const firstLetter = username.charAt(0); + const userLenght = username.Lenght; + const isValidLength = userLenght >= 5 && userLenght <=10; + const isASuperType = type === "admin" || type ==="manager"; + + if ( isASuperType || ( firstLetter === firstLetter.toUpperCase() && isValidLength ) ){ + return "Username Valid" + } else { + return "Username invalid"; + } +} + +console.log(validName("Critiane", "admin")); //it prints: Username Valid \ No newline at end of file From 9d1d8cf749d6e660a3823ec1541eb5be29f0a9df Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Thu, 3 Mar 2022 16:11:55 +0100 Subject: [PATCH 052/117] correcting an incorrect space on the exercise --- week-2/InClass/exercise-E.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-2/InClass/exercise-E.js b/week-2/InClass/exercise-E.js index e0556e56..84390a25 100644 --- a/week-2/InClass/exercise-E.js +++ b/week-2/InClass/exercise-E.js @@ -3,6 +3,6 @@ num > 5 && num < 15; //true num < 10 || num === 10; // true; false || true; // true; !true // false -let greaterThan 5 = num > 5 // true; +let greaterThan5 = num > 5; // true; !greaterThan5 /* ! implica lo contrario - falso; */ !(num === 10); /* ! implica lo comtrario - falso; */ From 4cc96ca112085072e1363cfcdf3d40401f77ddfa Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Thu, 3 Mar 2022 16:15:06 +0100 Subject: [PATCH 053/117] adding the exercise G --- week-2/InClass/exercise-G.js | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/week-2/InClass/exercise-G.js b/week-2/InClass/exercise-G.js index efbb01e2..1f40dbef 100644 --- a/week-2/InClass/exercise-G.js +++ b/week-2/InClass/exercise-G.js @@ -1,4 +1,28 @@ -var apolloCountdownMessage = "all engine running... LIFT-OFF!"; -var countdown = 8; +const apolloCountdownMessage = "all engine running... LIFT-OFF!"; + + +let countdown = 8; + +while (countdown >= 0){ + console.log(countdown); + countdown-- ; +} + +console.log(apolloCountdownMessage); + + +/* Prints + +8 +7 +6 +5 +4 +3 +2 +1 +0 +all engine running... LIFT-OFF! + +*/ -console.log(apolloCountdownMessage); \ No newline at end of file From 306959c9376e142c29914f88e759ba7d2233a3e5 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 15:19:28 +0100 Subject: [PATCH 054/117] adding the exercise-H - Still need to correct --- week-2/InClass/exercise-H.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/week-2/InClass/exercise-H.js b/week-2/InClass/exercise-H.js index 1a1bef7b..2166e9c2 100644 --- a/week-2/InClass/exercise-H.js +++ b/week-2/InClass/exercise-H.js @@ -1,7 +1,35 @@ +// function exponential(number) { +// return number * number; +// } + +// function isEven(number) { +// return number % 2 === 0; +// } + +// + function exponential(number) { return number * number; } function isEven(number) { return number % 2 === 0; -} \ No newline at end of file +} + +for (let i = 5; i < 20; i++){ + console.log(`The exponential of ${isEven()} is ${exponential()}`) + isEven = isEven + 2; +} + +/* +Prints + +The exponential of true is 36 +The exponential of true is 36 +The exponential of true is 36 +The exponential of true is 36 +The exponential of true is 36 +The exponential of true is 36 +The exponential of true is 36 +The exponential of true is 36 +*/ \ No newline at end of file From fe5fda0074cf353206e571a803aa0e60a9842ad4 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 15:44:59 +0100 Subject: [PATCH 055/117] adding exercise H correcto --- week-2/InClass/exercise-H.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/week-2/InClass/exercise-H.js b/week-2/InClass/exercise-H.js index 2166e9c2..32a8975e 100644 --- a/week-2/InClass/exercise-H.js +++ b/week-2/InClass/exercise-H.js @@ -9,27 +9,35 @@ // function exponential(number) { - return number * number; + return number * number; // o number **2 } function isEven(number) { return number % 2 === 0; } -for (let i = 5; i < 20; i++){ - console.log(`The exponential of ${isEven()} is ${exponential()}`) - isEven = isEven + 2; +// for (let i = 5; i < 20; i++){ +// console.log(`The exponential of ${isEven()} is ${exponential()}`) +// isEven = isEven + 2; +// } + +for ( let number = 5; number < 20; number++ ) { // o 20 < number + if (isEven(number)){ + console.log(`The exponencial of ${number} is ${exponential(number)}`); + + + } } /* Prints -The exponential of true is 36 -The exponential of true is 36 -The exponential of true is 36 -The exponential of true is 36 -The exponential of true is 36 -The exponential of true is 36 -The exponential of true is 36 -The exponential of true is 36 +The exponencial of 6 is 36 +The exponencial of 8 is 64 +The exponencial of 10 is 100 +The exponencial of 12 is 144 +The exponencial of 14 is 196 +The exponencial of 16 is 256 +The exponencial of 18 is 324 + */ \ No newline at end of file From a301469170bdeb4d470bb365dd14226cc49a8ca4 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 16:02:49 +0100 Subject: [PATCH 056/117] adding the exercise I with comments --- week-2/InClass/exercise-I.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/week-2/InClass/exercise-I.js b/week-2/InClass/exercise-I.js index e69de29b..42bd53b0 100644 --- a/week-2/InClass/exercise-I.js +++ b/week-2/InClass/exercise-I.js @@ -0,0 +1,28 @@ +const fruits = ['banana', 'apple', 'strawberry', 'kiwi', 'fig', 'orange']; + +console.log( fruits[2]) +console.log( fruits[3]) +console.log( fruits[5]) +console.log( fruits[0]) +console.log( fruits[2]) + +/* prints: + +strawberry +kiwi +orange +banana +strawberry + +*/ + +fruits[1] = "rapberry" +fruits[4] = " pineapple" + +console.log(fruits); + +/* it prints: + +[ 'banana', 'rapberry', 'strawberry', 'kiwi', ' pineapple', 'orange' ] + +*/ \ No newline at end of file From bb643de082b7f5974edfa2483a0332e282f52fd1 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 16:10:58 +0100 Subject: [PATCH 057/117] adding the exercise-J with comments --- week-2/InClass/exercise-J.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/week-2/InClass/exercise-J.js b/week-2/InClass/exercise-J.js index 1c14afe9..e7044e94 100644 --- a/week-2/InClass/exercise-J.js +++ b/week-2/InClass/exercise-J.js @@ -1,6 +1,20 @@ + +/* + +Complete this function so that, +if the second index in the array contains the name "Amy", + it returns "Second index matched!" + +*/ + +const people = ["Cristiane", "Juliana", "Amy", "Jorge", "Luis"] + function secondMatchesAmy(array) { - if ( ) { + if ( array[2] === "Amy") { return "Second index matched!"; } return "Second index not matched"; -} \ No newline at end of file +} + console.log(secondMatchesAmy(people)); + + // printa: Second index matched! \ No newline at end of file From 30db63379723ce20cfbcea97f3f3315eecd9b7c2 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 16:38:26 +0100 Subject: [PATCH 058/117] adding exercise K with the comments --- week-2/InClass/exercise-K.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/week-2/InClass/exercise-K.js b/week-2/InClass/exercise-K.js index e69de29b..51460046 100644 --- a/week-2/InClass/exercise-K.js +++ b/week-2/InClass/exercise-K.js @@ -0,0 +1,20 @@ +const students = [ "Cris", "Jane", "Lucas", "Fabricio", "Juan", "Gabriel"] + + + for ( let i = 0; i < students.length ; i++ ){ + const nameofStudent = students[i] + console.log(nameofStudent) + } + + /* + + Prints: + +Cris +Jane +Lucas +Fabricio +Juan +Gabriel + + */ \ No newline at end of file From 57e322c35d700a24cbd24f1f2184a3cbf9b2ba33 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 16:49:23 +0100 Subject: [PATCH 059/117] adding the exercise C --- week-2/Homework/C-comparison-operators/exercise.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/week-2/Homework/C-comparison-operators/exercise.js b/week-2/Homework/C-comparison-operators/exercise.js index 58aee1c5..801b3158 100644 --- a/week-2/Homework/C-comparison-operators/exercise.js +++ b/week-2/Homework/C-comparison-operators/exercise.js @@ -7,14 +7,14 @@ var studentCount = 16; var mentorCount = 9; -var moreStudentsThanMentors; // finish this statement +var moreStudentsThanMentors = studentCount > mentorCount;// finish this statement var roomMaxCapacity = 25; -var enoughSpaceInRoom; // finish this statement +var enoughSpaceInRoom = roomMaxCapacity >= (studentCount + mentorCount);// finish this statement var personA = "Daniel"; var personB = "Irina"; -var sameName; // finish this statement +var sameName = personA === personB; // finish this statement /* DO NOT EDIT BELOW THIS LINE From 4bf61b758c302da8420a9c46dc71050fb202198f Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 16:56:49 +0100 Subject: [PATCH 060/117] adding the exercise homework E --- week-2/Homework/E-conditionals/exercise.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/week-2/Homework/E-conditionals/exercise.js b/week-2/Homework/E-conditionals/exercise.js index acbaaa8e..347a9b3d 100644 --- a/week-2/Homework/E-conditionals/exercise.js +++ b/week-2/Homework/E-conditionals/exercise.js @@ -9,6 +9,12 @@ var name = "Daniel"; var danielsRole = "mentor"; +if(danielsRole === "mentor"){ + console.log("Hi, I'm " + name + ", I'm a mentor.") +} else { + console.log("Hi, I'm " + name + ", I'm a student.") +} + /* EXPECTED RESULT --------------- From 0903a5ed155908436d803d9f1f3d800941ba235f Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 17:02:30 +0100 Subject: [PATCH 061/117] adding exercise homework F --- week-2/Homework/F-logical-operators/exercise.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/week-2/Homework/F-logical-operators/exercise.js b/week-2/Homework/F-logical-operators/exercise.js index a8f2945b..3b0b5688 100644 --- a/week-2/Homework/F-logical-operators/exercise.js +++ b/week-2/Homework/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 = htmlLevel >= 5; +var cssLevelAbove5 = cssLevel >=5; // Finish the next two statement // Use the previous variables and logical operators // Do not "hardcode" the answers -var cssAndHtmlAbove5; -var cssOrHtmlAbove5; +var cssAndHtmlAbove5 = htmlLevelAbove5 && cssLevelAbove5; +var cssOrHtmlAbove5 = htmlLevelAbove5 || cssLevelAbove5; /* DO NOT EDIT BELOW THIS LINE From 3380079a3d3e566ddcffb90a03c5fc34f1225065 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 17:03:28 +0100 Subject: [PATCH 062/117] adding exercise homework F --- week-2/Homework/F-logical-operators/exercise.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/week-2/Homework/F-logical-operators/exercise.js b/week-2/Homework/F-logical-operators/exercise.js index 3b0b5688..90469cac 100644 --- a/week-2/Homework/F-logical-operators/exercise.js +++ b/week-2/Homework/F-logical-operators/exercise.js @@ -11,8 +11,8 @@ var cssLevel = 4; // Finish the statement to check whether HTML, CSS knowledge are above 5 // (hint: use the comparison operator from before) -var htmlLevelAbove5 = htmlLevel >= 5; -var cssLevelAbove5 = cssLevel >=5; +var htmlLevelAbove5 = htmlLevel > 5; +var cssLevelAbove5 = cssLevel > 5; // Finish the next two statement // Use the previous variables and logical operators From a4ead1c56b9632fc7c8d06b46cade4ea7e301eb0 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 17:35:25 +0100 Subject: [PATCH 063/117] adding exercise1 to homework G --- week-2/Homework/G-conditionals-2/exercise-1.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/week-2/Homework/G-conditionals-2/exercise-1.js b/week-2/Homework/G-conditionals-2/exercise-1.js index 54708ef6..f19357b4 100644 --- a/week-2/Homework/G-conditionals-2/exercise-1.js +++ b/week-2/Homework/G-conditionals-2/exercise-1.js @@ -7,7 +7,9 @@ */ function negativeOrPositive(number) { - + if (number >= 0){ + return "positive" + } return "negative" } /* From e189e67077058ed9d249a57c82a77d674228b498 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 17:39:40 +0100 Subject: [PATCH 064/117] adding exercise 2 of homework G --- week-2/Homework/G-conditionals-2/exercise-2.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/week-2/Homework/G-conditionals-2/exercise-2.js b/week-2/Homework/G-conditionals-2/exercise-2.js index 313f3fb2..1d3f59ca 100644 --- a/week-2/Homework/G-conditionals-2/exercise-2.js +++ b/week-2/Homework/G-conditionals-2/exercise-2.js @@ -9,6 +9,12 @@ function studentPassed(grade) { + if (grade < 50){ + return "failed" + } else {(grade > 50 ) + return "passed" + } + } /* From cad8ca171e93ba97104d776ff7d7db8a3ee59ef0 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 17:47:33 +0100 Subject: [PATCH 065/117] adding the exercise-3 of homework G --- week-2/Homework/G-conditionals-2/exercise-3.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/week-2/Homework/G-conditionals-2/exercise-3.js b/week-2/Homework/G-conditionals-2/exercise-3.js index a79cf30e..574ba082 100644 --- a/week-2/Homework/G-conditionals-2/exercise-3.js +++ b/week-2/Homework/G-conditionals-2/exercise-3.js @@ -9,7 +9,13 @@ */ function calculateGrade(mark) { - +if (mark < 50 ){ + return "F" +}else if ( mark <= 50 && mark <= 60){ + return "C" +} else if (mark > 60 && mark < 80){ + return "B" +} return "A" } /* @@ -18,7 +24,7 @@ DO NOT EDIT BELOW THIS LINE var grade1 = 49; var grade2 = 90; var grade3 = 70; -var grade4 = 55; +var grade4 = 50; console.log("'" + grade1 + "': " + calculateGrade(grade1)); console.log("'" + grade2 + "': " + calculateGrade(grade2)); From 9cfc0770edd861f635300080c85350ecea03d170 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 17:57:07 +0100 Subject: [PATCH 066/117] adding the exercise 4 of the homework G --- week-2/Homework/G-conditionals-2/exercise-4.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/week-2/Homework/G-conditionals-2/exercise-4.js b/week-2/Homework/G-conditionals-2/exercise-4.js index bd5bb1ef..d6535ce1 100644 --- a/week-2/Homework/G-conditionals-2/exercise-4.js +++ b/week-2/Homework/G-conditionals-2/exercise-4.js @@ -6,11 +6,14 @@ - otherwise return false Hint: Google how to check if a string contains a word + + podemos utilizar o methodo includes() + */ function containsCode(sentence) { - -} + return sentence.includes('code') +} /* DO NOT EDIT BELOW THIS LINE From e87769b367c30802978470c6203f61a6f926e66e Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 18:00:13 +0100 Subject: [PATCH 067/117] adding the exercise H of the homework --- week-2/Homework/H-array-literals/exercise.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/week-2/Homework/H-array-literals/exercise.js b/week-2/Homework/H-array-literals/exercise.js index d6dc556a..97469b4a 100644 --- a/week-2/Homework/H-array-literals/exercise.js +++ b/week-2/Homework/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 = [0,1,2,3,4,5,6,7,8,9,10]; // add numbers from 1 to 10 into this array +var mentors = ['Daniel', 'Irina', 'Rares']; // Create an array with the names of the mentors: Daniel, Irina and Rares /* DO NOT EDIT BELOW THIS LINE From 51d72f1d4ac5788762d6b52239424cdf2aa84158 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 18:18:07 +0100 Subject: [PATCH 068/117] adding exercise I homework --- week-2/Homework/I-array-properties/exercise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-2/Homework/I-array-properties/exercise.js b/week-2/Homework/I-array-properties/exercise.js index f9aec89f..a2280a89 100644 --- a/week-2/Homework/I-array-properties/exercise.js +++ b/week-2/Homework/I-array-properties/exercise.js @@ -6,7 +6,7 @@ */ function isEmpty(arr) { - return; // complete this statement + return arr.length === 0; // complete this statement } /* From 85e11b380a0d8de5ef9f28812b2106406b1f9131 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 18:36:50 +0100 Subject: [PATCH 069/117] adding the exercise L of the homework --- week-2/Homework/L-for-loop/exercise.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/week-2/Homework/L-for-loop/exercise.js b/week-2/Homework/L-for-loop/exercise.js index 151a60da..c1656989 100644 --- a/week-2/Homework/L-for-loop/exercise.js +++ b/week-2/Homework/L-for-loop/exercise.js @@ -10,6 +10,28 @@ let n = 10; function sumTillNum(num){ //your code here + let suma = [] + for (let counter = 0; counter <= num; counter++){ + suma.push(counter) + } + return suma.toString().replace(/,/g,"+") } console.log("Sum from 0 to " + n + " is: " + sumTillNum(n)); + +// prints: Sum from 0 to 10 is: 0+1+2+3+4+5+6+7+8+9+10 + + + +function sumTillNum(num){ + //your code here + let suma = 0; + for (let counter = 0; counter <= num; counter++){ + suma = suma + counter; // o suma += counter; + } + return suma +} + +console.log("Sum from 0 to " + n + " is: " + sumTillNum(n)); + +//prints: Sum from 0 to 10 is: 55 \ No newline at end of file From 5e979d951a8167459496dbd18775a7a9de12b59c Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 18:57:38 +0100 Subject: [PATCH 070/117] adding exercise M to the homework --- week-2/Homework/M-array-loop/exercise.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/week-2/Homework/M-array-loop/exercise.js b/week-2/Homework/M-array-loop/exercise.js index b79956a5..34e355e2 100644 --- a/week-2/Homework/M-array-loop/exercise.js +++ b/week-2/Homework/M-array-loop/exercise.js @@ -4,6 +4,17 @@ */ +function getDaysStartingWithT(array){ + + for (let i=0; i < array.length; i++){ + const day = array[i]; + if (day.startsWith('T')){ + console.log(day) + } + } + +} + const daysOfWeek = [ "Monday", "Tuesday", @@ -12,4 +23,6 @@ const daysOfWeek = [ "Friday", "Saturday", "Sunday", -]; \ No newline at end of file +]; + +const result = getDaysStartingWithT(daysOfWeek) From 468a6f7ab53f6dcc67bc5599a887577c659725e5 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 5 Mar 2022 19:03:47 +0100 Subject: [PATCH 071/117] adding the exercise K of the homework --- week-2/Homework/K-while-loop/exercise.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/week-2/Homework/K-while-loop/exercise.js b/week-2/Homework/K-while-loop/exercise.js index c5662fe0..a44465c7 100644 --- a/week-2/Homework/K-while-loop/exercise.js +++ b/week-2/Homework/K-while-loop/exercise.js @@ -10,6 +10,13 @@ let n = 10; function sumTillNum(num){ //your code here + let counter = 0; + let result = 0; + while ( counter <=num){ + result += counter; + counter ++; + } + return result; } console.log("Sum from 0 to " + n + " is: " + sumTillNum(n)); From f196aef322d06b69adbb0557585a60c1e1217cd7 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 6 Mar 2022 17:12:37 +0100 Subject: [PATCH 072/117] adding the exercise 2 of homework J --- week-2/Homework/J-array-get-set/exercises2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/week-2/Homework/J-array-get-set/exercises2.js b/week-2/Homework/J-array-get-set/exercises2.js index 97f126f3..d200c532 100644 --- a/week-2/Homework/J-array-get-set/exercises2.js +++ b/week-2/Homework/J-array-get-set/exercises2.js @@ -8,6 +8,8 @@ var numbers = [1, 2, 3]; // Don't change this array literal declaration +numbers[3] = 4 + /* DO NOT EDIT BELOW THIS LINE --------------------------- */ @@ -16,5 +18,5 @@ console.log(numbers); /* EXPECTED RESULT --------------- - [1, 2, 3, 4] + [1, 2, 3, 4] */ From 166ab04e0d7021ffe0b3bd60bf494655efa89227 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 6 Mar 2022 20:40:13 +0100 Subject: [PATCH 073/117] adding the exercise L of the Homework --- week-2/Homework/L-for-loop/exercise.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/week-2/Homework/L-for-loop/exercise.js b/week-2/Homework/L-for-loop/exercise.js index c1656989..3c5912e3 100644 --- a/week-2/Homework/L-for-loop/exercise.js +++ b/week-2/Homework/L-for-loop/exercise.js @@ -8,6 +8,8 @@ let n = 10; +/* + function sumTillNum(num){ //your code here let suma = [] @@ -21,7 +23,7 @@ console.log("Sum from 0 to " + n + " is: " + sumTillNum(n)); // prints: Sum from 0 to 10 is: 0+1+2+3+4+5+6+7+8+9+10 - +*/ function sumTillNum(num){ //your code here From 5bac25d2f9f791623f0d3ef55cbaf5b6e5f942ad Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 6 Mar 2022 20:41:49 +0100 Subject: [PATCH 074/117] adding exercise M to the homework --- week-2/Homework/M-array-loop/exercise.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/week-2/Homework/M-array-loop/exercise.js b/week-2/Homework/M-array-loop/exercise.js index 34e355e2..a8d7a2e5 100644 --- a/week-2/Homework/M-array-loop/exercise.js +++ b/week-2/Homework/M-array-loop/exercise.js @@ -25,4 +25,12 @@ const daysOfWeek = [ "Sunday", ]; -const result = getDaysStartingWithT(daysOfWeek) +getDaysStartingWithT(daysOfWeek) + + /* prints: + + Tuesday +Thursday + + +*/ \ No newline at end of file From 6a796c5c553a9281f003f820b0e868183fbf8165 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 6 Mar 2022 20:43:20 +0100 Subject: [PATCH 075/117] adding exercise K of the homework --- week-2/Homework/K-while-loop/exercise.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/week-2/Homework/K-while-loop/exercise.js b/week-2/Homework/K-while-loop/exercise.js index a44465c7..e0792dd9 100644 --- a/week-2/Homework/K-while-loop/exercise.js +++ b/week-2/Homework/K-while-loop/exercise.js @@ -20,3 +20,6 @@ function sumTillNum(num){ } console.log("Sum from 0 to " + n + " is: " + sumTillNum(n)); + + +// Prints: Sum from 0 to 10 is: 55 \ No newline at end of file From 663cffcb5a2fb83fe0d553d92ac058a9ab2b8177 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 6 Mar 2022 20:44:59 +0100 Subject: [PATCH 076/117] adding the exercise H of the homwork --- week-2/Homework/H-array-literals/exercise.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/week-2/Homework/H-array-literals/exercise.js b/week-2/Homework/H-array-literals/exercise.js index 97469b4a..63acfce9 100644 --- a/week-2/Homework/H-array-literals/exercise.js +++ b/week-2/Homework/H-array-literals/exercise.js @@ -13,7 +13,11 @@ var mentors = ['Daniel', 'Irina', 'Rares']; // Create an array with the names of console.log(numbers); console.log(mentors); -/* + + +/* prints : + + EXPECTED RESULT --------------- [1,2,3,4,5,6,7,8,9,10] From 62fee7c92d0f6016b675e9e663b0a6dcd0c482d6 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 6 Mar 2022 20:53:31 +0100 Subject: [PATCH 077/117] adding the exercise2 to F homework --- .../Homework/F-logical-operators/exercise2.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/week-2/Homework/F-logical-operators/exercise2.js b/week-2/Homework/F-logical-operators/exercise2.js index fcc99247..e65bb652 100644 --- a/week-2/Homework/F-logical-operators/exercise2.js +++ b/week-2/Homework/F-logical-operators/exercise2.js @@ -5,7 +5,27 @@ Update the code so that you get the expected result. */ -function isNegative() {} +function isNegative(number) { + return number < 0 +} +function isBetween5and10(number){ + return number >= 5 && number <=10 +} + +//nombre corto es hasta 6 caracteres? + +function isShortName(person){ + let nameLength = person.length; + return nameLength <= 6 +} + +function startsWithD(personName){ + let firstCharacter = personName[0] + return firstCharacter === "D" + +} + + /* DO NOT EDIT BELOW THIS LINE From 29e3754d3f413a081632a8fc4ebae6d777810639 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 6 Mar 2022 21:42:46 +0100 Subject: [PATCH 078/117] adding the comment for exercise E --- week-2/Homework/E-conditionals/exercise.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/week-2/Homework/E-conditionals/exercise.js b/week-2/Homework/E-conditionals/exercise.js index 347a9b3d..0a285dd3 100644 --- a/week-2/Homework/E-conditionals/exercise.js +++ b/week-2/Homework/E-conditionals/exercise.js @@ -16,6 +16,9 @@ if(danielsRole === "mentor"){ } /* + +Prints: + EXPECTED RESULT --------------- Hi, I'm Daniel, I'm a mentor. From 9c484a1129d4a0595c6a0f0f191fe4a77c7d2781 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 6 Mar 2022 22:19:21 +0100 Subject: [PATCH 079/117] adding the first exercise of J homework --- week-2/Homework/J-array-get-set/exercise.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/week-2/Homework/J-array-get-set/exercise.js b/week-2/Homework/J-array-get-set/exercise.js index 3b95694e..6f15d4c0 100644 --- a/week-2/Homework/J-array-get-set/exercise.js +++ b/week-2/Homework/J-array-get-set/exercise.js @@ -5,11 +5,12 @@ */ function first(arr) { - return; // complete this statement + return arr[0]; // complete this statement } + function last(arr) { - return; // complete this statement + return arr[arr.length -1]; // complete this statement } /* @@ -22,7 +23,8 @@ console.log(first(numbers)); console.log(last(numbers)); console.log(last(names)); -/* +/* Prints: + EXPECTED RESULT --------------- 1 From a8c8aad001c697293c079e7cf1e63748bbba4d6e Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 6 Mar 2022 22:36:03 +0100 Subject: [PATCH 080/117] correcting the Inclass exercise H - some paramethers needed to be excluded --- week-2/InClass/exercise-H.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/week-2/InClass/exercise-H.js b/week-2/InClass/exercise-H.js index 32a8975e..4a55399f 100644 --- a/week-2/InClass/exercise-H.js +++ b/week-2/InClass/exercise-H.js @@ -1,12 +1,4 @@ -// function exponential(number) { -// return number * number; -// } -// function isEven(number) { -// return number % 2 === 0; -// } - -// function exponential(number) { return number * number; // o number **2 @@ -16,11 +8,6 @@ function isEven(number) { return number % 2 === 0; } -// for (let i = 5; i < 20; i++){ -// console.log(`The exponential of ${isEven()} is ${exponential()}`) -// isEven = isEven + 2; -// } - for ( let number = 5; number < 20; number++ ) { // o 20 < number if (isEven(number)){ console.log(`The exponencial of ${number} is ${exponential(number)}`); From 6665338a29df54accdcbfff1c288ce16ff19066c Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Thu, 10 Mar 2022 18:29:33 +0100 Subject: [PATCH 081/117] adding exercise-A Inclass --- week-3/InClass/exercise-A.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/week-3/InClass/exercise-A.js b/week-3/InClass/exercise-A.js index e69de29b..0f7fb5ae 100644 --- a/week-3/InClass/exercise-A.js +++ b/week-3/InClass/exercise-A.js @@ -0,0 +1,18 @@ +let peopleOnMyTable = ["Cristiane", "Rosangela", "Marina"]; + +console.log(peopleOnMyTable, peopleOnMyTable.length); + +// prints : + +// 'Cristiane', 'Rosangela', 'Marina' ] 3 + +peopleOnMyTable.unshift("Felix"); // Añade el nombre al inicio del array +peopleOnMyTable.push('SomeoneElse') // Añade el nombre al final del Array + + +console.log(peopleOnMyTable); + +// prints : + +// [ 'Felix', 'Cristiane', 'Rosangela', 'Marina', 'SomeoneElse' ] + From b22a1a9538ec0f0aa455ab24766cc7f821c2c686 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 13 Mar 2022 20:55:54 +0100 Subject: [PATCH 082/117] test --- week-3/InClass/exercise-A.js | 1 + 1 file changed, 1 insertion(+) diff --git a/week-3/InClass/exercise-A.js b/week-3/InClass/exercise-A.js index 0f7fb5ae..b3e1256b 100644 --- a/week-3/InClass/exercise-A.js +++ b/week-3/InClass/exercise-A.js @@ -14,5 +14,6 @@ console.log(peopleOnMyTable); // prints : + // [ 'Felix', 'Cristiane', 'Rosangela', 'Marina', 'SomeoneElse' ] From ac48d71a01ac4dc900bb8147c794b281971fcc71 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 13 Mar 2022 20:57:55 +0100 Subject: [PATCH 083/117] adding the Inclass exercise A --- week-3/InClass/exercise-A.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/week-3/InClass/exercise-A.js b/week-3/InClass/exercise-A.js index b3e1256b..f962aa96 100644 --- a/week-3/InClass/exercise-A.js +++ b/week-3/InClass/exercise-A.js @@ -14,6 +14,4 @@ console.log(peopleOnMyTable); // prints : - // [ 'Felix', 'Cristiane', 'Rosangela', 'Marina', 'SomeoneElse' ] - From 134a3061ecf900bb37e54506c66f95758218405c Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 13 Mar 2022 20:58:33 +0100 Subject: [PATCH 084/117] testing exercise B --- week-3/InClass/exercise-B.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/week-3/InClass/exercise-B.js b/week-3/InClass/exercise-B.js index e69de29b..af9fc51c 100644 --- a/week-3/InClass/exercise-B.js +++ b/week-3/InClass/exercise-B.js @@ -0,0 +1,3 @@ + lalalala + + teste \ No newline at end of file From b406f479e680942bebf95c3f64731f840e9f2785 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Mon, 14 Mar 2022 10:08:13 +0100 Subject: [PATCH 085/117] teste --- week-3/Homework/A-array-find/exercise.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/week-3/Homework/A-array-find/exercise.js b/week-3/Homework/A-array-find/exercise.js index d7fd51f8..2b60c4b3 100644 --- a/week-3/Homework/A-array-find/exercise.js +++ b/week-3/Homework/A-array-find/exercise.js @@ -7,6 +7,19 @@ var names = ["Rakesh", "Antonio", "Alexandra", "Andronicus", "Annam", "Mikey", "Anastasia", "Karim", "Ahmed"]; +// function isLongNameStartingWithA(name){ +// return isLongName(name) && startsWithA(name) +// } + +function isLongNameStartingWithA(name){ +return name[0] ==="A" && name.length > 7 + +} + +function findLongNameThatStartsWithA(names){ + return names.find( name => isLongNameStartingWithA(name)) +} + var longNameThatStartsWithA = findLongNameThatStartsWithA(names); console.log(longNameThatStartsWithA); From 301c562565caec6aa91b46c301a5c393774501e2 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Mon, 14 Mar 2022 10:19:15 +0100 Subject: [PATCH 086/117] adding the exercise B of the homework --- week-3/Homework/B-array-some/exercise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-3/Homework/B-array-some/exercise.js b/week-3/Homework/B-array-some/exercise.js index 965c0524..f4c994ea 100644 --- a/week-3/Homework/B-array-some/exercise.js +++ b/week-3/Homework/B-array-some/exercise.js @@ -10,7 +10,7 @@ var pairsByIndex = [[0, 3], [1, 2], [2, 1], null, [3, 0]]; // 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); +// if (pairsByIndex.some(item => item == null))process.exit(1); var students = ["Islam", "Lesley", "Harun", "Rukmini"]; var mentors = ["Daniel", "Irina", "Mozafar", "Luke"]; From fcd6436a49e9857cccca0c223a3fd9ec4f07d122 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Mon, 14 Mar 2022 10:36:48 +0100 Subject: [PATCH 087/117] adding the homework exercise C --- week-3/Homework/C-array-every/exercise.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/week-3/Homework/C-array-every/exercise.js b/week-3/Homework/C-array-every/exercise.js index b515e941..bdb54128 100644 --- a/week-3/Homework/C-array-every/exercise.js +++ b/week-3/Homework/C-array-every/exercise.js @@ -5,7 +5,11 @@ var students = ["Omar", "Austine", "Dany", "Swathi", "Lesley", "Rukmini"]; var group = ["Austine", "Dany", "Swathi", "Daniel"]; -var groupIsOnlyStudents; // complete this statement +function isStudent(name){ + return students.includes(name) +} + +var groupIsOnlyStudents = group.every(isStudent)// complete this statement if (groupIsOnlyStudents) { console.log("The group contains only students"); From 35b4f59b9744f256e40fb610b5d298c703256e02 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Mon, 14 Mar 2022 11:28:35 +0100 Subject: [PATCH 088/117] first try of the homework exercise-D - I would like to review if this is the correct function for this exercise as we dont have any expected result --- week-3/Homework/D-array-filter/exercise.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/week-3/Homework/D-array-filter/exercise.js b/week-3/Homework/D-array-filter/exercise.js index 6e32cc6b..9e7a2169 100644 --- a/week-3/Homework/D-array-filter/exercise.js +++ b/week-3/Homework/D-array-filter/exercise.js @@ -8,7 +8,7 @@ var pairsByIndexRaw = [[0, 3], [1, 2], [2, 1], null, [1], false, "whoops"]; -var pairsByIndex; // Complete this statement +var pairsByIndex = pairsByIndexRaw.slice(0,3) // Complete this statement var students = ["Islam", "Lesley", "Harun", "Rukmini"]; var mentors = ["Daniel", "Irina", "Mozafar", "Luke"]; @@ -20,3 +20,8 @@ var pairs = pairsByIndex.map(function(indexes) { }); console.log(pairs); + + + + + From 4a9a7c1adbafeb667a29dabd7c365a48de40a8ab Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Mon, 14 Mar 2022 22:18:43 +0100 Subject: [PATCH 089/117] adding the exercise D of the homework --- week-3/Homework/D-array-filter/exercise.js | 35 +++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/week-3/Homework/D-array-filter/exercise.js b/week-3/Homework/D-array-filter/exercise.js index 9e7a2169..4643b3f8 100644 --- a/week-3/Homework/D-array-filter/exercise.js +++ b/week-3/Homework/D-array-filter/exercise.js @@ -6,22 +6,37 @@ - Do not edit any of the existing code */ -var pairsByIndexRaw = [[0, 3], [1, 2], [2, 1], null, [1], false, "whoops"]; +var pairsByIndexRaw = [[0, 3], [1, 2], [2, 1], null, [1], false, 'whoops']; -var pairsByIndex = pairsByIndexRaw.slice(0,3) // Complete this statement +// Solution 1: -var students = ["Islam", "Lesley", "Harun", "Rukmini"]; -var mentors = ["Daniel", "Irina", "Mozafar", "Luke"]; +/* +var pairsByIndex = pairsByIndexRaw.filter(function (element) { + if (Array.isArray(element) && element.length === 2) { + return true; + } + return false; -var pairs = pairsByIndex.map(function(indexes) { - var student = students[indexes[0]]; - var mentor = mentors[indexes[1]]; - return [student, mentor]; }); +*/ + +// Solution 2: -console.log(pairs); - +// var pairsByIndex = pairsByIndexRaw.filter(element => Array.isArray(element) && element.length === 2); +// Solution 3: +let filterFunction = element => Array.isArray(element) && element.length === 2; +var pairsByIndex = pairsByIndexRaw.filter(filterFunction) +var students = ['Islam', 'Lesley', 'Harun', 'Rukmini']; +var mentors = ['Daniel', 'Irina', 'Mozafar', 'Luke']; + +var pairs = pairsByIndex.map(function (indexes) { + var student = students[indexes[0]]; + var mentor = mentors[indexes[1]]; + return [student, mentor]; +}); + +console.log(pairs); \ No newline at end of file From cbe85725f5cd6e7e5bbaea85e1ca210903bfa093 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Mon, 14 Mar 2022 22:43:26 +0100 Subject: [PATCH 090/117] adding the exercise E of the homework --- week-3/Homework/E-array-map/exercise.js | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/week-3/Homework/E-array-map/exercise.js b/week-3/Homework/E-array-map/exercise.js index 2835e922..24fbca12 100644 --- a/week-3/Homework/E-array-map/exercise.js +++ b/week-3/Homework/E-array-map/exercise.js @@ -3,3 +3,34 @@ var numbers = [0.1, 0.2, 0.3, 0.4, 0.5]; +//solution 1 - callback function: + +/* +let numbersMultiplied = numbers.map(function (number){ + return number * 100 +}) + +console.log(numbersMultiplied) // prints: [ 10, 20, 30, 40, 50 ] + +*/ + +//solution 2 +/* + +let numbersMultiplied = numbers.map(number => { + return number * 100 +}) + +console.log(numbersMultiplied) // prints: [ 10, 20, 30, 40, 50 ] +*/ + +//solution 3 + + +let numbersMultiplied = numbers.map(number => number * 100) + +console.log(numbersMultiplied) // prints: [ 10, 20, 30, 40, 50 ] + + + + From 16c30b51f40ba6fe20c13a8ebc471529efc6d3ab Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Mon, 14 Mar 2022 23:40:40 +0100 Subject: [PATCH 091/117] adding exercise B inclass --- week-3/InClass/exercise-B.js | 44 ++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/week-3/InClass/exercise-B.js b/week-3/InClass/exercise-B.js index af9fc51c..c87db744 100644 --- a/week-3/InClass/exercise-B.js +++ b/week-3/InClass/exercise-B.js @@ -1,3 +1,43 @@ - lalalala +let peopleOnMyClass = ["Cristiane" , "Valeria" , "Diego" , "Alejandra" , "Yennifer" , "Angel "]; - teste \ No newline at end of file +let peopleFromTheOtherClass = peopleOnMyClass.concat("Yogi ", "Diana ", "Abdul ", "Carlos ", "Vincent ", "David ") + +console.log(peopleFromTheOtherClass.sort()) + + +/* prints +[ + 'Abdul ', 'Alejandra', + 'Angel ', 'Carlos', + 'Cristiane ', 'David', + 'Diana', 'Diego', + 'Valeria', 'Vincent', + 'Yennifer', 'Yogi' +] +*/ + +// function callingByTheName(people){ +// if (peopleOnMyClass == people) { +// return `${people} is at the class with ${peopleOnMyClass}` +// } +// return `${people} is not at the class with ${peopleOnMyClass}` + +// } + + + +// prints: + +// Vincent is not at the class with Cristiane,Valeria,Diego,Alejandra,Yennifer,Angel + +function callingByTheName(name, arr){ + if (!arr.includes(name)){ + return `${name} is not at the class with ${peopleOnMyClass}` + } + return `${name} is at the class with ${peopleOnMyClass}` +} + +console.log(callingByTheName("Juan", peopleFromTheOtherClass)) + + +// prints: Juan is not at the class with Cristiane,Valeria,Diego,Alejandra,Yennifer,Angel \ No newline at end of file From 17615ccd2ca39253211dd50cee236d233a75d3bf Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Mon, 21 Mar 2022 01:05:00 +0100 Subject: [PATCH 092/117] adding the exercise C of the Inclass content --- week-3/InClass/exercise-C.js | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/week-3/InClass/exercise-C.js b/week-3/InClass/exercise-C.js index e69de29b..bcd3c500 100644 --- a/week-3/InClass/exercise-C.js +++ b/week-3/InClass/exercise-C.js @@ -0,0 +1,52 @@ + + +// I have a function defined below as: +// This function does not need to be modified. Can you pass in a callback function which will mutate namesArray such that it: +// Upper cases all letters in the array + +function magician(yourFunc) { + console.log( + "I am magician! Watch as I mutate an array of strings to your heart's content!" + ); + const namesArray = [ + "James", + "Elamin", + "Ismael", + "Sanyia", + "Chris", + "Antigoni", + ]; + + const magicOutput = yourFunc(namesArray); + + return magicOutput; +} + +// const upperCaseNamesArray = function (yourFunc){ return namesArray.toUpperCase()} + +/// + +function nametoUpperCase(person){ + return person.toUpperCase(); +} + +function manipulateArray(array){ + const result = [] + for (let i = 0; i < array.length; i++){ + const element = array[i]; + result.push(nametoUpperCase(element)) + } + return result; +} + +console.log(magician(manipulateArray)) + + +/// It prints: + +//I am magician! Watch as I mutate an array of strings to your heart's content! +//[ 'JAMES', 'ELAMIN', 'ISMAEL', 'SANYIA', 'CHRIS', 'ANTIGONI' ] + + + +///Calback Function: From cf3941fc586aa30eca7b5f0107c56cb3d6093e52 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Mon, 21 Mar 2022 01:06:05 +0100 Subject: [PATCH 093/117] adding the exercise D of the inclass JSI --- week-3/InClass/exercise-D.js | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/week-3/InClass/exercise-D.js b/week-3/InClass/exercise-D.js index e69de29b..83b8171c 100644 --- a/week-3/InClass/exercise-D.js +++ b/week-3/InClass/exercise-D.js @@ -0,0 +1,47 @@ + + +/* Modify your callback function from the previous exercise so that it also: +sorts namesArray in alphabetical order */ + +function magician(yourFunc) { + console.log( + "I am magician! Watch as I mutate an array of strings to your heart's content!" + ); + const namesArray = [ + "James", + "Elamin", + "Ismael", + "Sanyia", + "Chris", + "Antigoni", + ]; + + const magicOutput = yourFunc(namesArray); + + return magicOutput; +} + +// const upperCaseNamesArray = function (yourFunc){ return namesArray.toUpperCase()} + +/// + +function nametoUpperCase(person){ + return person.toUpperCase(); +} + +function manipulateArray(array){ + const result = [] + for (let i = 0; i < array.length; i++){ + const element = array[i]; + result.push(nametoUpperCase(element)) + } + return result.sort(); +} + +console.log(magician(manipulateArray)) + + +//Prints: + +//I am magician! Watch as I mutate an array of strings to your heart's content! +//[ 'ANTIGONI', 'CHRIS', 'ELAMIN', 'ISMAEL', 'JAMES', 'SANYIA' ] From a6c2e360cf86cd22937a86e1ca1d464533c78490 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Mon, 21 Mar 2022 12:25:30 +0100 Subject: [PATCH 094/117] adding a peace of the exercise F --- week-3/Homework/F-array-forEach/exercise.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/week-3/Homework/F-array-forEach/exercise.js b/week-3/Homework/F-array-forEach/exercise.js index e83e2df6..173ddaf1 100644 --- a/week-3/Homework/F-array-forEach/exercise.js +++ b/week-3/Homework/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 ismultiple(value, mult){ + let resp = value % mult; + if(resp === 0) return true; + else return false +} + +function multiple (){ + let min = 0; + for(let i =15; i >min; i--){ + console.log(i); + } +} + +console.log(ismultiple(9,3)) + + /* EXPECTED OUTPUT */ /* From 5617e968165057922b51f7db9659368611ad4402 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Mon, 21 Mar 2022 22:08:09 +0100 Subject: [PATCH 095/117] adding exercise F of the inclass homework --- week-3/InClass/exercise-F.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/week-3/InClass/exercise-F.js b/week-3/InClass/exercise-F.js index e69de29b..178c8696 100644 --- a/week-3/InClass/exercise-F.js +++ b/week-3/InClass/exercise-F.js @@ -0,0 +1,13 @@ +/* + +You can drive in the UK at the age of 17. +Write another function that takes a birth year and returns a string Born in {year} can drive or Born in {year} can drive in {x} years +Use the array of birth years, [ 1964, 2008, 1999, 2005, 1978, 1985, 1919 ], to get an array of strings saying if these people can drive +console.log the answers + + +*/ + + + +// completar \ No newline at end of file From b25e5682319c2737fb35d2112f0390d59da483f3 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Mon, 21 Mar 2022 22:08:49 +0100 Subject: [PATCH 096/117] adding exercise E of the inclass homework --- week-3/InClass/exercise-E.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/week-3/InClass/exercise-E.js b/week-3/InClass/exercise-E.js index e69de29b..4642a61e 100644 --- a/week-3/InClass/exercise-E.js +++ b/week-3/InClass/exercise-E.js @@ -0,0 +1,28 @@ + +/* + +Create a function that takes a birthYear, and returns the age of someone +You are given an array with year that 7 people were born, [1964, 2008, 1999, 2005, 1978, 1985, 1919]. +Take this array and create another array containing their ages. +console.log the birth years array + +*/ + +const birthYears = [1964, 2008, 1999, 2005, 1978, 1985, 1919]; + +const ages = birthYears.map(function (birthYear){ + const year = 2022; + const yearsOld = year - birthYear; + return yearsOld + +}) + +console.log(ages) + +/* RESULT +[ + 58, 14, 23, 17, + 44, 37, 103 +] + +*/ From f329c1fd658360711e158ab9fc00f3b3c01e3d9d Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Tue, 22 Mar 2022 00:15:41 +0100 Subject: [PATCH 097/117] adding exercise-f - asked help for the teacher, waiting the answer --- week-3/InClass/exercise-F.js | 65 ++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/week-3/InClass/exercise-F.js b/week-3/InClass/exercise-F.js index 178c8696..8b432498 100644 --- a/week-3/InClass/exercise-F.js +++ b/week-3/InClass/exercise-F.js @@ -1,13 +1,72 @@ /* You can drive in the UK at the age of 17. -Write another function that takes a birth year and returns a string Born in {year} can drive or Born in {year} can drive in {x} years -Use the array of birth years, [ 1964, 2008, 1999, 2005, 1978, 1985, 1919 ], to get an array of strings saying if these people can drive + +Write another function that takes a birth year and returns a string Born in {year} + can drive or Born in {year} can drive in {x} years + +Use the array of birth years, [ 1964, 2008, 1999, 2005, 1978, 1985, 1919 ], + to get an array of strings saying if these people can drive + console.log the answers */ +const birthYears = [1964, 2008, 1999, 2005, 1978, 1985, 1919]; + +// const ages = birthYears.map(function (birthYear){ +// const year = 2022; +// const yearsOld = year - birthYear; +// return yearsOld + +// }) + +// solucion 1 cris: + +// const dLicense = birthYears.map(function (driver){ +// const year = 2022; +// const yearsOld = year - driver; +// const legalDriver = yearsOld >= 17; +// const waitingPermition = yearsOld < 17; +// const yearsWaiting = 17 - yearsOld; +// if (driver === legalDriver){ +// console.log( `Born in ${birthYears.length()} can drive`) +// } else ( driver === waitingPermition) +// console.log(`Born in ${birthYears} can drive in ${yearsWaiting} years`) +// }); + + + +// Prints: + +/* +Born in 1964,2008,1999,2005,1978,1985,1919 can drive in -41 years +Born in 1964,2008,1999,2005,1978,1985,1919 can drive in 3 years +Born in 1964,2008,1999,2005,1978,1985,1919 can drive in -6 years +Born in 1964,2008,1999,2005,1978,1985,1919 can drive in 0 years +Born in 1964,2008,1999,2005,1978,1985,1919 can drive in -27 years +Born in 1964,2008,1999,2005,1978,1985,1919 can drive in -20 years +Born in 1964,2008,1999,2005,1978,1985,1919 can drive in -86 years + +*/ + + +const dLicense = birthYears.map(function (driver){ + const year = 2022; + const yearsOld = year - driver; + const legalDriver = yearsOld >= 17; + const waitingPermition = yearsOld < 17; + const yearsWaiting = 17 - yearsOld; + if ( driver == waitingPermition){ + console.log(`Born in ${birthYears.length} can drive in ${yearsWaiting} years`) + } else (driver == legalDriver) + console.log( `Born in ${birthYears.length} can drive`) + + }); + + + +// PEDI AYUDA AL PROFESOR ALEJANDRO -// completar \ No newline at end of file From 42147c77edd54e1b64253e6d559477496f40950e Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Tue, 22 Mar 2022 00:38:27 +0100 Subject: [PATCH 098/117] adding exercise H - need to create a new function with .find() now --- week-3/InClass/exercise-H.js | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/week-3/InClass/exercise-H.js b/week-3/InClass/exercise-H.js index e69de29b..b63275ea 100644 --- a/week-3/InClass/exercise-H.js +++ b/week-3/InClass/exercise-H.js @@ -0,0 +1,40 @@ +/* + +Exercise H (10 mins) +Create a function which: +Takes an array of names +Looks to see if your name is in the array +If it is, return Found me!; if not, return Haven't found me :( + +*/ + +const nameList = ["Cristiane", "Joana", "Carmem" , "Maria", "Ana", "Jessica"]; + + +const findingCris = function (people){ + if (people === "Cristiane") + return "Found me!" + else + return "Haven't found me" + +} + +console.log(findingCris("Cristiane")) + + +//Prints: +//Found me! + + + +// completar com o find + +// function findingCris(person) { +// if (person === nameList.find(person)){ +// return "Found me!" +// } else { +// return "Haven't found me" +// } +// } + +// console.log(findingCris("Cristiane")); \ No newline at end of file From 88f12c993f1def5906c1b93acf4ffa475268812b Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Tue, 22 Mar 2022 21:46:58 +0100 Subject: [PATCH 099/117] finished the exercise F of inclass exercises, with the help of the codeBuddy Manana --- week-3/InClass/exercise-F.js | 65 ++++++++++-------------------------- 1 file changed, 18 insertions(+), 47 deletions(-) diff --git a/week-3/InClass/exercise-F.js b/week-3/InClass/exercise-F.js index 8b432498..30cec467 100644 --- a/week-3/InClass/exercise-F.js +++ b/week-3/InClass/exercise-F.js @@ -15,58 +15,29 @@ console.log the answers const birthYears = [1964, 2008, 1999, 2005, 1978, 1985, 1919]; -// const ages = birthYears.map(function (birthYear){ -// const year = 2022; -// const yearsOld = year - birthYear; -// return yearsOld -// }) - -// solucion 1 cris: - -// const dLicense = birthYears.map(function (driver){ -// const year = 2022; -// const yearsOld = year - driver; -// const legalDriver = yearsOld >= 17; -// const waitingPermition = yearsOld < 17; -// const yearsWaiting = 17 - yearsOld; -// if (driver === legalDriver){ -// console.log( `Born in ${birthYears.length()} can drive`) -// } else ( driver === waitingPermition) -// console.log(`Born in ${birthYears} can drive in ${yearsWaiting} years`) -// }); +const dLicense = birthYears.map(function (birthYear){ + const year = 2022; // number + const yearsOld = year - birthYear; // number + const yearsWaiting = 17 - yearsOld; // number + if ( yearsOld < 17){ + console.log(`Born in ${birthYear} can drive in ${yearsWaiting} years`) + } else if( yearsOld >= 17) + console.log( `Born in ${birthYear} can drive`) + }); -// Prints: +//PRINTS: /* -Born in 1964,2008,1999,2005,1978,1985,1919 can drive in -41 years -Born in 1964,2008,1999,2005,1978,1985,1919 can drive in 3 years -Born in 1964,2008,1999,2005,1978,1985,1919 can drive in -6 years -Born in 1964,2008,1999,2005,1978,1985,1919 can drive in 0 years -Born in 1964,2008,1999,2005,1978,1985,1919 can drive in -27 years -Born in 1964,2008,1999,2005,1978,1985,1919 can drive in -20 years -Born in 1964,2008,1999,2005,1978,1985,1919 can drive in -86 years - -*/ - - -const dLicense = birthYears.map(function (driver){ - const year = 2022; - const yearsOld = year - driver; - const legalDriver = yearsOld >= 17; - const waitingPermition = yearsOld < 17; - const yearsWaiting = 17 - yearsOld; - if ( driver == waitingPermition){ - console.log(`Born in ${birthYears.length} can drive in ${yearsWaiting} years`) - } else (driver == legalDriver) - console.log( `Born in ${birthYears.length} can drive`) - - }); - - - -// PEDI AYUDA AL PROFESOR ALEJANDRO +Born in 1964 can drive +Born in 2008 can drive in 3 years +Born in 1999 can drive +Born in 2005 can drive +Born in 1978 can drive +Born in 1985 can drive +Born in 1919 can drive +*/ \ No newline at end of file From 5dfab82eedab6e4f94bf9a2a9505b63aea2d6f04 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Tue, 22 Mar 2022 21:49:02 +0100 Subject: [PATCH 100/117] adding the changes of exercise C of the inclass serie of exercises --- week-3/InClass/exercise-C.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/week-3/InClass/exercise-C.js b/week-3/InClass/exercise-C.js index bcd3c500..03668b1a 100644 --- a/week-3/InClass/exercise-C.js +++ b/week-3/InClass/exercise-C.js @@ -5,9 +5,7 @@ // Upper cases all letters in the array function magician(yourFunc) { - console.log( - "I am magician! Watch as I mutate an array of strings to your heart's content!" - ); + console.log("I am magician! Watch as I mutate an array of strings to your heart's content!"); const namesArray = [ "James", "Elamin", @@ -49,4 +47,4 @@ console.log(magician(manipulateArray)) -///Calback Function: + From cc6de638005018d6cb3bd81975af318a2265436a Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Tue, 22 Mar 2022 22:03:01 +0100 Subject: [PATCH 101/117] adding exercise G of inclass --- week-3/InClass/exercise-F.js | 1 - week-3/InClass/exercise-G.js | 24 ++++++++++++++++++++++++ week-3/InClass/exercise-I.js | 26 ++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/week-3/InClass/exercise-F.js b/week-3/InClass/exercise-F.js index 30cec467..9097c05c 100644 --- a/week-3/InClass/exercise-F.js +++ b/week-3/InClass/exercise-F.js @@ -27,7 +27,6 @@ const dLicense = birthYears.map(function (birthYear){ }); - //PRINTS: /* diff --git a/week-3/InClass/exercise-G.js b/week-3/InClass/exercise-G.js index e69de29b..b6719ea0 100644 --- a/week-3/InClass/exercise-G.js +++ b/week-3/InClass/exercise-G.js @@ -0,0 +1,24 @@ +/* + +Create a function which: +Takes an array of birthYears +Uses console.log to print the message +These are the birth years of people who can drive: +Returns an array of people who can drive (remember, you can drive if you are 17 years or older) + +*/ + +const birthYears = [1964, 2008, 1999, 2005, 1978, 1985, 1919]; + +function whoCanDrive( birthYear){ + return birthYear <= 2005; +} + +const canDrive = birthYears.filter(whoCanDrive) + +console.log(`These are the birth years of people who can drive ${canDrive}`); + + +//prints: + +// These are the birth years of people who can drive 1964,1999,2005,1978,1985,1919 diff --git a/week-3/InClass/exercise-I.js b/week-3/InClass/exercise-I.js index e69de29b..8f57cff3 100644 --- a/week-3/InClass/exercise-I.js +++ b/week-3/InClass/exercise-I.js @@ -0,0 +1,26 @@ +/* +Create a function which accepts an array of "messy" strings. Example: +[ + 100, + "iSMael", + 55, + 45, + "sANyiA", + 66, + "JaMEs", + "eLAmIn", + 23, + "IsMael", + 67, + 19, + "ElaMIN", +]; + +This function should: +Remove all non-string entries +Change the strings to upper case, and add an exclamation mark to the end +If you're using the above example, you should expect to return an array with 2x ELAMIN!, 1x SANYIA!, 2x ISMAEL! and 1x JAMES! + + +*/ +// completar \ No newline at end of file From ed1eeac058117d08528847e486cf3df168c2f19e Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Fri, 25 Mar 2022 10:43:51 +0100 Subject: [PATCH 102/117] adding the exercise H of Inclass exercises --- week-3/Homework/F-array-forEach/exercise.js | 54 ++++++++++++++++----- week-3/InClass/exercise-F.js | 3 -- week-3/InClass/exercise-H.js | 44 +++++++++++------ 3 files changed, 71 insertions(+), 30 deletions(-) diff --git a/week-3/Homework/F-array-forEach/exercise.js b/week-3/Homework/F-array-forEach/exercise.js index 173ddaf1..ff60ce04 100644 --- a/week-3/Homework/F-array-forEach/exercise.js +++ b/week-3/Homework/F-array-forEach/exercise.js @@ -9,21 +9,49 @@ var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; -function ismultiple(value, mult){ - let resp = value % mult; - if(resp === 0) return true; - else return false -} - -function multiple (){ - let min = 0; - for(let i =15; i >min; i--){ - console.log(i); +// solution 1 + + +arr.forEach(function (element) { + + if (element % 3 === 0 && element % 5 === 0) { + console.log("FizzBuzz"); + } else if (element % 5 === 0) { + console.log("Buzz"); + } else if(element % 3 === 0) { + console.log("Fizz"); + } else { + console.log(element); } -} +}); + + +// function solutionTwo(element) { + +// if (element % 3 === 0 && element % 5 === 0) { +// console.log("FizzBuzz"); +// return +// } +// if (element % 5 === 0) { +// console.log("Buzz"); +// return +// } +// if(element % 3 === 0) { +// console.log("Fizz"); +// return +// } +// console.log(element); + +// }; + +// arr.forEach(solutionTwo) -console.log(ismultiple(9,3)) +// return - "stop the execution of the function // sinonimus of exit - go out of the function" + +// return - IF Theres any expression after >> it will give me undefined + +// if I want to save the result of the function, I can put this on a variable /* EXPECTED OUTPUT */ @@ -44,3 +72,5 @@ console.log(ismultiple(9,3)) 14 'FizzBuzz' */ + + diff --git a/week-3/InClass/exercise-F.js b/week-3/InClass/exercise-F.js index 9097c05c..f5e86fdf 100644 --- a/week-3/InClass/exercise-F.js +++ b/week-3/InClass/exercise-F.js @@ -1,5 +1,4 @@ /* - You can drive in the UK at the age of 17. Write another function that takes a birth year and returns a string Born in {year} @@ -9,8 +8,6 @@ Use the array of birth years, [ 1964, 2008, 1999, 2005, 1978, 1985, 1919 ], to get an array of strings saying if these people can drive console.log the answers - - */ const birthYears = [1964, 2008, 1999, 2005, 1978, 1985, 1919]; diff --git a/week-3/InClass/exercise-H.js b/week-3/InClass/exercise-H.js index b63275ea..c1a73f96 100644 --- a/week-3/InClass/exercise-H.js +++ b/week-3/InClass/exercise-H.js @@ -8,33 +8,47 @@ If it is, return Found me!; if not, return Haven't found me :( */ -const nameList = ["Cristiane", "Joana", "Carmem" , "Maria", "Ana", "Jessica"]; +const nameList = ["Cristiane", "Joana", "Carmem" , "Maria", "Ana"]; -const findingCris = function (people){ - if (people === "Cristiane") + function findingPeople(person){ + if (person === "Cristiane") // boolean return "Found me!" else return "Haven't found me" } -console.log(findingCris("Cristiane")) +console.log(findingPeople("Cristiane")) -//Prints: -//Found me! +/* All the other tries I got stuck: -// completar com o find +function findingPeople(person){ + if (person == nameList ){ + return "Found Me!" + } + else return "Haven't found me" +} + +const findingCris = nameList.find(findingPeople) + +console.log(findingPeople("Cristiane")) + + + + +function findingPeople(person) { + if (person == nameList.find("Cristiane")){ + return "Found me!" + } else { + return "Haven't found me" + } +} + +console.log(findingPeople("Cristiane")); -// function findingCris(person) { -// if (person === nameList.find(person)){ -// return "Found me!" -// } else { -// return "Haven't found me" -// } -// } -// console.log(findingCris("Cristiane")); \ No newline at end of file +*/ \ No newline at end of file From 75e1717504d2f28c949caa89189e1b40881fb780 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Fri, 25 Mar 2022 10:46:02 +0100 Subject: [PATCH 103/117] adding exercise G of inCLASS --- week-3/InClass/exercise-G.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-3/InClass/exercise-G.js b/week-3/InClass/exercise-G.js index b6719ea0..f2938915 100644 --- a/week-3/InClass/exercise-G.js +++ b/week-3/InClass/exercise-G.js @@ -10,7 +10,7 @@ Returns an array of people who can drive (remember, you can drive if you are 17 const birthYears = [1964, 2008, 1999, 2005, 1978, 1985, 1919]; -function whoCanDrive( birthYear){ +function whoCanDrive(birthYear){ return birthYear <= 2005; } From 8ef88bfd9af515d1ecac44e419f3084f0b61b17f Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Fri, 25 Mar 2022 16:49:23 +0100 Subject: [PATCH 104/117] finally adding exercise-I of inclass activity --- week-3/InClass/exercise-I.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/week-3/InClass/exercise-I.js b/week-3/InClass/exercise-I.js index 8f57cff3..a2ba607e 100644 --- a/week-3/InClass/exercise-I.js +++ b/week-3/InClass/exercise-I.js @@ -21,6 +21,36 @@ Remove all non-string entries Change the strings to upper case, and add an exclamation mark to the end If you're using the above example, you should expect to return an array with 2x ELAMIN!, 1x SANYIA!, 2x ISMAEL! and 1x JAMES! - */ -// completar \ No newline at end of file + const messyElements = [ + 100, + "iSMael", + 55, + 45, + "sANyiA", + 66, + "JaMEs", + "eLAmIn", + 23, + "IsMael", + 67, + 19, + "ElaMIN", +]; + + +const stringArray = messyElements.forEach( function organizingElements(element){ + if (typeof element === 'string'){ + console.log(element.toLocaleUpperCase() + '!') + } }) + +// printa : +// ISMAEL! +// SANYIA! +// JAMES! +// ELAMIN! +// ISMAEL! +// ELAMIN! + + + From 5007a1230a88b806903af47e68960847554f128c Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Fri, 25 Mar 2022 17:07:26 +0100 Subject: [PATCH 105/117] adding exercise C of homework --- week-3/Homework/C-array-every/exercise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-3/Homework/C-array-every/exercise.js b/week-3/Homework/C-array-every/exercise.js index bdb54128..0574751a 100644 --- a/week-3/Homework/C-array-every/exercise.js +++ b/week-3/Homework/C-array-every/exercise.js @@ -9,7 +9,7 @@ function isStudent(name){ return students.includes(name) } -var groupIsOnlyStudents = group.every(isStudent)// complete this statement +var groupIsOnlyStudents = group.every(isStudent) if (groupIsOnlyStudents) { console.log("The group contains only students"); From 6d97beed5608baf3e8e4ea597006a2a27c306b60 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Fri, 25 Mar 2022 17:22:56 +0100 Subject: [PATCH 106/117] adding the answer to the exercise D --- week-3/Homework/D-array-filter/exercise.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/week-3/Homework/D-array-filter/exercise.js b/week-3/Homework/D-array-filter/exercise.js index 4643b3f8..401de69f 100644 --- a/week-3/Homework/D-array-filter/exercise.js +++ b/week-3/Homework/D-array-filter/exercise.js @@ -39,4 +39,8 @@ var pairs = pairsByIndex.map(function (indexes) { return [student, mentor]; }); -console.log(pairs); \ No newline at end of file +console.log(pairs); + +// Prints: + +//[ [ 'Islam', 'Luke' ], [ 'Lesley', 'Mozafar' ], [ 'Harun', 'Irina' ] ] \ No newline at end of file From f3b7916e34fa546ba9551fd101855cd8f5215c00 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Fri, 25 Mar 2022 17:31:37 +0100 Subject: [PATCH 107/117] adding the first exercise of G of the Homework --- week-3/Homework/G-array-methods/exercise.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/week-3/Homework/G-array-methods/exercise.js b/week-3/Homework/G-array-methods/exercise.js index 44e9c801..56fa5f24 100644 --- a/week-3/Homework/G-array-methods/exercise.js +++ b/week-3/Homework/G-array-methods/exercise.js @@ -4,7 +4,7 @@ */ var numbers = [3, 2, 1]; -var sortedNumbers; // complete this statement +var sortedNumbers = numbers.sort(); /* DO NOT EDIT BELOW THIS LINE @@ -17,3 +17,8 @@ console.log(sortedNumbers); --------------- [1, 2, 3] */ + + +// Prints: + + [1, 2, 3] \ No newline at end of file From f12c2004d3cbe93bb2295faddd5f554b64e19915 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Fri, 25 Mar 2022 17:33:40 +0100 Subject: [PATCH 108/117] adding the second and last exercise of G of the Homework --- week-3/Homework/G-array-methods/exercise2.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/week-3/Homework/G-array-methods/exercise2.js b/week-3/Homework/G-array-methods/exercise2.js index 3dd24a17..180cdbb7 100644 --- a/week-3/Homework/G-array-methods/exercise2.js +++ b/week-3/Homework/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) /* DO NOT EDIT BELOW THIS LINE @@ -20,3 +20,15 @@ console.log(everyone); --------------- ["Daniel", "Irina", "Rares", "Rukmini", "Abdul", "Austine", "Swathi"] */ + + +// prints: + +/* + 'Daniel', 'Irina', + 'Rares', 'Rukmini', + 'Abdul', 'Austine', + 'Swathi' +] + +*/ \ No newline at end of file From 6d57b6f2e27d13bf4556312d88e67a457b03c7b8 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Fri, 25 Mar 2022 18:01:30 +0100 Subject: [PATCH 109/117] adding first exercise of H homework --- week-3/Homework/H-array-methods-2/exercise.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/week-3/Homework/H-array-methods-2/exercise.js b/week-3/Homework/H-array-methods-2/exercise.js index d36303b8..1eab436c 100644 --- a/week-3/Homework/H-array-methods-2/exercise.js +++ b/week-3/Homework/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); +var lastFive =everyone.slice(2,7); /* DO NOT EDIT BELOW THIS LINE From 196d8390feffeeb18c847e5f559974e9b009b6c3 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Mar 2022 22:22:21 +0100 Subject: [PATCH 110/117] adding the Homework H, exercise 2 - waiting the MC comments about this exercise --- week-3/Homework/H-array-methods-2/exercise2.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/week-3/Homework/H-array-methods-2/exercise2.js b/week-3/Homework/H-array-methods-2/exercise2.js index b7be576e..bd9060ca 100644 --- a/week-3/Homework/H-array-methods-2/exercise2.js +++ b/week-3/Homework/H-array-methods-2/exercise2.js @@ -7,7 +7,16 @@ Tip: use the string method .split() and the array method .join() */ -function capitalise(str) {} +//First solution + +function capitalise(str) { + return str.charAt(0).toUpperCase() + str.slice(1) +} + +// Prints +// Daniel +// Hello + /* DO NOT EDIT BELOW THIS LINE From c17998dc9de44f2cb18040f7b22f22478cff0c9a Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Mar 2022 22:24:41 +0100 Subject: [PATCH 111/117] adding the Homework H, the last exercise 3 --- week-3/Homework/H-array-methods-2/exercise3.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/week-3/Homework/H-array-methods-2/exercise3.js b/week-3/Homework/H-array-methods-2/exercise3.js index 82e9dd8c..ef03d68f 100644 --- a/week-3/Homework/H-array-methods-2/exercise3.js +++ b/week-3/Homework/H-array-methods-2/exercise3.js @@ -6,8 +6,9 @@ var ukNations = ["Scotland", "Wales", "England", "Northern Ireland"]; + function isInUK(country) { - return; // complete this statement + return ukNations.includes(country); } /* From 217bf8d0f68b2f7effe6f5f73fd259c9d6b0bc1b Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Mar 2022 22:25:18 +0100 Subject: [PATCH 112/117] adding the Homework H, the last exercise 3 --- week-3/Homework/H-array-methods-2/exercise3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-3/Homework/H-array-methods-2/exercise3.js b/week-3/Homework/H-array-methods-2/exercise3.js index ef03d68f..8084d195 100644 --- a/week-3/Homework/H-array-methods-2/exercise3.js +++ b/week-3/Homework/H-array-methods-2/exercise3.js @@ -19,7 +19,7 @@ console.log(isInUK("Republic of Ireland")); console.log(isInUK("England")); /* - EXPECTED RESULT + EXPECTED RESULT // printed: --------------- false false From 90634744e5fae3925b22ed5bc89e91ce28d01d58 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Mar 2022 23:30:17 +0100 Subject: [PATCH 113/117] adding the exercise B of the Homework --- week-3/Homework/B-array-some/exercise.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/week-3/Homework/B-array-some/exercise.js b/week-3/Homework/B-array-some/exercise.js index f4c994ea..8e2b00fd 100644 --- a/week-3/Homework/B-array-some/exercise.js +++ b/week-3/Homework/B-array-some/exercise.js @@ -10,15 +10,28 @@ var pairsByIndex = [[0, 3], [1, 2], [2, 1], null, [3, 0]]; // 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 -// if (pairsByIndex.some(item => item == null))process.exit(1); +if (pairsByIndex.some(item => item == null))process.exit(1); var students = ["Islam", "Lesley", "Harun", "Rukmini"]; var mentors = ["Daniel", "Irina", "Mozafar", "Luke"]; -var pairs = pairsByIndex.map(function(indexes) { +var pairs = pairsByIndex.map(function (indexes) { var student = students[indexes[0]]; var mentor = mentors[indexes[1]]; return [student, mentor]; }); console.log(pairs); + +// prints ( when I delete the null of the program:) + +/* + +[ + [ 'Islam', 'Luke' ], + [ 'Lesley', 'Mozafar' ], + [ 'Harun', 'Irina' ], + <1 empty item>, + [ 'Rukmini', 'Daniel' ] + +]*/ From c2e8dd7e3430c19103f8e43dd72e23aac62cd94d Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Mar 2022 23:46:06 +0100 Subject: [PATCH 114/117] adding the another best way to do this exercise - thanks to codebuddy Manana who helped me to understand better the concept of JS - array methods --- week-3/InClass/exercise-H.js | 55 +++++++++++------------------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/week-3/InClass/exercise-H.js b/week-3/InClass/exercise-H.js index c1a73f96..082a88df 100644 --- a/week-3/InClass/exercise-H.js +++ b/week-3/InClass/exercise-H.js @@ -10,45 +10,24 @@ If it is, return Found me!; if not, return Haven't found me :( const nameList = ["Cristiane", "Joana", "Carmem" , "Maria", "Ana"]; - - function findingPeople(person){ - if (person === "Cristiane") // boolean - return "Found me!" - else +// I did in two ways, this first one I was not happy about it: + +// function findingPeople(person){ +// if (person === "Cristiane") // boolean +// return "Found me!" +// else +// return "Haven't found me" +// } +// console.log(findingPeople("Cristiane")) + +// I Kept practicing, and I found this new way a little bit easier now, and I can use properly an array method ( better than put my name dirrectly at the function): + +const findingPeople = (person) => { + if (nameList.includes(person)){ + return "Found me!" + } else return "Haven't found me" - -} - - -console.log(findingPeople("Cristiane")) - - -/* All the other tries I got stuck: - - -function findingPeople(person){ - if (person == nameList ){ - return "Found Me!" - } - else return "Haven't found me" } -const findingCris = nameList.find(findingPeople) - -console.log(findingPeople("Cristiane")) - - - - -function findingPeople(person) { - if (person == nameList.find("Cristiane")){ - return "Found me!" - } else { - return "Haven't found me" - } -} - -console.log(findingPeople("Cristiane")); - +console.log(findingPeople("Cristiane")) // prints: Found me! -*/ \ No newline at end of file From 2300105ecabe30cfd1c2191f65b6486221dd35f7 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sat, 26 Mar 2022 23:49:47 +0100 Subject: [PATCH 115/117] adding exercise A of Homework --- week-3/Homework/A-array-find/exercise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-3/Homework/A-array-find/exercise.js b/week-3/Homework/A-array-find/exercise.js index 2b60c4b3..b6af656d 100644 --- a/week-3/Homework/A-array-find/exercise.js +++ b/week-3/Homework/A-array-find/exercise.js @@ -25,4 +25,4 @@ var longNameThatStartsWithA = findLongNameThatStartsWithA(names); console.log(longNameThatStartsWithA); /* EXPECTED OUTPUT */ -// "Alexandra" +// "Alexandra" From c6d6f76fc496c9ba8d172a5e22959bbc51e0dc29 Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 27 Mar 2022 00:18:43 +0100 Subject: [PATCH 116/117] pushing the worked extra exercise to follow the progress --- week-3/Extra/2-bush-berries.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/week-3/Extra/2-bush-berries.js b/week-3/Extra/2-bush-berries.js index aca45ad5..bc8d3bc2 100644 --- a/week-3/Extra/2-bush-berries.js +++ b/week-3/Extra/2-bush-berries.js @@ -10,10 +10,19 @@ Use the tests to confirm which message to return */ -function bushChecker() { - +function bushChecker(_array) { + if (typeof _array == 'string'.length === 4 && _array.startsWith('p')) + return true + else false } +/* Prints: working on it + +bushChecker funtion works - case 1: FAILED: expected: 'Toxic! Leave bush alone!' but your function returned: undefined +bushChecker funtion works - case 1: FAILED: expected: 'Bush is safe to eat from' but your function returned: undefined + +*/ + /* ======= TESTS - DO NOT MODIFY ===== */ let bushBerryColours1 = ["pink", "pink", "pink", "neon", "pink", "transparent"] From 914815062cca6dffc05b9e04360b8801ecc5300f Mon Sep 17 00:00:00 2001 From: Cris-Rocha Date: Sun, 27 Mar 2022 20:28:35 +0200 Subject: [PATCH 117/117] adding the last information on the exercise H --- week-3/.DS_Store | Bin 0 -> 6148 bytes week-3/InClass/exercise-H.js | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 week-3/.DS_Store diff --git a/week-3/.DS_Store b/week-3/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5b6a87d4a9deeb4ead6c8d2d18eb4602480da5e8 GIT binary patch literal 6148 zcmeHKUrXaa5TETIyG4XPDD>qZ;A`=EDh2T+Rt0@Eq7UBDOKiCdjaf<3%RwpR`R>Eq ztDnTLqcgi(=^yVN%PBK3`Nbc}uoTOV|C0e)yDFT*PskvF+4Z9>afG__q(#5JgfmcZ2Ls3v6By2{H^u*1 zh_Asp#BdA|_>e+6A1yxoJ37eId%Kq&g8L{;vv&JYl**OrT20pEy8PmOSGkw@*(mM$ z$qn@`m5PF??FU!kAn!Fck5!!cVLV85Lf9W*$mi=Y?yJ13MsYvYxtY)_75g4XMC`W_WoXHGO5e0?T?2SyMsGcp6r05h;E2JHDG*H<+m&%+Eb18;@_Iv*TVLf2wpP#+!G=qmtX1>IWErXNAd zaV)wP3xha { - if (nameList.includes(person)){ +const findingPeople = (nameList) => { + if (nameList.includes(nameList)){ return "Found me!" } else return "Haven't found me"