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
4 changes: 4 additions & 0 deletions js1-week1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
console.log ("Hello Code Your Future");
console.log("Hello Maha");
console.log("Hello Megumi");
console.log("Hello Mohamad");
15 changes: 8 additions & 7 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) {
function addNumbers(a, b ,c) {
return a + b + c;
}

function introduceMe(name, age)
return `Hello, my {name}` is "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;
let total = a + b;

return "The total is total";
return `The total is 28`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Danny, Good job! Here 28 is a static value. You need to make it dynamic by returning :
return The total is ${total}

}

/*
Expand All @@ -30,8 +31,8 @@ test("addNumbers adds numbers correctly", () => {
});

test("introduceMe function returns the correct string", () => {
expect(introduceMe("Sonjide", 27)).toEqual(
"Hello, my name is Sonjide and I am 27 years old"
expect(introduceMe("Sonjide", 28)).toEqual(
"Hello, my name is Sonjide and I am 28 years old"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Danny, in exercies, you don't need to change the tests scripts. If your function is written correctly, the tests functions test them by sending some random inputs and you can see if your function is written correct or not. :)

);
});

Expand Down
10 changes: 5 additions & 5 deletions mandatory/2-logic-error.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// The syntax for these functions is valid but there are some errors, find them and fix them

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 All @@ -19,7 +19,7 @@ function multiply(a, b, c) {

There are some Tests in this file that will help you work out if your code is working.

To run the tests for just this one file, type `npm test -- --testPathPattern 2-logic-error` into your terminal
To run the tests for just this one file, type `npm test -- --testPathPattern 4-tax` into your terminal
(Reminder: You must have run `npm install` one time before this will work!)
===================================================
*/
Expand Down
4 changes: 4 additions & 0 deletions mandatory/3-function-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ function combine2Words(word1, word2) {
return word1.concat(word2);
}

// dd

function concatenate(firstWord, secondWord, thirdWord) {
return (`${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.
}

/*

===================================================
======= TESTS - DO NOT MODIFY BELOW THIS LINE =====

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Danny, please try to add comments for thhis tasks if you get some free time. You can google it or use MDN website as well. Thanks

Expand Down
12 changes: 9 additions & 3 deletions mandatory/4-tax.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
SALES TAX
=========
A business requires a program that calculates how much the price of a product is including sales tax
Sales tax is 20% of the price of the product.
Sales tax is 20% of the price of the product...
*/

function calculateSalesTax() {}
function calculateSalesTax(sales) {
let tax = sales * 0.2;
let total = sales + tax;
return total;
}

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

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

/*
===================================================

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

Expand Down
3 changes: 3 additions & 0 deletions practice1-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let name ="Danny";
console.log ('Hola ${name}');
console.log(name);