Skip to content
This repository has been archived by the owner on Oct 26, 2020. It is now read-only.

Bashir week 7 #1011

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
d0eb2ef
added notes to w2-j4
Ashaghel Apr 26, 2020
c30ee0f
Hakona Matata Anthony and Ahmad
Ashaghel Apr 26, 2020
74e3f46
fix minor spelling and grammatical errors
Apr 27, 2020
6fcaeb5
editing exercises for week3 mcr3
Ashaghel May 1, 2020
468db41
Update 5-journey-planner.js
Ashaghel May 2, 2020
6163944
Update 0- Introduction.md
Ashaghel May 2, 2020
9346bcb
added info on every and some to exercise 2
Augs0 May 2, 2020
960c002
fixed formatting
Augs0 May 2, 2020
c5786a9
added info on replace and substring
Augs0 May 2, 2020
eb54bc5
Modify description and add extra tests to exercise week-3/4-eligible-…
zoltan-gal May 2, 2020
191b122
fix syntax
zoltan-gal May 2, 2020
e20bef6
Add extra exercise to week-3/4-eligible-students
zoltan-gal May 2, 2020
7905332
added small note
Ashaghel May 2, 2020
6c489f4
Added more instructions
Ashaghel May 2, 2020
ce4cdb0
changed function name
Ashaghel May 2, 2020
46747c0
Update 6-lane-names.js
Ashaghel May 2, 2020
1422133
formating
Ashaghel May 2, 2020
4feab6b
Add more details and restructure journey planner exercise
zoltan-gal May 2, 2020
349fee5
Reformatting journey planner description
zoltan-gal May 2, 2020
fe6726a
Add extra challange tip to journey planner
zoltan-gal May 2, 2020
9678006
Add examples and tweak descriptions
zoltan-gal May 2, 2020
222a34b
tweak week-3 intro description
zoltan-gal May 2, 2020
ccc11b5
tweak week-3 intro description
zoltan-gal May 2, 2020
7a91d2e
fix text
zoltan-gal May 2, 2020
1a7abaf
Improve examples in ex4
zoltan-gal May 2, 2020
e84f22f
Merge remote-tracking branch 'origin/master' into manchester3
zoltan-gal May 15, 2020
f8f41b0
more info
Ashaghel May 16, 2020
68f6d79
Create forinLoop.js
Ashaghel May 16, 2020
57dc8b0
Select freecodecamp resource list
zoltan-gal May 16, 2020
891b2aa
Add extra exercise and description to writers exercise
zoltan-gal May 16, 2020
e50722e
Add extra exercises to water bottle exercise
zoltan-gal May 16, 2020
02492c9
Remove extra resources recommendations that have not been taught yet
zoltan-gal May 16, 2020
394aab1
Merge branch 'manchester3' of github.com:CodeYourFuture/js-exercises …
zoltan-gal May 16, 2020
1feffbe
Rewrite grocery list exercise
zoltan-gal May 16, 2020
4a1fa48
Fix week-4 exercise issues
zoltan-gal May 16, 2020
a3c1d0c
more reading
Ashaghel May 16, 2020
393cab1
Update 1-freecodecamp.md
Ashaghel May 16, 2020
05218bc
Update extra-homework.md
Ashaghel May 16, 2020
f836b89
Update 1-freecodecamp.md
Ashaghel May 16, 2020
90f6f0b
Update 1-freecodecamp.md
Ashaghel May 16, 2020
a4055ca
Update 1-freecodecamp.md
Ashaghel May 16, 2020
e559c9a
Update 2-writers.js
Ashaghel May 16, 2020
9b87a3e
fix description
zoltan-gal May 17, 2020
793cd96
tweak description
zoltan-gal May 17, 2020
1d25f8e
Update 2-writers.js
May 19, 2020
55efde1
fix wording
zoltan-gal May 20, 2020
27ce362
Rewrite week-5/2-exercises
zoltan-gal May 29, 2020
f555e27
Rewrite week-5/3-project
zoltan-gal May 29, 2020
6053f8e
tweak khanakademy hw descriptions
zoltan-gal May 29, 2020
37bc38e
add extra description to week-5, exercise 3
zoltan-gal May 30, 2020
6409675
fix link
zoltan-gal May 31, 2020
b92dcd4
Merge remote-tracking branch 'origin/master' into manchester3
zoltan-gal Jun 6, 2020
ff6e285
Update week-6 exercise description
zoltan-gal Jun 6, 2020
723a0c2
Submit week 6
bash93 Jul 2, 2020
ff9bb88
Submit week 7
bash93 Jul 2, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
*/
// `getStations` goes here


/* ======= TESTS - DO NOT MODIFY ======= */

