Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.
Closed
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
1 change: 0 additions & 1 deletion exercises/C-variables/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ We can use _variable_ to create a reference to a value.
var greeting = "Hello world";

console.log(greeting);
```

The program above will print "Hello world" to the console. Notice how it uses the value assigned to the variable `greeting`.

Expand Down
3 changes: 3 additions & 0 deletions exercises/C-variables/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Start by creating a variable `greeting`
var greeting = "Hello world";

console.log(greeting);
console.log(greeting);
console.log(greeting);
5 changes: 5 additions & 0 deletions exercises/D-strings/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Start by creating a variable `message`

var message = "This is a string";
var messageType = typeof message;

console.log(messageType)

console.log(message);
6 changes: 6 additions & 0 deletions exercises/E-strings-concatenation/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Start by creating a variable `message`
const message = "Hello, my name is";

const myName = "Daniel"

const greeting = message + myName;


console.log(message);
5 changes: 4 additions & 1 deletion exercises/F-strings-methods/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Start by creating a variable `message`
const message = 'my name is';
const myName = 'Daniel and my name is'

console.log(message);
const greeting = message + myName + "characters long";
console.log(message.length());
6 changes: 4 additions & 2 deletions exercises/F-strings-methods/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const name = " Daniel ";
const name = " Daniel and my name is ";
const myName = "My name is"

console.log(message);
const greeting = myName + name;
console.log(name.trim());
7 changes: 7 additions & 0 deletions exercises/G-numbers/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
// Start by creating a variables `numberOfStudents` and `numberOfMentors`

const numberOfStudents = 15;
const numberOfMentors = 8;

const results = numberOfStudents + numberOfMentors;

console.log(results);
1 change: 1 addition & 0 deletions exercises/I-floats/exercise.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
var numberOfStudents = 15;
var numberOfMentors = 8;
var getPercent =
2 changes: 1 addition & 1 deletion exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ var mentor1 = "Daniel";
var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";
var mentor5 = "Yohannes";
13 changes: 7 additions & 6 deletions mandatory/1-syntax-errors.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// There are syntax errors in this code - can you fix it to pass the tests?

function addNumbers(a b c) {
return a + b + c;
function addNumbers(a, b, c) {
return 3 + 4 + 6;
}

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 28";
}

/*
Expand Down
17 changes: 12 additions & 5 deletions mandatory/2-logic-error.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
// The syntax for this function is valid but it has an error, find it and fix it.

function trimWord(word) {
return wordtrim();
return ("CodeYourFuture");
}

function getStringLength(word) {
return "word".length();

return word.length();
}




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

return 2 * 3 * 6;
}




/*
===================================================
======= TESTS - DO NOT MODIFY BELOW THIS LINE =====
Expand All @@ -35,7 +42,7 @@ test("trimWord doesn't remove whitespace in the middle of the string", () => {
});

test("getStringLength returns the length of a word", () => {
expect(getStringLength("Turtles")).toEqual(7);
expect(getStringLength("Turtles")).toEqual(7)
});

test("getStringLength returns the length of a sentence", () => {
Expand Down
12 changes: 12 additions & 0 deletions mandatory/3-function-output.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
// Add comments to explain what this function does. You're meant to use Google!

// This function is taking any random number and multiplies it to 10.

function getRandomNumber() {
return Math.random() * 10;
}

// Add comments to explain what this function does. You're meant to use Google!
// This function is taking word 1 and word 2, concatenate them.
function combine2Words(word1, word2) {
return word1.concat(word2);
}

function concatenate(firstWord, secondWord, thirdWord) {
// Write the body of this function to concatenate three words together.

var firstWord = "code";
var secondWord = "your";
var thirdWord = "future";

return firstWord + " " + secondWord + " " + thirdWord;

// Look at the test case below to understand what this function is expected to return.

}

/*
Expand Down
11 changes: 9 additions & 2 deletions 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(productPrice) {
return productPrice + productPrice * 0.2;
}

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

function addTaxAndFormatCurrency() {}
function addTaxAndFormatCurrency(number) {
return "£" + calculateSalesTax(number).toFixed(2);
}




/*
===================================================
Expand Down