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
15 changes: 15 additions & 0 deletions exercises/B-hello-world/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
console.log("Hello world");
<<<<<<< HEAD

console.log("Hello world, I am enjoying my coding journey");

console.log();

console.log();

console.log();
=======
console.log("Hello world, I am enjoying my coding journey");
console.log()
console.log()
console.log()
>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193
7 changes: 7 additions & 0 deletions exercises/C-variables/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// Start by creating a variable `greeting`
<<<<<<< HEAD

let greeting ="Welcome to rewarding journey of JS";
=======
let greeting ="Welcome to rewarding journey of JS"
>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193
console.log(greeting);
console.log(greeting);
console.log(greeting);
6 changes: 4 additions & 2 deletions 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`

console.log(message);
let message= "This is a string";
let messageType = typeof message; //find the data type
console.log(message); //Log 'This is a string'
console.log(messageType);//Log 'string'
12 changes: 11 additions & 1 deletion exercises/E-strings-concatenation/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Start by creating a variable `message`
<<<<<<< HEAD
let myName = "Nonye";
let greetingstart ="Hello my name is "+ myName;

console.log(message);
console.log(greetingstart);
=======
let greetingstart ="Hello my name is ";
let myName = "Nonye";

let greeting = greetingstart + myName;
console.log(greeting); //logs Hello my name is Nonye
>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193
7 changes: 6 additions & 1 deletion 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`
let greetingstart ="Hello my name is ";
let myName = "Nonye";
let nameLength = myName.length;// the length of the character of myName

let greeting = `${greetingstart} ${myName} and my name is ${nameLength} character long.` // using interpolation to combine Hello my name is Nonye and the length of the character of myName
console.log(greeting);//logs Hello my name is Nonye

console.log(message);
11 changes: 9 additions & 2 deletions exercises/F-strings-methods/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
const name = " Daniel ";
let myName = "Nonye";
let myNameLowerCase = myName.toLowerCase(); //change Nonye to nonye
let myNameUpperCase = myName.toUpperCase();//change Nonye to NONYE
let myNameReplace = myName.replace('Nonye', 'Ruth');// Ruth
let myNameLength = myName.length;

console.log(message);
console.log(myNameLowerCase); // "nonye"
console.log(myNameUpperCase);// NONYE
console.log(myNameReplace);// Ruth
console.log(myNameLength); //5
32 changes: 32 additions & 0 deletions exercises/G-numbers/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
// Start by creating a variables `numberOfStudents` and `numberOfMentors`
<<<<<<< HEAD
<<<<<<< HEAD

let numberOfStudents = 15;
let numberOfMentors = 8;
let sum = numberOfMentors + numberOfStudents;

let pStudents = Math.round((numberOfStudents/sum)*100);

let pMentors = Math.round((numberOfMentors/sum)*100);

=======
let numberOfStudents =15;
let numberOfMentors =8;
const sum = numberOfMentors + numberOfStudents;
>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193
=======
let numberOfStudents =15;
let numberOfMentors =8;
const sum = numberOfMentors + numberOfStudents;
>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193

console.log(`Number of Students: ${numberOfStudents}`);
console.log(`Number of Students: ${numberOfMentors}`);
console.log(`Total number of Students and Mentors: ${sum}`);
<<<<<<< HEAD
<<<<<<< HEAD

=======
>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193
=======
>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193
15 changes: 15 additions & 0 deletions exercises/I-floats/exercise.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
<<<<<<< HEAD
var numberOfStudents = 15;
var numberOfMentors = 8;
=======
let numberOfStudents = 15;
let numberOfMentors = 8;
>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193
let sum = numberOfMentors + numberOfStudents;
let pStudents = Math.round((numberOfStudents/sum)*100);
let pMentors = Math.round((numberOfMentors/sum)*100);

console.log(`Percentage of Students: ${pStudents}%`);
console.log(`Percentage of Mentors: ${pMentors}%`);
<<<<<<< HEAD
=======

>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193
15 changes: 10 additions & 5 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
<<<<<<< HEAD
return number * 0.5; // complete the function here
let result = halve(12);
console.log(result); // log 6
}

