Skip to content
This repository was archived by the owner on Oct 26, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
34bd935
js syntax-errors
mara-ber Apr 26, 2020
ff6d181
js 2-logic-error
mara-ber Apr 30, 2020
a9e6e53
js 3-function-output
mara-ber Apr 30, 2020
5315f50
js 4-tax
mara-ber Apr 30, 2020
088f8b0
js 5-magic-8-ball
mara-ber Apr 30, 2020
04e479a
js-extra 1-currency-conversion
mara-ber Apr 30, 2020
3803243
Use last year's exercises for scotland class 4
May 2, 2020
dd4a1b2
Add Loops exercises
May 2, 2020
5eee5fb
Add expected result to while loop exercise
May 2, 2020
1b05858
Remove array method exercises
May 2, 2020
faac018
Add more While loop exercises
May 2, 2020
da65354
Revert "Add more While loop exercises"
May 2, 2020
8e466c8
Working while exercises
May 2, 2020
412666e
homework
May 3, 2020
0ac118b
Revert "homework"
May 3, 2020
18476ec
week-2-1-fix-functions
mara-ber May 3, 2020
b19f2f7
js-extra 2-piping.js
mara-ber May 3, 2020
c4f12f2
Add Old Homework To Scotland Class 4 Branch (#852)
May 12, 2020
b81a28e
week2-man/2
mara-ber May 14, 2020
8499fee
restructure homework
rarmatei May 24, 2020
a64e1f3
simplify homework
rarmatei May 25, 2020
dd6f0dc
remote this keyword from homework
rarmatei May 25, 2020
37f6e1e
Merge pull request #878 from rarmatei/class4-js-wk-4
rarmatei May 28, 2020
c603c7b
update homework
rarmatei May 29, 2020
d6bed7c
update
rarmatei May 29, 2020
2b0206a
add itworked file
rarmatei May 30, 2020
d04abf9
Merge branch 'scotland-class4' of github.com:CodeYourFuture/js-exercises
mara-ber May 30, 2020
7b33f98
move exercises for week5
rarmatei Jun 5, 2020
ff90e30
add images to exercise 1 homework
rarmatei Jun 5, 2020
fd49d01
add image links
rarmatei Jun 5, 2020
53c9feb
add task 6
rarmatei Jun 5, 2020
b1add69
move khanacademy back into mandatory
rarmatei Jun 6, 2020
bfe03e6
Merge branch 'scotland-class4' of github.com:CodeYourFuture/js-exercises
mara-ber Jun 6, 2020
a473f31
Merge branch 'master' of github.com:CodeYourFuture/js-exercises into …
rarmatei Jun 9, 2020
b4eb201
restructure week6
rarmatei Jun 9, 2020
3e32b89
simplify exercise 1
rarmatei Jun 12, 2020
72e3e21
simplify dom exercise
rarmatei Jun 12, 2020
5283e47
hide movie loader
rarmatei Jun 12, 2020
c0c8b8b
add more exercise details
rarmatei Jun 12, 2020
6df8c05
not finnished week5
mara-ber Jun 13, 2020
16af22a
Merge branch 'scotland-class4' of github.com:CodeYourFuture/js-exercises
mara-ber Jun 13, 2020
d8d5674
Week-7 add InClass Exercises
r-darby Jun 27, 2020
ab5d0b5
Merge branch 'scotland-class4' of github.com:CodeYourFuture/js-exercises
mara-ber Jun 27, 2020
9e1c70f
week-7 inClass
mara-ber Jun 27, 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
Binary file modified .DS_Store
Binary file not shown.
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}"
}
]
}
9 changes: 6 additions & 3 deletions week-1/Homework/extra/1-currency-conversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
Write a function that converts a price to USD (exchange rate is 1.4 $ to £)
*/

function convertToUSD() {}
function convertToUSD(pricePound) {
return pricePound * 1.4;
}

/*
CURRENCY FORMATTING
===================
The business is now breaking into the Brazilian market
Write a new function for converting to the Brazilian real (exchange rate is 5.7 BRL to £)
They have also decided that they should add a 1% fee to all foreign transactions
Find a way to add 1% to all currency conversions (think about the DRY principle)
*/

function convertToBRL() {}
function convertToBRL(pricePound) {
return (pricePound * 1.01) * 5.7;
}

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

Expand Down
19 changes: 13 additions & 6 deletions week-1/Homework/extra/2-piping.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,33 @@
the final result to the variable goodCode
*/

function add() {

}

