Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.
Open
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
10 changes: 9 additions & 1 deletion exercises/B-hello-world/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
console.log("Hello world");
let greeting = "Hello world";
console.log(greeting);
greeting2 = "I just started learning JavaScript!"
console.log(greeting2);
greeting3 = "My aim is to understand the bacis"
console.log(greeting3);
const value = 31
console.log(value)

7 changes: 6 additions & 1 deletion exercises/C-variables/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Start by creating a variable `greeting`

greeting = "Hello word"
console.log(greeting);
greeting2 = "Hello word"
console.log(greeting2)
greeting3 = "Hello word"
console.log(greeting3)

5 changes: 3 additions & 2 deletions exercises/D-strings/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Start by creating a variable `message`

console.log(message);
let message = "This is a string"
console.log(message)
console.log(typeof(message));
5 changes: 4 additions & 1 deletion exercises/E-strings-concatenation/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Start by creating a variable `message`

let greeting = "Hello, my name is"
let name = "seble"
message = greeting + " " + name + ".";
console.log(message);

10 changes: 8 additions & 2 deletions exercises/F-strings-methods/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Start by creating a variable `message`

console.log(message);
let name = "Seble"
console.log(name.length) // Logs 5
console.log(name.toLowerCase()) // "sebel"
let greeting = "Hello, my name is"
let myName = "Seble"
let message = "and my name is 5 characters long"
myChar = greeting + " " + myName + " " + message
console.log(myChar)
11 changes: 9 additions & 2 deletions exercises/F-strings-methods/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
const name = " Daniel ";
const name = " Seble ";
let none = name
console.log(none.trim())

console.log(message);

let greeting = "Hello, my name is"
let myName = "Seble"
let message = "and my name is 5 characters long"
myChar = greeting + " " + myName + " " + message
console.log(myChar)
4 changes: 4 additions & 0 deletions exercises/G-numbers/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
// Start by creating a variables `numberOfStudents` and `numberOfMentors`
let numberOfStudents = 15
let numberOfMentors = 8
let total = numberOfStudents + numberOfMentors
console.log(total)
9 changes: 7 additions & 2 deletions exercises/I-floats/exercise.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
var numberOfStudents = 15;
var numberOfMentors = 8;
let numberOfStudents = 15;
let numberOfMentors = 8;
let total = numberOfStudents + numberOfMentors
let studentsPercentage = numberOfStudents / total * 100
console.log(Math.round(studentsPercentage) + "%")
let mentorsPercentage = (numberOfMentors * 100) / total
console.log(Math.round(mentorsPercentage) + "%")
1 change: 1 addition & 0 deletions exercises/J-functions/exercise.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function halve(number) {
return (12 / 2)
// complete the function here
}

Expand Down
1 change: 1 addition & 0 deletions exercises/J-functions/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function triple(number) {
return (12 * 3)
// complete function here
}

Expand Down
3 changes: 2 additions & 1 deletion exercises/K-functions-parameters/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Complete the function so that it takes input parameters
function multiply() {
return (3 * 4)
// Calculate the result of the function and return it
}

// Assign the result of calling the function the variable `result`
var result = multiply(3, 4);
let result = multiply(3, 4);

console.log(result);
5 changes: 4 additions & 1 deletion exercises/K-functions-parameters/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Declare your function first
function divide() {
return(3 / 4)
}

var result = divide(3, 4);
let result = divide(3, 4);

console.log(result);
5 changes: 4 additions & 1 deletion exercises/K-functions-parameters/exercise3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Write your function here
function createGreeting(name) {
return greeting = `Hello, my name is ${name}`
}

var greeting = createGreeting("Daniel");
greeting = createGreeting("seble");

console.log(greeting);
10 changes: 9 additions & 1 deletion exercises/K-functions-parameters/exercise4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
// Declare your function first

// Call the function and assign to a variable `sum`
function passing(a, b) {
return sum = a + b;
}

// Call the function and assign to a variable `sum`
sum = passing(13, 124)

console.log(sum);


console.log(sum);
7 changes: 6 additions & 1 deletion exercises/K-functions-parameters/exercise5.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// Declare your function here
function createLongGreeting(myName, greeting, Age) {
return("Hello, my name is", myName,"and I'm", Age;)

}

//Hello, my name is Daniel and I'm 30 years old
const greeting = createLongGreeting("Daniel", 30);

console.log(greeting);
console.log(greeting)
8 changes: 8 additions & 0 deletions exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";
function mentors(name) {
return `HELLO ${name.toUppreCase()}!`
}
console.log(mentors(mentor1))
console.log(mentors(mentor2))
console.log(mentors(mentor3))
console.log(mentors(mentor4))
console.log(mentors(mentor5))
6 changes: 5 additions & 1 deletion extra/1-currency-conversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
Write a function that converts a price to USD (exchange rate is 1.4 $ to £)
*/

function convertToUSD() {}
function convertToUSD() {


}
console.log(convertToUSD)

/*
CURRENCY CONVERSION
Expand Down
18 changes: 12 additions & 6 deletions mandatory/1-syntax-errors.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
// 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 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";

}
console.log(introduceMe("dan", 17))
function getTotal(a, b) {
total = a ++ b;

let total = a + b;

return "The total is total";
return "The total is" + total;
}

/*
Expand Down
7 changes: 3 additions & 4 deletions 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 getStringLength(word) {
return "word".length();
return word.length;
}

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

/*
Expand Down
9 changes: 7 additions & 2 deletions mandatory/3-function-output.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
// Add comments to explain what this function does. You're meant to use Google!
function getRandomNumber() {
return Math.random() * 10;
return Math.random() * 10; // random numbers are 0 or less than 1 so multiplying by 10 and gives as a random number.
}

console.log(getRandomNumber)

// Add comments to explain what this function does. You're meant to use Google!
function combine2Words(word1, word2) {
return word1.concat(word2);
return word1.concat(word2); //When a function is defined, it is typically defined along with one or more parameters.
//The actual values that are input (or "passed") into a function when it is called are known as arguments.
}

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 + " " + secondWord + " " + thirdWord
}


/*
===================================================
======= TESTS - DO NOT MODIFY BELOW THIS LINE =====
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,11 @@
Sales tax is 20% of the price of the product.
*/

function calculateSalesTax() {}
function calculateSalesTax(priceBefore) {

return priceBefore + (priceBefore * 20) / 100;

}

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

function addTaxAndFormatCurrency() {}
function addTaxAndFormatCurrency(priceBefore) {
let priceAfter = calculateSalesTax(priceBefore);
return `£${priceAfter.toFixed(2)}`;
}

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