Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.
Open
5 changes: 3 additions & 2 deletions exercises/E-strings-concatenation/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Start by creating a variable `message`
let greetingStart = "Hello my name is ";
let firstName = "Rabie ";

console.log(message);
console.log(greetingStart + firstName);
10 changes: 9 additions & 1 deletion exercises/F-strings-methods/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
// Start by creating a variable `message`
let firstMessage = "Hello my name is ";
let secondmessage = "and my name is ";
let thirdmessage = " long";
let name = "Rabie ";
let length = name.length;


let message = firstMessage + name + secondmessage + length + thirdmessage;


console.log(message);
10 changes: 9 additions & 1 deletion exercises/F-strings-methods/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
const name = " Daniel ";
let firstMessage = "Hello my name is ";
let secondmessage = "and my name is ";
let thirdmessage = " long";
let name = "Rabie ";
let length = name.length;


let message = firstMessage + name + secondmessage + length + thirdmessage;


console.log(message);
8 changes: 7 additions & 1 deletion exercises/G-numbers/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
// Start by creating a variables `numberOfStudents` and `numberOfMentors`
let numOfStudents = 15;
let numOfmentores = 8;
let total = numOfStudents + numOfmentores;

console.log("Number of student: " + numOfStudents);
console.log("Number of mentores: " + numOfmentores);
console.log("Total number of students and mentores " + total);
11 changes: 9 additions & 2 deletions exercises/I-floats/exercise.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
var numberOfStudents = 15;
var numberOfMentors = 8;
let numOfStudents = 15;
let numOfmentores = 8;
let total = numOfStudents + numOfmentores;

let percentageOfStudents = (numOfStudents / total) * 100;
let percentageOfMentores = (numOfmentores / total) * 100;

console.log("Percentage Students: " + Math.round(percentageOfStudents) + "%");
console.log("Percentage Mentores: " + Math.round (percentageOfMentores) + "%");
3 changes: 2 additions & 1 deletion exercises/J-functions/exercise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
function halve(number) {
// complete the function here
return number/2;
}

var result = halve(12);

console.log(result);

2 changes: 1 addition & 1 deletion exercises/J-functions/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function triple(number) {
// complete function here
return number * 3;
}

var result = triple(12);
Expand Down
8 changes: 3 additions & 5 deletions exercises/K-functions-parameters/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Complete the function so that it takes input parameters
function multiply() {
// Calculate the result of the function and return it
function multiply(a, b){
return a * b;
}

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

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

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

console.log(result);
7 changes: 5 additions & 2 deletions 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){
console.log("Hello, my name is " + name);
return name;
}

var greeting = createGreeting("Daniel");
let greeting = createGreeting("Rabie");

console.log(greeting);
9 changes: 6 additions & 3 deletions exercises/K-functions-parameters/exercise4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Declare your function first
function summation(num1, num2){
let sum = num1 + num2;
return sum
}

// Call the function and assign to a variable `sum`
let result = summation(13, 124);

console.log(sum);
console.log(result);
10 changes: 6 additions & 4 deletions exercises/K-functions-parameters/exercise5.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Declare your function here
function greeting(name, age){
let message = "Hello, my name is " + name + " and I am " + age + " years old";
return message;
}

const greeting = createLongGreeting("Daniel", 30);

console.log(greeting);
let greetingMessage = greeting("Rabie", 27);
console.log(greetingMessage);
13 changes: 7 additions & 6 deletions mandatory/1-syntax-errors.js
Original file line number Diff line number Diff line change
@@ -1,18 +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) { //There are missing "," between each argument.
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"; // after name there needs to be + also after the string.
}
function getTotal(a, b) {
total = a ++ b;
let total = a + b;

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


/*
===================================================
======= TESTS - DO NOT MODIFY BELOW THIS LINE =====
Expand Down
8 changes: 4 additions & 4 deletions mandatory/2-logic-error.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// 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(); // wordtrim is undefined word.
}

function getStringLength(word) {
return "word".length();
return word.length; // word shouldn't be a string.
}

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

return a * b * c; // the return should have the multiplication like: return a * b * c;
}

/*
Expand Down
1 change: 1 addition & 0 deletions mandatory/3-function-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function combine2Words(word1, word2) {
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;
}

/*
Expand Down
9 changes: 7 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(priceBeforeTax) {
return priceBeforeTax + (priceBeforeTax * 0.2);
}

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

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

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