function multiply() {
function add(a, b) {
const sum = Math.round((a + b) * 10) / 10;
return sum;
}

function multiply(a, b) {
return a * b;
}

function format() {
function format(a) {
return "£" + a;

}

const startingValue = 2

// Why can this code be seen as bad practice? Comment your answer.
let badCode =
let badCode = format(multiply(add(startingValue, 10), 2));

/* BETTER PRACTICE */

let goodCode =
addValue = add(startingValue, 10);
multiplyValue = multiply(addValue, 2);

let goodCode = format(multiplyValue);

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

Expand Down
12 changes: 7 additions & 5 deletions week-1/Homework/mandatory/1-syntax-errors.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
// 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 getRemainder(a, b) {
remainder = a %% b;
remainder = a % b;


// Use string interpolation here
return "The remainder is %{remainder}"
return `The remainder is ${remainder}`;
}

/* ======= TESTS - DO NOT MODIFY ===== */
Expand Down
7 changes: 3 additions & 4 deletions week-1/Homework/mandatory/2-logic-error.js
Original file line number Diff line number Diff line change
@@ -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 getWordLength(word) {
return "word".length()
return word.length;
}

function multiply(a, b, c) {
a * b * c;
return;
return a * b * c;
}

/* ======= TESTS - DO NOT MODIFY ===== */
Expand Down
3 changes: 3 additions & 0 deletions week-1/Homework/mandatory/3-function-output.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
// Add comments to explain what this function does. You're meant to use Google!
//Takes a random number between 0 (included) and 1 (excluded) and multiply it on 10
function getNumber() {
return Math.random() * 10;
}

// Add comments to explain what this function does. You're meant to use Google!
//concatenates the string arguments to the calling string and returns a new string.
function s(w1, w2) {
return w1.concat(w2);
}

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 to expect in return
return `${firstWord} ${secondWord} ${thirdWord}`
}

/* ======= TESTS - DO NOT MODIFY ===== */
Expand Down
10 changes: 8 additions & 2 deletions week-1/Homework/mandatory/4-tax.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
Sales tax is 20% of the price of the product
*/

function calculateSalesTax() {}
function calculateSalesTax(amount) {
return amount * 1.2;
}

/*
CURRENCY FORMATTING
Expand All @@ -17,7 +19,11 @@ function calculateSalesTax() {}
Remember that the prices must include the sales tax (hint: you already wrote a function for this!)
*/

function formatCurrency() {}
function formatCurrency(amount) {
const price = calculateSalesTax(amount);
return "£" + price.toFixed(2);
}


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

Expand Down
35 changes: 33 additions & 2 deletions week-1/Homework/mandatory/5-magic-8-ball.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,20 @@ Very doubtful.

// This should log "The ball has shaken!"
// and return the answer.
function shakeBall() {}
function shakeBall(question) {
console.log("The ball has shaken!");
const array1 = ["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."];
let answer = array1[Math.floor(Math.random() * array1.length)];
return answer;
}



// The answer should come from shaking the ball
let answer;
Expand All @@ -55,7 +68,25 @@ let answer;
// - positive
// - negative
// - very negative
function checkAnswer() {}
function checkAnswer(answer) {
const arr1 = ["It is certain.", "It is decidedly so.",
"Without a doubt.", "Yes - definitely.", "You may rely on it."];
const arr2 = ["As I see it, yes.", "Most likely.", "Outlook good.", "Yes.",
"Signs point to yes."];
const arr3 = ["Reply hazy, try again.", "Ask again later.",
"Better not tell you now.", "Cannot predict now.", "Concentrate and ask again."];
const arr4 = ["Don't count on it.", "My reply is no.", "My sources say no.",
"Outlook not so good.", "Very doubtful."];
if (arr1.includes(answer)) {
return "very positive";
} else if (arr2.includes(answer)) {
return "positive";
} else if (arr3.includes(answer)) {
return "negative";
} else if (arr4.includes(answer)) {
return "very negative";
}
}

/* ======= TESTS - DO NOT MODIFY ===== */
const log = console.log;
Expand Down
55 changes: 0 additions & 55 deletions week-2/.archive/K-array-methods/README.md

This file was deleted.

19 changes: 0 additions & 19 deletions week-2/.archive/K-array-methods/exercise.js

This file was deleted.

22 changes: 0 additions & 22 deletions week-2/.archive/K-array-methods/exercise2.js

This file was deleted.

46 changes: 0 additions & 46 deletions week-2/.archive/L-array-methods-2/README.md

This file was deleted.

Loading