var result = halve(12);

console.log(result);
=======
return number * 0.5; // complete the function here
}
let result = halve(12);
console.log(result); // log 6
>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193
10 changes: 7 additions & 3 deletions exercises/J-functions/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
function triple(number) {
// complete function here
<<<<<<< HEAD
return number*3; // complete function here
=======
return number*3; // complete function here
>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193
}

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

console.log(result);
console.log(result);// log 36
10 changes: 7 additions & 3 deletions exercises/K-functions-parameters/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// Complete the function so that it takes input parameters
function multiply() {
// Calculate the result of the function and return it
function multiply(num1, num2) {
<<<<<<< HEAD
return num1*num2; // Calculate the result of the function and return it
=======
return num1*num2; // Calculate the result of the function and return it
>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193
}

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

console.log(result);
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

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

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

var greeting = createGreeting("Daniel");
function greet(myName, middleName)//Hello is a Parameter of the greet function
{
console.log('Hello, my name is ' + myName + ' ' + middleName);
}
<<<<<<< HEAD
<<<<<<< HEAD
greet('Nonye', 'Ruth'); // Nonye is an arugment of the greet function

console.log(greeting);
=======
greet('Nonye', 'Ruth'); // Nonye is an arugment of the greet function
>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193
=======
greet('Nonye', 'Ruth'); // Nonye is an arugment of the greet function
>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193
8 changes: 6 additions & 2 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)
// Call the function and assign to a variable `sum`
{
return num1+num2;
}
const result =add(13,124)
console.log(result);

console.log(sum);
19 changes: 17 additions & 2 deletions exercises/K-functions-parameters/exercise5.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
//- Write a function that takes a name (a string) and an age (a number) and returns a greeting (a string)
// Declare your function here
<<<<<<< HEAD
function greet(myName, age) {//Hello is a Parameter of the greet function
console.log('Hello, my name is ' + myName + ' and I am ' + age + ` Years old`);
}
greet ("Nonye", 33);
console.log(greeting);
=======

const greeting = createLongGreeting("Daniel", 30);
function greet(myName, age) //Hello is a Parameter of the greet function
{
console.log('Hello, my name is ' + myName + ' and I am ' + age + ` Years old`);
}

console.log(greeting);
greet ("Nonye", 33);

//console.log(greeting);

>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193
40 changes: 39 additions & 1 deletion exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
var mentor1 = "Daniel";
let mentor1 = "Daniel";
var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";

<<<<<<< HEAD
function upperCaseName(mentor)
{
return mentor.toLowerCase;
}

function shoutGreeting(mentor)
{
let greeting = 'Hello';
return greeting + upperCaseName(mentor)
}
console.log(shoutGreeting(mentor1));
console.log(shoutGreeting(mentor2));
console.log(shoutGreeting(mentor3));
console.log(shoutGreeting(mentor4));
console.log(shoutGreeting(mentor5));
=======
function upperCaseName(mentor1)
{
let callName = mentor1.toLowerCase;
return callName;
}
console.log(upperCaseName);



// function getAgeInDays(age) {
// return age * 365;
// }

// function createCreeting(name, age) {
// var ageInDays = getAgeInDays(age);
// var message =
// "My Name is " + name + " and I was born over " + ageInDays + " days ago!";
// return message;
// }
>>>>>>> 82d3c6248e7f9737e9c4152aeee1971cff5b8193
13 changes: 7 additions & 6 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 " + 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;

return "The total is total";
total = a + b;
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
3 changes: 3 additions & 0 deletions mandatory/3-function-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ function combine2Words(word1, 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
15 changes: 13 additions & 2 deletions mandatory/4-tax.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@
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.
*/
// const productPrice;
// const totalSalePrice;

function calculateSalesTax(price)
{
// Whatever math is involved to calculate your sales tax here
return price * 1.2;
};

function calculateSalesTax() {}

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

function addTaxAndFormatCurrency() {}
function addTaxAndFormatCurrency(price) {
let newPrice = calculateSalesTax(price);
let newPriceTotal = newPrice.toFixed(2);
return `£${newPriceTotal}`;
}

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