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
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"printWidth": 100
}
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("Hello world I'm learning JavaScript");
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`

const greeting = "Hello world";
console.log(greeting);
console.log(greeting);
console.log(greeting);
2 changes: 1 addition & 1 deletion exercises/D-strings/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Start by creating a variable `message`

const message = `Current Month January\n ${typeof "Current Month January"}`;
console.log(message);
2 changes: 1 addition & 1 deletion exercises/E-strings-concatenation/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Start by creating a variable `message`

const message = "Hello, my name is " + "Junior";
console.log(message);
4 changes: 3 additions & 1 deletion exercises/F-strings-methods/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Start by creating a variable `message`

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

console.log(message);
8 changes: 8 additions & 0 deletions exercises/G-numbers/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
// Start by creating a variables `numberOfStudents` and `numberOfMentors`
const numberOfStudents = 25;
const numberOfMentors = 25;

console.log(`Total number of students: ${numberOfStudents}`);
console.log(`Totla number of mentors; ${numberOfMentors}`);
console.log(
`Total number of students and mentors: ${numberOfStudents + numberOfMentors}`
);
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;
const numberOfStudents = 15;
const numberOfMentors = 8;

//Getting the total number of people either students or mentors
const totalNumberOfPeople = numberOfMentors + numberOfStudents;

//Getting the percentage of mentors and students
const studentPercentage = (numberOfStudents / totalNumberOfPeople) * 100;
const mentorPercentage = (numberOfMentors / totalNumberOfPeople) * 100;

console.log(`Percentage students: ${Math.round(studentPercentage)}%`);
console.log(`Percentage mentors: ${Math.round(mentorPercentage)}%`);
6 changes: 3 additions & 3 deletions exercises/J-functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ console.log(result); // 4

## Exercise

* Complete the function in exercise.js so that it halves the input
* Try calling the function more than once with some different numbers
- Complete the function in exercise.js so that it halves the input
- Try calling the function more than once with some different numbers

> Remember to use the return keyword to get a value out of the function

Expand All @@ -33,7 +33,7 @@ console.log(result); // 4

## Exercise 2

* Complete the function in exercise2.js so that it triples the input
- Complete the function in exercise2.js so that it triples the input

## Expected result

Expand Down
2 changes: 2 additions & 0 deletions exercises/J-functions/exercise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function halve(number) {
// complete the function here

return number / 2;
}

var result = halve(12);
Expand Down
2 changes: 2 additions & 0 deletions exercises/J-functions/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function triple(number) {
// complete function here

return number * 3;
}

var result = triple(12);
Expand Down
12 changes: 6 additions & 6 deletions exercises/K-functions-parameters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function add(num1, num2) {

## Exercise

* Write a function that multiplies two numbers together
- Write a function that multiplies two numbers together

## Expected result

Expand All @@ -30,7 +30,7 @@ function add(num1, num2) {

## Exercise 2

* From scratch, write a function that divides two numbers
- From scratch, write a function that divides two numbers

## Expected result

Expand All @@ -40,7 +40,7 @@ function add(num1, num2) {

## Exercise 3

* Write a function that takes a name (a string) and returns a greeting
- Write a function that takes a name (a string) and returns a greeting

## Expected result

Expand All @@ -50,8 +50,8 @@ Hello, my name is Daniel

## Exercise 4

* Write a function that adds two numbers together
* Call the function, passing `13` and `124` as parameters, and assigning the returned value to a variable `sum`
- Write a function that adds two numbers together
- Call the function, passing `13` and `124` as parameters, and assigning the returned value to a variable `sum`

## Expected result

Expand All @@ -61,7 +61,7 @@ Hello, my name is Daniel

## Exercise 5

* Write a function that takes a name (a string) and an age (a number) and returns a greeting (a string)
- Write a function that takes a name (a string) and an age (a number) and returns a greeting (a string)

## Expected result

Expand Down
4 changes: 3 additions & 1 deletion exercises/K-functions-parameters/exercise.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// 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`
Expand Down
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
const 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
const 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
const 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
const createLongGreeting = (name, age) => {
return `Hello, my name is ${name} and I'm ${age} years old`;
};

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

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

const GetPercentage = (number_to_get_ratio) => {
return (number_to_get_ratio / totalNumberOfPeople) * 100;
};

const DisplayPercentage = () => {
const studentPercentage = Math.round(GetPercentage(numberOfStudents));
const mentorPercentage = Math.round(GetPercentage(numberOfMentors));

console.log(`Percentage students: ${studentPercentage}%`);
console.log(`Percentage mentors: ${mentorPercentage}%`);
};

DisplayPercentage();
11 changes: 11 additions & 0 deletions exercises/L-functions-nested/exercise2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const mentor1 = "Daniel";
const mentor2 = "Irina";
const mentor3 = "Mimi";
const mentor4 = "Rob";
const mentor5 = "Yohannes";

console.log(mentor1);
console.log(mentor2);
console.log(mentor3);
console.log(mentor4);
console.log(mentor5);
9 changes: 7 additions & 2 deletions extra/1-currency-conversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
Write a function that converts a price to USD (exchange rate is 1.4 $ to £)
*/

function convertToUSD() {}
function convertToUSD(amount) {
return amount * 1.4;
}

/*
CURRENCY FORMATTING
Expand All @@ -15,7 +17,10 @@ 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(amount) {
const percentageAmountToConvert = amount - (1 / 100) * amount;
return 5.7 * percentageAmountToConvert;
}

/* ======= TESTS - DO NOT MODIFY =====
There are some Tests in this file that will help you work out if your code is working.
Expand Down
26 changes: 16 additions & 10 deletions extra/2-piping.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,32 @@
the final result to the variable goodCode
*/

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

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

function multiply() {

}

function format() {

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

const startingValue = 2

// Why can this code be seen as bad practice? Comment your answer.
let badCode =

/* BETTER PRACTICE */
/**
* Chaining of this methods all in one line is unclear on what is happening at first glance
* Prone to making errors while chaining this methods
**/
let badCode = format(multiply(add(startingValue, 10), 2))

let goodCode =
/* BETTER PRACTICE */
const sum = add(startingValue, 10);
const multipleOfSum = multiply(sum,2)
let goodCode = format(multipleOfSum)

/* ======= 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