From a879e03c6c88d96006821fb65df4579e8108a1ea Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 11:13:38 +0100 Subject: [PATCH 01/22] mandatory_1-syntax-error fixed --- mandatory/1-syntax-errors.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mandatory/1-syntax-errors.js b/mandatory/1-syntax-errors.js index a10cc9ac2..98360ac6b 100644 --- a/mandatory/1-syntax-errors.js +++ b/mandatory/1-syntax-errors.js @@ -1,16 +1,17 @@ // There are syntax errors in this code - can you fix it to pass the tests? -function addNumbers(a b c) { +function addNumbers(a, b, c) { return a + b + c; } -function introduceMe(name, age) - return "Hello, my name is " + name "and I am " age + "years old"; +function introduceMe(name, age) { + return "Hello, my name is " + name + " and I am " + age + " years old"; +} function getTotal(a, b) { - total = a ++ b; + total = a + b; - return "The total is total"; + return "The total is " + total; } /* From df8cfe6da0ad469f6fa1e0b879140ddb6a946ae5 Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 11:27:51 +0100 Subject: [PATCH 02/22] mandatory_2-logic-errors_fix --- mandatory/2-logic-error.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mandatory/2-logic-error.js b/mandatory/2-logic-error.js index 9cca7603b..37c4ebc15 100644 --- a/mandatory/2-logic-error.js +++ b/mandatory/2-logic-error.js @@ -1,16 +1,15 @@ // The syntax for this function is valid but it has an error, find it and fix it. function trimWord(word) { - return wordtrim(); + return word.trim(); } function getStringLength(word) { - return "word".length(); + return word.length; } function multiply(a, b, c) { - a * b * c; - return; + return a * b * c; } /* From 54b574a11936dfaab0ea3e01ad51ae8e88ca874c Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 11:43:37 +0100 Subject: [PATCH 03/22] madatory_3_function_output_fixed --- mandatory/3-function-output.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mandatory/3-function-output.js b/mandatory/3-function-output.js index 5a953ba60..d5ab20241 100644 --- a/mandatory/3-function-output.js +++ b/mandatory/3-function-output.js @@ -1,9 +1,13 @@ // Add comments to explain what this function does. You're meant to use Google! +/*The Math.random() function returns a floating-point, pseudo-random number in the range 0 to less than 1 (inclusive of 0, but not 1) with approximately uniform distribution over that range — which you can then scale to your desired range. The implementation selects the initial seed to the random number generation algorithm; it cannot be chosen or reset by the user.*/ +/*this function create random number, the result is random number time by 10*/ function getRandomNumber() { return Math.random() * 10; } // Add comments to explain what this function does. You're meant to use Google! +/*The concat() method concatenates the string arguments to the calling string and returns a new string.*/ +/*this function is going to create connected word from word1 and word2 input*/ function combine2Words(word1, word2) { return word1.concat(word2); } @@ -11,6 +15,7 @@ function combine2Words(word1, word2) { function concatenate(firstWord, secondWord, thirdWord) { // Write the body of this function to concatenate three words together. // Look at the test case below to understand what this function is expected to return. + return firstWord.concat(" " + secondWord + " " + thirdWord); } /* From 7721fcdffff892bae6c255a5faa9ac03c486016e Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 12:27:56 +0100 Subject: [PATCH 04/22] mandatory_4_tax_fixed --- mandatory/4-tax.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mandatory/4-tax.js b/mandatory/4-tax.js index ba77c7ae2..f7aeb85f2 100644 --- a/mandatory/4-tax.js +++ b/mandatory/4-tax.js @@ -5,7 +5,10 @@ Sales tax is 20% of the price of the product. */ -function calculateSalesTax() {} +function calculateSalesTax(num) { + let result = num + num * 0.2; + return result; +} /* CURRENCY FORMATTING @@ -17,7 +20,10 @@ function calculateSalesTax() {} Remember that the prices must include the sales tax (hint: you already wrote a function for this!) */ -function addTaxAndFormatCurrency() {} +function addTaxAndFormatCurrency(num) { + let result = num + num * 0.2; + return "£" + result.toFixed(2); +} /* =================================================== From 4ea4c73977d1042ea3d1d2ddb3a3b7ae4033fd0c Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 22:09:53 +0100 Subject: [PATCH 05/22] exercise_B_hello_world_test --- exercises/B-hello-world/exercise.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/exercises/B-hello-world/exercise.js b/exercises/B-hello-world/exercise.js index b179ee953..017a3123e 100644 --- a/exercises/B-hello-world/exercise.js +++ b/exercises/B-hello-world/exercise.js @@ -1 +1,4 @@ console.log("Hello world"); +console.log("Are you learning as well?"); +console.log("I " + "hope " + "that you know " + "what you are doing."); +console.log(3); From 0193ef72a944e9269f6575de2564b1632111f17f Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 22:17:02 +0100 Subject: [PATCH 06/22] exercise_C_variables_done --- exercises/C-variables/exercise.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exercises/C-variables/exercise.js b/exercises/C-variables/exercise.js index a6bbb9786..3244c32f2 100644 --- a/exercises/C-variables/exercise.js +++ b/exercises/C-variables/exercise.js @@ -1,3 +1,5 @@ // Start by creating a variable `greeting` - +var greeting = "Hello World"; +console.log(greeting); +console.log(greeting); console.log(greeting); From 2334cc300a0d5832345f2b66ad267772554dd729 Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 22:20:43 +0100 Subject: [PATCH 07/22] exercise_D_strings_done --- exercises/D-strings/exercise.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exercises/D-strings/exercise.js b/exercises/D-strings/exercise.js index 2cffa6a81..11b1e4b1f 100644 --- a/exercises/D-strings/exercise.js +++ b/exercises/D-strings/exercise.js @@ -1,3 +1,5 @@ // Start by creating a variable `message` - +var message = "This is a string"; console.log(message); +var messageType = typeof message; +console.log(messageType); From 3d97dd8d3b3e055ce9f16ae6a69450a620347987 Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 22:24:07 +0100 Subject: [PATCH 08/22] exercise_E_strings_concatenation_done --- exercises/E-strings-concatenation/exercise.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exercises/E-strings-concatenation/exercise.js b/exercises/E-strings-concatenation/exercise.js index 2cffa6a81..e15251fc8 100644 --- a/exercises/E-strings-concatenation/exercise.js +++ b/exercises/E-strings-concatenation/exercise.js @@ -1,3 +1,5 @@ // Start by creating a variable `message` - +var firstPart = "Hello, my name is "; +var secondPart = "Ro."; +var message = firstPart + secondPart; console.log(message); From b5cc1149e8c0366c960a30fc1200e293453e949c Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 22:37:13 +0100 Subject: [PATCH 09/22] exercise_F_strings_method_exercise1_done --- exercises/F-strings-methods/exercise.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/exercises/F-strings-methods/exercise.js b/exercises/F-strings-methods/exercise.js index 2cffa6a81..6609cb1fe 100644 --- a/exercises/F-strings-methods/exercise.js +++ b/exercises/F-strings-methods/exercise.js @@ -1,3 +1,18 @@ // Start by creating a variable `message` - +var name = "Daniel"; +var nameLength = name.length; +var messagePart; +if (name.length === 1) { + var messagePart = "character"; +} else { + var messagePart = "characters"; +} +var message = + "My name is " + + name + + " and my name is " + + nameLength + + " " + + messagePart + + " long."; console.log(message); From af4ded33ada42e092ee6ac6ac9714aae6e39a6f2 Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 22:46:00 +0100 Subject: [PATCH 10/22] exercise_F_strings_methods_exercise2_done --- exercises/F-strings-methods/exercise2.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/exercises/F-strings-methods/exercise2.js b/exercises/F-strings-methods/exercise2.js index b4b46943d..0b0b66a5f 100644 --- a/exercises/F-strings-methods/exercise2.js +++ b/exercises/F-strings-methods/exercise2.js @@ -1,3 +1,18 @@ const name = " Daniel "; - +var noSpaceName = name.trim(); +var nameLength = noSpaceName.length; +var messagePart; +if (noSpaceName.length === 1) { + var messagePart = "character"; +} else { + var messagePart = "characters"; +} +var message = + "My name is " + + noSpaceName + + " and my name is " + + nameLength + + " " + + messagePart + + " long."; console.log(message); From 96a770b5f2aa761cc9e872e16232db50acdc96ea Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 22:50:40 +0100 Subject: [PATCH 11/22] exercise_G_numbers_exercise_done --- exercises/G-numbers/exercise.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/exercises/G-numbers/exercise.js b/exercises/G-numbers/exercise.js index 49e7bc00b..b787d49bb 100644 --- a/exercises/G-numbers/exercise.js +++ b/exercises/G-numbers/exercise.js @@ -1 +1,9 @@ // Start by creating a variables `numberOfStudents` and `numberOfMentors` +let numberOfStudents = 15; +let 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 6610613677bb00a4a4ae7314898a088ea5d943ad Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 23:18:03 +0100 Subject: [PATCH 12/22] exercises_I_floats_exercise_done --- exercises/I-floats/exercise.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/exercises/I-floats/exercise.js b/exercises/I-floats/exercise.js index a5bbcd852..f88fe01b8 100644 --- a/exercises/I-floats/exercise.js +++ b/exercises/I-floats/exercise.js @@ -1,2 +1,11 @@ var numberOfStudents = 15; var numberOfMentors = 8; +let total = numberOfStudents + numberOfMentors; +function percentageOf(num) { + var precisePercentage = (num / total) * 100; + let roughPercentage = Math.round(precisePercentage); + return roughPercentage; +} + +console.log("Percentage students: " + percentageOf(numberOfStudents) + "%"); +console.log("Percentage mentors: " + percentageOf(numberOfMentors) + "%"); From 8c5305b4ae6270d902b92963d2832dae0bb9cab2 Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 23:20:27 +0100 Subject: [PATCH 13/22] exercises_J_functions_exercise1_done --- exercises/J-functions/exercise.js | 1 + 1 file changed, 1 insertion(+) diff --git a/exercises/J-functions/exercise.js b/exercises/J-functions/exercise.js index 0ae5850e5..99898ae3c 100644 --- a/exercises/J-functions/exercise.js +++ b/exercises/J-functions/exercise.js @@ -1,4 +1,5 @@ function halve(number) { + return number / 2; // complete the function here } From 782080c3008bfa57806c139901788acaa0b34174 Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 23:21:23 +0100 Subject: [PATCH 14/22] exercises_J_functions_exercise2_done --- exercises/J-functions/exercise2.js | 1 + 1 file changed, 1 insertion(+) diff --git a/exercises/J-functions/exercise2.js b/exercises/J-functions/exercise2.js index 82ef5e780..75d1c2f90 100644 --- a/exercises/J-functions/exercise2.js +++ b/exercises/J-functions/exercise2.js @@ -1,4 +1,5 @@ function triple(number) { + return number * 3; // complete function here } From 5ebed6e315a2fbbfa9ccaaa0eabc7c008b36f374 Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 23:23:17 +0100 Subject: [PATCH 15/22] exercises_K_functions_exercise1_done --- exercises/K-functions-parameters/exercise.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exercises/K-functions-parameters/exercise.js b/exercises/K-functions-parameters/exercise.js index 8d5db5e69..cb0b0d927 100644 --- a/exercises/K-functions-parameters/exercise.js +++ b/exercises/K-functions-parameters/exercise.js @@ -1,5 +1,6 @@ // Complete the function so that it takes input parameters -function multiply() { +function multiply(num1, num2) { + return num1 * num2; // Calculate the result of the function and return it } From 6ef4cf9ef7f6d7fce591497b867df0b12ae5bd61 Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 23:24:30 +0100 Subject: [PATCH 16/22] exercises_K_functions_exercise2_done --- exercises/K-functions-parameters/exercise2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exercises/K-functions-parameters/exercise2.js b/exercises/K-functions-parameters/exercise2.js index db7a8904b..8f0f0680b 100644 --- a/exercises/K-functions-parameters/exercise2.js +++ b/exercises/K-functions-parameters/exercise2.js @@ -1,5 +1,7 @@ // Declare your function first - +function divide(num1, num2) { + return num1 / num2; +} var result = divide(3, 4); console.log(result); From 49f9b75985bdc1d09ba0608de9ea61eff3e1c340 Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 23:26:30 +0100 Subject: [PATCH 17/22] exercises_K_functions_exercise3_done --- exercises/K-functions-parameters/exercise3.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/exercises/K-functions-parameters/exercise3.js b/exercises/K-functions-parameters/exercise3.js index 537e9f4ec..8aaea4624 100644 --- a/exercises/K-functions-parameters/exercise3.js +++ b/exercises/K-functions-parameters/exercise3.js @@ -1,5 +1,9 @@ // Write your function here +function createGreeting(name) { + return "Hello, my name is " + name; +} + var greeting = createGreeting("Daniel"); console.log(greeting); From 9d64433120861e2bd3f1a6ab99bdd4b09dcd0dcd Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 23:28:21 +0100 Subject: [PATCH 18/22] exercises_K_functions_exercise4_done --- exercises/K-functions-parameters/exercise4.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/exercises/K-functions-parameters/exercise4.js b/exercises/K-functions-parameters/exercise4.js index 7ab44589e..0e5a78614 100644 --- a/exercises/K-functions-parameters/exercise4.js +++ b/exercises/K-functions-parameters/exercise4.js @@ -1,5 +1,9 @@ // Declare your function first +function add(num1, num2) { + return num1 + num2; +} // Call the function and assign to a variable `sum` +let sum = add(13, 124); console.log(sum); From 37d87c4f02bd6650161ae93dfcb30c0ec5cc067c Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 23:34:32 +0100 Subject: [PATCH 19/22] exercises_K_functions_exercise5_done --- exercises/K-functions-parameters/exercise5.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/exercises/K-functions-parameters/exercise5.js b/exercises/K-functions-parameters/exercise5.js index 7c5bcd605..1b8bd1499 100644 --- a/exercises/K-functions-parameters/exercise5.js +++ b/exercises/K-functions-parameters/exercise5.js @@ -1,5 +1,17 @@ // Declare your function here -const greeting = createLongGreeting("Daniel", 30); +function createLongGreeting(name, age) { + let ageGreet; + if (age === 1) { + ageGreet = "year"; + } else { + ageGreet = "years"; + } + return ( + "Hello, my name is " + name + " and I'm " + age + " " + ageGreet + " old" + ); +} + +const greeting = createLongGreeting("Daniel", 20); console.log(greeting); From 396dc972e0f605fe9034777aa62a93d410059c3e Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Fri, 13 Aug 2021 23:42:24 +0100 Subject: [PATCH 20/22] exercises_L_functions_exercise_done --- exercises/L-functions-nested/exercise.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/exercises/L-functions-nested/exercise.js b/exercises/L-functions-nested/exercise.js index a5d377442..b8449b254 100644 --- a/exercises/L-functions-nested/exercise.js +++ b/exercises/L-functions-nested/exercise.js @@ -3,3 +3,13 @@ var mentor2 = "Irina"; var mentor3 = "Mimi"; var mentor4 = "Rob"; var mentor5 = "Yohannes"; + +function shoutGreeting(name) { + return "HELLO " + name.toUpperCase(); +} + +console.log(shoutGreeting(mentor1)); +console.log(shoutGreeting(mentor2)); +console.log(shoutGreeting(mentor3)); +console.log(shoutGreeting(mentor4)); +console.log(shoutGreeting(mentor5)); From ef774857cc20917cef0991a6ec77dc0db83bf34c Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Sat, 14 Aug 2021 01:10:33 +0100 Subject: [PATCH 21/22] extra_1_and_2 --- extra/1-currency-conversion.js | 11 ++++++++--- extra/2-piping.js | 16 ++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/extra/1-currency-conversion.js b/extra/1-currency-conversion.js index d82e59480..9a94f4b1a 100644 --- a/extra/1-currency-conversion.js +++ b/extra/1-currency-conversion.js @@ -5,7 +5,9 @@ Write a function that converts a price to USD (exchange rate is 1.4 $ to £) */ -function convertToUSD() {} +function convertToUSD(num) { + return num * 1.4; +} /* CURRENCY CONVERSION @@ -15,12 +17,15 @@ function convertToUSD() {} They have also decided that they should add a 1% fee to all foreign transactions, which means you only convert 99% of the £ to BRL. */ -function convertToBRL() {} +function convertToBRL(num) { + let result = num * 0.99 * 5.7; + return Number(result.toFixed(2)); +} /* ======= TESTS - DO NOT MODIFY ===== There are some Tests in this file that will help you work out if your code is working. -To run these tests type `npm run extraTo run the tests for just this one file, type `npm run extra-tests -- --testPathPattern 1-syntax-errors` into your terminal +To run these tests type `npm run extraTo run the tests for just this one file, type `npm run extra-tests -- --testPathPattern 1-syntax-errors` correct path: `npm run extra-tests -- --testPathPattern 1-currency-conversion` into your terminal (Reminder: You must have run `npm install` one time before this will work!) */ diff --git a/extra/2-piping.js b/extra/2-piping.js index 9c8ebc76a..a673525ad 100644 --- a/extra/2-piping.js +++ b/extra/2-piping.js @@ -16,26 +16,26 @@ the final result to the variable goodCode */ -function add() { - +function add(num1, num2) { + return num1 + num2; } -function multiply() { - +function multiply(num1, num2) { + return num1 * num2; } -function format() { - +function format(num) { + return "£" + num; } const startingValue = 2; // Why can this code be seen as bad practice? Comment your answer. -let badCode = +let badCode = format(24); /* BETTER PRACTICE */ -let goodCode = +let goodCode = format(24); /* ======= TESTS - DO NOT MODIFY ===== There are some Tests in this file that will help you work out if your code is working. From 249150d2325edaa7f0f8dc22dfe911893c16ec90 Mon Sep 17 00:00:00 2001 From: Roman-Hal <85693082+Roman-Hal@users.noreply.github.com> Date: Sat, 14 Aug 2021 23:12:23 +0100 Subject: [PATCH 22/22] extra_3_magic_8_ball_done --- extra/3-magic-8-ball.js | 47 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/extra/3-magic-8-ball.js b/extra/3-magic-8-ball.js index f3adbefa5..02a03b72c 100644 --- a/extra/3-magic-8-ball.js +++ b/extra/3-magic-8-ball.js @@ -43,9 +43,41 @@ Very doubtful. */ + + // This should log "The ball has shaken!" // and return the answer. function shakeBall() { + + listOfAnswers = [ + "It is certain", + "It is decidedly so.", + "Without a doubt.", + "Yes - definitely.", + "You may rely on it.", + "As I see it, yes.", + "Most likely.", + " Outlook good.", + "Yes.", + "Signs point to yes.", + "Reply hazy, try again.", + "Ask again later.", + "Better not tell you now.", + "Cannot predict now.", + "Concentrate and ask again.", + "Don't count on it.", + "My reply is no.", + "My sources say no.", + "Outlook not so good.", + "Very doubtful.", +]; + +var randomNumber = Math.floor(Math.random() * 20); + + console.log("The ball has shaken!"); + + var answer = listOfAnswers[randomNumber]; + return answer; //Write your code in here } @@ -59,6 +91,17 @@ function shakeBall() { This function should expect to be called with any value which was returned by the shakeBall function. */ function checkAnswer(answer) { + var shortMessage; + if (listOfAnswers.indexOf(answer) >= 0 && listOfAnswers.indexOf(answer) <= 4 ) { + shortMessage = "very positive"; + } else if (listOfAnswers.indexOf(answer) >= 5 && listOfAnswers.indexOf(answer) <= 9) { + shortMessage = "positive"; + } else if (listOfAnswers.indexOf(answer) >= 10 && listOfAnswers.indexOf(answer) <= 14) { + shortMessage = "negative"; + } else if (listOfAnswers.indexOf(answer) >= 15 && listOfAnswers.indexOf(answer) <= 19) { + shortMessage = "very negative"; + } + return shortMessage; //Write your code in here } @@ -101,7 +144,9 @@ test("magic 8 ball returns different values each time", () => { ); } - let seenPositivities = new Set(Array.from(seenAnswers.values()).map(checkAnswer)); + let seenPositivities = new Set( + Array.from(seenAnswers.values()).map(checkAnswer) + ); if (seenPositivities.size < 2) { throw Error( "Expected to random answers with different positivities each time shakeBall was called, but always got the same one"