function getAvailableStations() {
Expand All @@ -36,10 +35,10 @@ function getAvailableStations() {
const stationCount = 4;
getAvailableStations.stations = new Array(stationCount)
.fill(undefined)
.map(function() {
.map(function () {
return Math.floor(Math.random() * (108 - 87 + 1) + 87);
})
.sort(function(frequencyA, frequencyB) {
.sort(function (frequencyA, frequencyB) {
return frequencyA - frequencyB;
});
}
Expand All @@ -64,7 +63,7 @@ function test(testName, fn) {
}
}

test("getAllFrequencies() returns all frequencies between 87 and 108", function() {
test("getAllFrequencies() returns all frequencies between 87 and 108", function () {
const frequencies = getAllFrequencies();
assert.deepStrictEqual(frequencies, [
87,
Expand All @@ -88,7 +87,7 @@ test("getAllFrequencies() returns all frequencies between 87 and 108", function(
105,
106,
107,
108
108,
]);
});

Expand Down
35 changes: 35 additions & 0 deletions week-2/Homework/extra/2-array-methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Following are set of small functions that you need to create using loops and array methods

*/
//1)Find the Smallest Number in an Array
//Create a function that takes an array of numbers and return the smallest number in it

function findSmallestNum(arr) {}

findSmallestNum([354, 15, 114, 2]); //Expected: 2

findSmallestNum([-76, 1, -79, 1, 0]); //Expected: -79

//2)Checking Even Numbers
//Create a function that takes in an array and returns true if all its values are even, and false otherwise.
function checkAllEven(arr) {}

checkAllEven([1, 2, 2, 6, 9, 4]); //Expected: false

checkAllEven([2, 4, 6]); //Expected: true
//3)Half, Quarter and Eighth
//Create a function that takes a number and return an array of three numbers: half of the number, quarter of the number and an eighth of the number.
function getHalfQuarterEighth(number) {}
getHalfQuarterEighth(6); //Expected:[3, 1.5, 0.75]

//4)Add the index to the number
//Given an array of numbers, create a function which returns the same array but with each element's index in the array added to itself. This means you add 0 to the number at index 0, add 1 to the number at index 1, etc...
function addIndexes(arr) {}
addIndexes([1, 4, 3, 4, 5]); //Expected: [1, 5, 5, 7, 9]

//4)Get the Sum of All Array Elements
//Create a function that takes an array and returns the sum of all numbers in the array.
function getSumOfItems(arr) {}

getSumOfItems([-2, 84, 23]); //Expected: 105
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
## FreeCodeCamp
# Introducion

## Instructions

- Just making the tests become `passed` is not enough, you need to use the code already there, to help answer your the task properly
- Read instructions in the README.md on how to make correct PRs to the main repo
- Remember to use Google as much as you can help

**Good Luck! Keep calm and code along**

## Resources

To get a better understanding of loops and arrays

- [while and for loops](https://javascript.info/while-for)
- [arrays](https://javascript.info/array)

## Freecodecamp

If you haven't already, you should complete all of these lessons on FreeCodeCamp - https://www.freecodecamp.org/learn

Expand Down
35 changes: 31 additions & 4 deletions week-2/Homework/mandatory/1-fix-functions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
// Fix Functions

// Aim: to understand the change code inside functions
//
// The below functions are syntactically correct but not outputting the right results.
// Look at the tests and see how you can fix them.



// 1) mood function does this return `"I am not happy"`
// Only make edits inside the function

function mood() {
let isHappy = true;

Expand All @@ -11,9 +20,13 @@ function mood() {
}
}

// 2) For any numerical value greater or equal to 10
// Hint: use constant `num` and only change isBigEnough.
// Variable isBigEnough needs to evaluate to a boolean

function greaterThan10() {
let num = 10;
let isBigEnough;
const num = 10;
const isBigEnough;

if (isBigEnough) {
return "num is greater than or equal to 10";
Expand All @@ -22,20 +35,34 @@ function greaterThan10() {
}
}

// 3) For any numerical value greater or equal to 10
// Hint: use the Array method sort()
// Remember to Google how to use sort method

function sortArray() {
let letters = ["a", "n", "c", "e", "z", "f"];
const letters = ["a", "n", "c", "e", "z", "f"];
let sortedLetters;

return sortedLetters;
}

// 4) first5 function should return the first 5 elements of array
// Hint: use the Array method splice()
// Remember to Google how to use splice()

function first5() {
let numbers = [1, 2, 3, 4, 5, 6, 7, 8];
let sliced;

return sliced;
}

// 5) get3rdIndex function needs to take an array `arr` and give
// back third element value.
// For example with array `[1, 2, 3, 4, 5]` it needs to return `4`
//
// Hint: remember that arrays are zero-index based

function get3rdIndex(arr) {
let index = 3;
let element;
Expand Down Expand Up @@ -82,7 +109,7 @@ test("first5 function works", arraysEqual(first5(), [1, 2, 3, 4, 5]));
test(
"get3rdIndex function works - case 1",
get3rdIndex(["fruit", "banana", "apple", "strawberry", "raspberry"]) ===
"strawberry"
"strawberry"
);
test(
"get3rdIndex function works - case 2",
Expand Down
12 changes: 5 additions & 7 deletions week-2/Homework/mandatory/2-function-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ Write a function that:
- numbers greater 100 must be replaced with 100
*/

function formatPercentage(arr) {

}
function formatPercentage(arr) {}

/* ======= TESTS - DO NOT MODIFY ===== */

Expand Down Expand Up @@ -72,7 +70,7 @@ test(
"daniel",
"irina",
"gordon",
"ashleigh"
"ashleigh",
])
);
test(
Expand Down Expand Up @@ -101,7 +99,7 @@ test(
"c",
"d",
"e",
"f"
"f",
])
);

Expand All @@ -111,6 +109,6 @@ test(
"23%",
"18%",
"100%",
"0.37%"
"0.37%",
])
);
);
10 changes: 8 additions & 2 deletions week-2/Homework/mandatory/3-playing-computer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Playing computer
//
// Aim: to understand and predict the answers of loops, and if statmetns
//
// You need write the answers of the below questions 1-7

/*
You have to predict the output of this program WITHOUT EXECUTING IT.

Expand All @@ -18,11 +24,11 @@
let x = 2;
let a = 6;

const f1 = function(a, b) {
const f1 = function (a, b) {
return a + b;
};

const f2 = function(a, b) {
const f2 = function (a, b) {
return a + b + x;
};

Expand Down
14 changes: 11 additions & 3 deletions week-2/Homework/mandatory/4-sorting-algorithm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Sorting Algorithms
//
// Aim: to understand the work of loops and nested loops and array methods
//
// You need to create the function sortAges that takes one array as parameter input

/*
At the start of the course, you worked in teams to sort your team members, labelled by
numbers, in ascending or descending order.
Expand All @@ -6,15 +12,17 @@ Today, you will be applying the sorting algorithm you used in that exercise in c

Create a function called sortAges which:
- takes an array of mixed data types as input
- removes any non-number data types without using the built-in javascript filter method
- removes any non-number data types without using the built-in javascript filter method
- returns an array of sorted ages in ascending order
- HARD MODE - without using the built-in javascript sort method 😎

You don't have to worry about making this algorithm work fast! The idea is to get you to
"think" like a computer and practice your knowledge of basic JavaScript.
*/

function sortAges(arr) {}
//1)Create the function inside, Think about nested loops
function sortAges(arr) {
//create function here
}

/* ======= TESTS - DO NOT MODIFY ===== */

Expand Down
35 changes: 0 additions & 35 deletions week-3/Homework/extra/1-card-vailidator.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

You should complete all of these FreeCodeCamp exercises - https://www.freecodecamp.org/learn

Go to **JavaScript Algorithms and Data Structures Certification (300 hours)**

Open section **Basic Data Structures** and do the following exercises

- Introduction to the Basic Data Structure Challenges
- Use an Array to Store a Collection of Data
- Access an Array's Contents Using Bracket Notation
Expand All @@ -15,16 +19,8 @@ You should complete all of these FreeCodeCamp exercises - https://www.freecodeca
- Check For The Presence of an Element With indexOf()
- Iterate Through All an Array's Items Using For Loops
- Create complex multi-dimensional arrays
- Add Key-Value Pairs to JavaScript Objects
- Modify an Object Nested Within an Object
- Access Property Names with Bracket Notation
- Use the delete Keyword to Remove Object Properties
- Check if an Object has a Property
- Iterate Through the Keys of an Object with a for...in Statement
- Generate an Array of All Object Keys with Object.keys()
- Modify an Array Stored in an Object

and you should attempt all of these
Then open **Basic Algorithm Scripting** and attempt all of these

- Convert Celsius to Fahrenheit
- Reverse a String
Expand Down
18 changes: 18 additions & 0 deletions week-3/Homework/mandatory/1-oxygen-levels.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,26 @@ Their computer detects a list of nearby planets that have Oxygen in their atmosp
To be safe, they need to land on the first unamed 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(). Let's look at a quick
example before trying the exercise.
*/

/* .replace() allows us to add something where we removed something*/
let greeting = "Good Morning";
greeting.replace('Morning', 'Evening'); // outputs Good Evening


/* .substring() allows us to remove things from strings */
let dessert = "ice cream and pancakes";

let newdessert = dessert.substring(0, 9);

console.log(newdessert); // returns ice cream

/* + + + + + + + */
/* Now try the exercise */

function safeLevels() {

}
Expand Down
20 changes: 19 additions & 1 deletion week-3/Homework/mandatory/2-bush-berries.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,25 @@
Create a function which checks if the bush has ALL PINK berries and is safe for the astronauts to eat from the bush.

Use the tests to confirm which message to return
*/

This exercise can be solved in a few different ways. One way might include the array methods
.some() and .every(). The .some() method tests to see if some of the values (at least 1) in an array
match what you're looking for and returns true or false. .every() will only return true
if all values match watch you're looking for. Let's first look at an example that will
teach you how to use these methods.
*/

let array = [12, 73, 92, 45, 100, 14, 61];

array.some((value) => {return (value % 2 == 0)}); /* this will return true as SOME values
will have a remainder of 0 i.e. they are even numbers*/

array.every((value) => {return (value % 2 == 0)}); /* this will return false as not ALL
values will have a remainder of 0 i.e. there are some odd numbers in the array too*/

/* + + + + + + + + + + + + + + */

/* Now try to complete the exercise */

function bushChecker() {

Expand Down
Loading