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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Like learning a musical instrument, programming requires daily practise.

The exercises are split into three folders: `exercises`, `mandatory` and `extra`. All homework in the `exercise` and `mandatory` section **must** be completed for homework by the following lesson.
The exercises are split into three folders: `exercises`, `mandatory` and `extra`. All homework in the `exercise` and `mandatory` section **must** be completed for homework by the following lesson.

The `extra` folder contains exercises that you can complete to challenge yourself, but are not required for the following lesson.

Expand Down
3 changes: 3 additions & 0 deletions exercises/D-strings/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Start by creating a variable `message`
var message = "This is a string";
var messageType = typeof message;

console.log(message);
console.log(messageType); // logs 'string'
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`

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

// console.log(nameLength); // Logs 8



const myName = "Georgina ";
console.log(
`My name is ${myName}, the length of my name is ${myName.length} characters`
);
console.log();



console.log(message);
14 changes: 12 additions & 2 deletions exercises/F-strings-methods/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
const name = " Daniel ";
// const name = " Georgina ";

console.log(message);
// console.log(
// `My name is ${Name}, the length of my name is ${Name.length} characters`
// );

// console.log(message);
const name = " Georgina ";
console.log(
`My name is ${name.trim()}, the length of my name is ${
name.trim().length
} characters`
);
6 changes: 6 additions & 0 deletions 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`
const numberOfStudents = "15";
const numberOfMentors = "8";

const sum = 15 + 8; // 23

console.log(sum);
23 changes: 21 additions & 2 deletions exercises/I-floats/exercise.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
var numberOfStudents = 15;
var numberOfMentors = 8;
const numberOfStudents = 15;
const numberOfMentors = 8;
const sum = numberOfStudents + numberOfMentors;

// console.log (TotalnumberOfStudents ${numberOfStudents} );

// console.log (TotalnumberOfMentors ${numberOfMentors } );

//console.log (TotalNumber ${totalNumber} );

const percentageStudents = (numberOfStudents/sum) * 100;//65

console.log (percentageStudents)

const percentageMentors = (numberOfMentors/sum) * 100;//34.7 (math.round =35

console.log (percentageMentors)




11 changes: 10 additions & 1 deletion exercises/J-functions/exercise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
function halve(number) {
// complete the function here

return number /2;
}

var result = halve(12);

console.log(result);
console.log(result);//6

var result = halve(10);
console.log (result); //5

var result = halve(100);
console.log (result); //50

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

var result = triple(12);

console.log(result);
console.log(result); //36
6 changes: 4 additions & 2 deletions exercises/K-functions-parameters/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Complete the function so that it takes input parameters
function multiply() {
function multiply (numberOne, numberTwo) {

// Calculate the result of the function and return it
return numberOne * numberTwo;
}

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

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

function divide(numberOne, numberTwo) {
return numberOne / numberTwo;
}
var result = divide(3, 4);

console.log(result);
8 changes: 6 additions & 2 deletions exercises/K-functions-parameters/exercise3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Write your function here
function greeting(greetingStart, name) {}
//var greeting = createGreeting("Daniel");
var greetingStart = "Hello, my name is ";
var name = "Georgina";

var greeting = createGreeting("Daniel");
greeting = greetingStart + name;

console.log(greeting);
console.log(greeting); // Logs "Hello, my name is Georgina"
5 changes: 4 additions & 1 deletion 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 addition(numberOne, numberTwo) {
return numberOne + numberTwo;
}
// Call the function and assign to a variable `sum`

const sum = addition(13, 124);
console.log(sum);
7 changes: 6 additions & 1 deletion exercises/K-functions-parameters/exercise5.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// Declare your function here
//function greeting(greetingStart, name, age) {
function createLongGreeting(name, age) {
return `Hello, my name is ${name} and I'm ${age} years old`;
}

const greeting = createLongGreeting("Daniel", 30);
//var greeting = createGreeting("Georgina");
const greeting = createLongGreeting("Georgina", 43);

console.log(greeting);
20 changes: 20 additions & 0 deletions exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,23 @@ var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";

var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";

function CreateGreeting(name) {
return `HELLO ${name}`;
}

function ToUpper(string) {
return CreateGreeting(string.toUpperCase());
}

console.log(ToUpper(mentor1));
console.log(ToUpper(mentor2));
console.log(ToUpper(mentor3));
console.log(ToUpper(mentor4));
console.log(ToUpper(mentor5));

console.log("\n");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

really neat work Georgina, sorry the last line of the coding, in console.log you put new line sign, can you please explain how it worked :),

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks Uzma, I'm learning something new each day. Using "/n" in the console.log lists each on a new line. I also learnt that you can even add some sort of margin at the start of each line if you list items like this - example:
console.log("one", "\n","two");

16 changes: 11 additions & 5 deletions mandatory/1-syntax-errors.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
// 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;
}
addNumbers(3, 4, 6);

function introduceMe(name, age) {
return "Hello, my name is " + name + " and I am " + age + "years old";
}
introduceMe("Sonjid", 27);

function introduceMe(name, age)
return "Hello, my name is " + name "and I am " age + "years old";

function getTotal(a, b) {
total = a ++ b;
total = a + b;

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

getTotal(23, 5);

/*
===================================================
======= TESTS - DO NOT MODIFY BELOW THIS LINE =====
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
21 changes: 20 additions & 1 deletion mandatory/3-function-output.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
// Add comments to explain what this function does. You're meant to use Google!
//This function generates a random decimal value between 0 and 1
function getRandomNumber() {
return Math.random() * 10;
return Math.random() * 10; //The Math.random() function returns a floating-point, pseudo-random number in the range 0 to less than 1 (inclusive of 0, but not 1) with approximately uniform distribution over that range
}

// Add comments to explain what this function does. You're meant to use Google!
function combine2Words(word1, word2) {
return word1.concat(word2);
return word1.concat(word2); //to join two or more text strings into one string
}

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.concat(" ", secondWord, " ", thirdWord);
}

/*

}

// Add comments to explain what this function does. You're meant to use Google!
//This function is used to join two strings
function combine2Words(word1, word2) {
return word1.concat(word2);
}

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

/*
Expand Down
9 changes: 9 additions & 0 deletions mandatory/4-tax.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ function calculateSalesTax() {}
*/

function addTaxAndFormatCurrency() {}
function calculateSalesTax(beforeSalesTax) {
// return the total price then multiply by tax percentage
return beforeSalesTax + beforeSalesTax * 0.2;
}

function addTaxAndFormatCurrency(numberToFormat) {
// returns: total price + tax using £ as the start currency symbol. Price has 2 decimal places at the end via .toFixed()
return `£${(numberToFormat + numberToFormat * 0.2).toFixed(2)}`;
}

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