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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 1-exercises/A-array-find/exercise.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
You are given an array of names.
Using .find(), we'd like to find the first name which starts with A and is longer than 7 letters.
*/
Expand Down
5 changes: 5 additions & 0 deletions 1-exercises/D-array-filter/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ let pairs = pairsByIndex.map(function (indexes) {
});

console.log(pairs);

/* EXPECTED RESULT
[ [ 'Islam', 'Luke' ], [ 'Lesley', 'Mozafar' ], [ 'Harun', 'Irina' ] ]
*/
9 changes: 9 additions & 0 deletions 1-exercises/E-array-map/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@
// Write multiple solutions using different syntax (as shown in the README)

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

let numbersMultipliedByOneHundred; // complete this statement

console.log(numbersMultipliedByOneHundred);

/* EXPECTED RESULT
[10, 20, 30, 40, 50]
*/
6 changes: 3 additions & 3 deletions 2-mandatory/2-oxygen-levels.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
Many years into the future, a team of Space Voyagers find their ship is low on Oxygen and need to dock
somewhere safe while they call home for help.

Their computer detects a list of nearby planets that have Oxygen in their atmosphere.

To be safe, they need to land on the first unnamed planet that has Oxygen levels between 19.5% and 23.5%.

Write a function that finds the oxygen level of the first safe planet - Oxygen between 19.5% and 23.5%

Some string methods that might help you here are .replace() and .substring().
Some string methods that might help you here are .replace() and .substring().
*/

function findSafeOxygenLevel() {}
Expand All @@ -33,6 +33,6 @@ test("findSafeOxygenLevel function filters out invalid percentages", () => {
).toEqual("21.1%");
});

test("findSafeOxygenLevel function returns undefined if no valid plants found", () => {
test("findSafeOxygenLevel function returns undefined if no valid planets found", () => {
expect(findSafeOxygenLevel(["50"])).toBeUndefined();
});
44 changes: 22 additions & 22 deletions 2-mandatory/6-journey-planner.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Before we go the big story; we will introduce more string methods.
Some of the methods you're using in Array have similar ones with strings.
Methods like : IndexOf, Include, Search, Slice , Spilt and more.
You can always google how a method of a string works!
Before we go to the big story, we will introduce some more string methods.
Some of the methods you're using on arrays are similar to ones you can use on strings.
Methods like: IndexOf, Include, Search, Slice , Spilt and more.
You can always Google how a method of a string works!
Here are links to some of those:
- https://www.w3schools.com/js/js_string_methods.asp
- https://javascript.info/string#quotes
Now let's do this small exercise
Using string methods update the checkCodeIsThere() function
- The function will have a string as a paramter
- The function should check if the string has the word "code" exists in the string
- The function should check if the word "code" exists in the string
- If it does exist, return the index of it, if not return "Not found"
Hint: search for string methods like Includes and IndexOf.
Expand All @@ -32,27 +32,27 @@ function checkCodeIsThere(stringText) {
The input provided contains a list of locations in London. Each of locations is followed by a list
of transport modes that can be used to get there.
Let's see an example:
To take to Tower Bridge, you can use tube or river boat. This information will represented as
To take to Tower Bridge, you can use tube or river boat. This information will represented as
["Tower Bridge", "tube", "river boat"]
Where
the 1st element says the name of the location,
and rest of them says the transport modes.
and rest of them say the transport modes.
You will then get a list of these information, e.g:
You will then get a list of this information, e.g:
[
["Tower Bridge", "tube", "river boat"],
["Abbey road", "double decker"],
["London Eye", "tube", "river boat", "bus"]
]
You have to finish up the body of journeyPlanner function that should tell where I can go if I only
You have to finish up the body of journeyPlanner function that should tell me where I can go if I only
want to use a specific mode of transport. But before jumping straight to the main function, we will
break down the whole task into smaller steps that make our job easier.
This technic is also referred as "problem decomposition". It helps you to reduce scope of the problem
by only focusing on a small chunk of the whole problem at a time.)
This technique is also referred to as "problem decomposition". It helps you to reduce the scope of the problem
by only focusing on a small chunk of the whole problem at a time.
*/

/*
Expand All @@ -61,7 +61,7 @@ function checkCodeIsThere(stringText) {
e.g: ["Tower Bridge", "tube", "river boat"]
- Returns an array including the available transport modes to the given location
e.g: ["tube", "river boat"]
Hint: Use the corresponding array method to split the array.
*/
function getTransportModes() {}
Expand All @@ -74,12 +74,12 @@ function getTransportModes() {}
e.g: ["tube", "river boat"]
2) Second parameter is a string containing a transport mode
e.g: "river boat"
- Returns
- Returns
* True if the location in the first parameter is accessible by the transport mode given in second parameter
* Otherwise, returns false
Hint: Use the corresponding array method to decide if an element is member of an array.
Hint: Use the corresponding array method to decide if an element is included in an array.
*/
function isAccessibleByTransportMode() {}

Expand Down Expand Up @@ -113,12 +113,12 @@ function getLocationName() {}
- Returns an array of where I can go if I only want to use a specific mode of transport.
NOTE: only the location names should be returned, not the name of transports.
HINTS:
- Use the function you implemented above.
- Use array method to remove locations that is not accessible by the given transportMode.
- Use array method to remove locations that are not accessible by the given transportMode.
- Use array method to manipulate its elements.
Advanced challange: try to use arrow function when invoking an array method.
*/
function journeyPlanner(locations, transportMode) {
Expand Down