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
11 changes: 11 additions & 0 deletions exercises/B-hello-world/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
console.log("Hello world");
console.log("Hello everyone. I am now trying using console.log with different kind of inputs.");
console.log(23);
console.log(("is this(using a nested paranthesis) gonna cause an error?"));
console.log("My name is", "Omer");
console.log((("I am now using three paranthesis inside console.log.")));

const name = "omer";
const hobby = "coding";

console.log("Hi everyone. My name is", name, ", and my hobby is", hobby);
console.log("Hi everyone. My name is" + name + "and my hobby is" + hobby);
5 changes: 5 additions & 0 deletions 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`

const greeting = "Hello world";

console.log(greeting);
console.log(greeting);
console.log(greeting);

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

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

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

const greeting = "Hello, my name is ";
const name = "Omer";
const message = greeting + name;

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

const name = "Omer";
const nameLength = name.length;
const message = ` My name is ${name} and my name is ${nameLength} characters long. `;

console.log(message);
console.log(message.trim());
4 changes: 4 additions & 0 deletions exercises/F-strings-methods/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const name = " Daniel ";
const nameTrim = name.trim();
const nameLength = name.length;
const message = `My name is ${nameTrim} and my name is 6 characters long`;

console.log(message);

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 message = `Number of students: ${numberOfStudents}
Number of mentors: ${numberOfMentors}
Total number of students and mentors: ${numberOfStudents + numberOfMentors}`;
console.log(message);
20 changes: 18 additions & 2 deletions exercises/I-floats/exercise.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
var numberOfStudents = 15;
var numberOfMentors = 8;
const numberOfStudents = 15;
const numberOfMentors = 8;
const studentsPercentage = Math.round(100 *(numberOfStudents / (numberOfStudents + numberOfMentors)));
const mentorsPercentage = Math.round(100 *
(numberOfMentors / (numberOfStudents + numberOfMentors)));

const message = `Percentage students: ${studentsPercentage}%
Percentage mentors: ${mentorsPercentage}%`;

const message2 = `Percentage students: ${Math.round(
100 * (numberOfStudents / (numberOfStudents + numberOfMentors))
)}%
Percentage mentors: ${Math.round(
100 * (numberOfMentors / (numberOfStudents + numberOfMentors))
)}%`;

console.log(message);
console.log(message2);
5 changes: 4 additions & 1 deletion exercises/J-functions/exercise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
function halve(number) {
// complete the function here
return number / 2;
}

var result = halve(12);
const result = halve(12);
const result2 = halve(36);

console.log(result);
console.log(result2);
4 changes: 3 additions & 1 deletion exercises/J-functions/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
function triple(number) {
// complete function here
return number * 3;
}

var result = triple(12);
const result = triple(12);

console.log(result);

5 changes: 3 additions & 2 deletions 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() {
function multiply(num1, num2) {
// Calculate the result of the function and return it
return num1 * num2;
}

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

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

var result = divide(3, 4);

const 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 `Hello, my name is ${name}`;
}

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

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

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

console.log(sum);
3 changes: 3 additions & 0 deletions exercises/K-functions-parameters/exercise5.js
Original file line number Diff line number Diff line change
@@ -1,4 +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);

Expand Down
48 changes: 43 additions & 5 deletions exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
var mentor1 = "Daniel";
var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";
const mentor1 = "Daniel";
const mentor2 = "Irina";
const mentor3 = "Mimi";
const mentor4 = "Rob";
const mentor5 = "Yohannes";


function createShoutyGreeting (name) {
name = name.toUpperCase();
console.log(`HELLO ${name}`);
}

createShoutyGreeting(mentor1);
createShoutyGreeting(mentor2);
createShoutyGreeting(mentor3);
createShoutyGreeting(mentor4);
createShoutyGreeting(mentor5);




// Another way of doing the exercise
/*
function nameInUpperCase(name) {
return name.toUpperCase();
}

function createShoutyGreeting() {
const name1 = nameInUpperCase(mentor1);
const name2 = nameInUpperCase(mentor2);
const name3 = nameInUpperCase(mentor3);
const name4 = nameInUpperCase(mentor4);
const name5 = nameInUpperCase(mentor5);
console.log(`HELLO ${name1}`);
console.log(`HELLO ${name2}`);
console.log(`HELLO ${name3}`);
console.log(`HELLO ${name4}`);
console.log(`HELLO ${name5}`);
}

createShoutyGreeting();
*/

13 changes: 10 additions & 3 deletions extra/1-currency-conversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
Write a function that converts a price to USD (exchange rate is 1.4 $ to £)
*/

function convertToUSD() {}
function convertToUSD(pound) {
const usd = pound * 1.4;
return usd;
}

/*
CURRENCY FORMATTING
Expand All @@ -15,7 +18,11 @@ function convertToUSD() {}
They have also decided that they should add a 1% fee to all foreign transactions, which means you only convert 99% of the £ to BRL.
*/

function convertToBRL() {}
function convertToBRL(pound) {
const afterFee = pound * 0.99;
const brl = afterFee * 5.7;
return parseFloat(brl.toFixed(2));
}

/* ======= TESTS - DO NOT MODIFY =====
There are some Tests in this file that will help you work out if your code is working.
Expand All @@ -37,5 +44,5 @@ test("convertToBRL function works for £30", () => {
});

test("convertToBRL function works for £0.99", () => {
expect(convertToBRL(1.5)).toEqual(8.46);
expect(convertToBRL(1.50)).toEqual(8.46);
});
20 changes: 12 additions & 8 deletions extra/2-piping.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,30 @@
the final result to the variable goodCode
*/

function add() {

function add(num1, num2) {
return num1 + num2;
}

function multiply() {

function multiply(num1, num2) {
return num1 * num2;
}

function format() {

function format(num) {
return `£${num}`;
}

const startingValue = 2;

// Why can this code be seen as bad practice? Comment your answer.
let badCode =
let badCode = format(multiply(add(startingValue, 10), 2)); //This code is not easy to read and understand

/* BETTER PRACTICE */

let goodCode =
const addedNumber = add(startingValue, 10);
const multiplied = multiply(addedNumber, 2);
const formatted = format(multiplied);

let goodCode = formatted;

/* ======= TESTS - DO NOT MODIFY =====
There are some Tests in this file that will help you work out if your code is working.
Expand Down
Loading