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
2 changes: 1 addition & 1 deletion exercises/B-hello-world/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
console.log("Hello world");
console.log(8, "Murat", "Busra");
4 changes: 3 additions & 1 deletion exercises/C-variables/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Start by creating a variable `greeting`

let greeting = 'Hello World'
console.log(greeting);
console.log(greeting);
console.log(greeting);
4 changes: 3 additions & 1 deletion exercises/D-strings/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Start by creating a variable `message`

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

let messageStart = "Hello, my name is ";
let name = "Busra"
let message = messageStart + name;
console.log(message);
6 changes: 6 additions & 0 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`
let name = "Busra";
let nameLength = name.length;

let messageStart = 'My name is ';
let messageEnd = " characters long";
let message = messageStart + name + ' and '+ messageStart.toLocaleLowerCase() + nameLength + messageEnd;

console.log(message);
9 changes: 7 additions & 2 deletions exercises/F-strings-methods/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
const name = " Daniel ";
let name = ' Busra '
let nameLength = name.trim().length;
let messageEnd = " characters long";

console.log(message);
let messageStart = 'My name is ';
let messageTrimmed = messageStart + name.trim() + ' and '+ messageStart.toLocaleLowerCase() + nameLength + messageEnd;

console.log(messageTrimmed);
4 changes: 2 additions & 2 deletions exercises/G-numbers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Unlike strings, numbers do not need to be wrapped in quotes.
var age = 30;
```

You can use mathematical operators to caclulate numbers:
You can use mathematical operators to calculate numbers:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 :) Thanks for fixing the spelling errors! It happens all the time in real projects. It's very useful to have a spellchecker configured in your IDE


```js
var sum = 10 + 2; // 12
Expand All @@ -25,5 +25,5 @@ var difference = 10 - 2; // 8
```
Number of students: 15
Number of mentors: 8
Total numnber of students and mentors: 23
Total number of students and mentors: 23
```
10 changes: 10 additions & 0 deletions exercises/G-numbers/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
// Start by creating a variables `numberOfStudents` and `numberOfMentors`

let students = 'Number of students: ';
let numberOfStudents = 33 + 16;
console.log(students + numberOfStudents);
let mentors = "Number of mentors: ";
let numberOfMentors = 8 * 2;
console.log(mentors + numberOfMentors);
let totalText = 'Total number of students and mentors: ';
let total = numberOfMentors + numberOfStudents;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Very good choice of variable names, the code is easy to follow.

console.log(totalText + total);
14 changes: 12 additions & 2 deletions exercises/I-floats/exercise.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
var numberOfStudents = 15;
var numberOfMentors = 8;
let numberOfStudents = 15;
let numberOfMentors = 8;

let studentsText = 'Percentage students: '
let percentageStudents = (numberOfStudents / (numberOfStudents + numberOfMentors)) * 100;
let roughPercentageStudents = Math.round(percentageStudents) + '%';
console.log(studentsText + roughPercentageStudents);

let mentorsText = 'Percentage mentors: '
let percentageMentors = (numberOfMentors / (numberOfStudents + numberOfMentors)) * 100;
let roughPercentageMentors = Math.round (percentageMentors) + '%';
console.log(mentorsText + roughPercentageMentors);
11 changes: 8 additions & 3 deletions exercises/J-functions/exercise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
function halve(number) {
// complete the function here
}
return number / 2;
}

var result = halve(12);
let result = halve(12);
let result1 = halve(6);
let result2 = halve(8);

console.log(result);
console.log(result1);
console.log(result2);

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
4 changes: 2 additions & 2 deletions exercises/K-functions-parameters/exercise.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Complete the function so that it takes input parameters
function multiply() {
// Calculate the result of the function and return it
function multiply(num1, num2) {
return num1 * num2;
}

// Assign the result of calling the function the variable `result`
Expand Down
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

var result = divide(3, 4);
function divide (num1, num2) {
return num1 / num2;
};
var result = divide(40, 4);

console.log(result);
6 changes: 4 additions & 2 deletions exercises/K-functions-parameters/exercise3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Write your function here

var greeting = createGreeting("Daniel");
function createGreeting (text) {
return 'Hello ' + text;
}
let greeting = createGreeting("Daniel");

console.log(greeting);
6 changes: 4 additions & 2 deletions exercises/K-functions-parameters/exercise4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Declare your function first

function add (num1, num2) {
return num1 + num2;
}
// Call the function and assign to a variable `sum`

let sum = add ( 13, 124);
console.log(sum);
4 changes: 3 additions & 1 deletion 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 createLongGreeting (name, age) {
return "Hello, my name is " + name + " and I'm " + age + " years old"
}
const greeting = createLongGreeting("Daniel", 30);

console.log(greeting);
37 changes: 32 additions & 5 deletions exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
var mentor1 = "Daniel";
var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";
let mentor1 = "Daniel";
let mentor2 = "Irina";
let mentor3 = "Mimi";
let mentor4 = "Rob";
let mentor5 = "Yohannes";
let greeting = "Hello ";


function greetingMentors (grt, name){
return grt + name;
};

let write = greetingMentors(greeting, mentor1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All these 5 greetings below are essentially the same code, only the mentor name is different. Could you create another function to reduce duplication of the code?

let result = write.toUpperCase();
console.log(result);

write = greetingMentors(greeting, mentor2);
result = write.toUpperCase();
console.log(result);

write = greetingMentors(greeting, mentor3);
result = write.toUpperCase();
console.log(result);

write = greetingMentors(greeting, mentor4);
result = write.toUpperCase();
console.log(result);

write = greetingMentors(greeting, mentor5);
result = write.toUpperCase();
console.log(result);

12 changes: 6 additions & 6 deletions mandatory/1-syntax-errors.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// 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 getTotal(a, b) {
total = a ++ b;
const 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
10 changes: 6 additions & 4 deletions mandatory/3-function-output.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// Add comments to explain what this function does. You're meant to use Google!
// expected output: a number from 0 to <10
function getRandomNumber() {
return Math.random() * 10;
}

// Add comments to explain what this function does. You're meant to use Google!
// combine2words function joins two strings
function combine2Words(word1, word2) {
return word1.concat(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}`;
}


// 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 =====
Expand Down
10 changes: 7 additions & 3 deletions mandatory/4-tax.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
Sales tax is 20% of the price of the product.
*/

function calculateSalesTax() {}

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

function addTaxAndFormatCurrency() {}
function addTaxAndFormatCurrency(productPrice) {
const total = productPrice + productPrice * 0.2 ;
return `£${total.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.

Hi Busra, good job with using string interpolation. Well done!!

};

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