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 .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
1 change: 0 additions & 1 deletion exercises/B-hello-world/exercise.js

This file was deleted.

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`

var greeting = "Hello world"
console.log(greeting);
console.log(greeting);
console.log(greeting);
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);
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`

var greetingStart = "Hello, my name is ";
var name = "Daniel";
var message = greetingStart + 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`

var name = "Daniel";
var nameLength = name.length;

var message = `My name is ${name} and my name is ${nameLength} characters long`


console.log(message);
5 changes: 5 additions & 0 deletions exercises/F-strings-methods/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
const name = " Daniel ";
var newName = name.trim();
var nameLength = newName.length;

var message = `My name is ${newName} and my name is ${nameLength} characters long`


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

var messageOne = `Number of students: ${numberOfStudents}`;
var messageTwo = `Number of mentors: ${numberOfMentors}`;
var messageThree = `Total numnber of students and mentors: ${total}`;

console.log(messageOne);
console.log(messageTwo);
console.log(messageThree);
7 changes: 7 additions & 0 deletions exercises/I-floats/exercise.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
var numberOfStudents = 15;
var numberOfMentors = 8;
var total = numberOfStudents + numberOfMentors;

var percentageStudents = Math.round((numberOfStudents / total) * 100);
var percentageMentors = Math.round((numberOfMentors / total) * 100);

console.log(`Percentage students: ${percentageStudents}%`);
console.log(`Percentage mentors: ${percentageMentors}%`);
3 changes: 2 additions & 1 deletion exercises/J-functions/exercise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function halve(number) {
// complete the function here
// complete the function
return number / 2;
}

var result = halve(12);
Expand Down
1 change: 1 addition & 0 deletions exercises/J-functions/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function triple(number) {
// complete function here
return number * 3;
}

var result = triple(12);
Expand Down
3 changes: 2 additions & 1 deletion exercises/K-functions-parameters/exercise.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 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
3 changes: 3 additions & 0 deletions exercises/K-functions-parameters/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// Declare your function first
function divide(num1, num2) {
return num1 / num2;
}

var result = divide(3, 4);

Expand Down
3 changes: 3 additions & 0 deletions exercises/K-functions-parameters/exercise3.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// Write your function here
function createGreeting(name) {
return `Hello, my name is ${name}`
}

var greeting = createGreeting("Daniel");

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

const sum = add(13, 124);

// Call the function and assign to a variable `sum`

Expand Down
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
15 changes: 15 additions & 0 deletions exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,18 @@ var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";

function upper(name) {
return name.toUpperCase();
}

function greeting(name) {
var nameUpp = upper(name);
return `HELLO ${nameUpp}`;
}

console.log(greeting(mentor1));
console.log(greeting(mentor2));
console.log(greeting(mentor3));
console.log(greeting(mentor4));
console.log(greeting(mentor5));
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Inside of `exercise.js` there's a line of code that will print "Hello world!".

- Try to `console.log()` something different. For example, 'Hello World. I just started learning JavaScript!'.
- Try to console.log() several things at once.
- What happens when you get rid of the quote marks?
- What happens when you console.log() just a number without quotes?
- What happens when you get rid of the quote marks? `if the entire was string it will be error, if number this is fine`
- What happens when you console.log() just a number without quotes? `the type of the entire will be number`
4 changes: 4 additions & 0 deletions exercises/cd B-hello-world/node exercise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
console.log("Hello world");
console.log('Hello World. I just started learning JavaScript!');
console.log('just started learning JavaScript!');

41 changes: 27 additions & 14 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(prise) {
var USD = prise * 1.4;
return USD;
}

/*
CURRENCY CONVERSION
Expand All @@ -15,7 +18,12 @@ 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(prise) {
var BRL = prise * 5.7;
var result = (BRL * .99);
result = result.toFixed(2);
return result;
}

/* ======= TESTS - DO NOT MODIFY =====
There are some Tests in this file that will help you work out if your code is working.
Expand All @@ -24,18 +32,23 @@ To run these tests type `npm run extraTo run the tests for just this one file, t
(Reminder: You must have run `npm install` one time before this will work!)
*/

test("convertToUSD function works for £32", () => {
expect(convertToUSD(32)).toEqual(44.8);
});
// test("convertToUSD function works for £32", () => {
// expect(convertToUSD(32)).toEqual(44.8);
// });

test("convertToUSD function works for £50", () => {
expect(convertToUSD(50)).toEqual(70);
});
// test("convertToUSD function works for £50", () => {
// expect(convertToUSD(50)).toEqual(70);
// });

test("convertToBRL function works for £30", () => {
expect(convertToBRL(30)).toEqual(169.29);
});
// test("convertToBRL function works for £30", () => {
// expect(convertToBRL(30)).toEqual(169.29);
// });

test("convertToBRL function works for £1.50", () => {
expect(convertToBRL(1.5)).toEqual(8.46);
});
// test("convertToBRL function works for £1.50", () => {
// expect(convertToBRL(1.5)).toEqual(8.46);
// });

console.log(convertToUSD(32));
console.log(convertToUSD(50));
console.log(convertToBRL(30));
console.log(convertToBRL(1.5));
34 changes: 17 additions & 17 deletions extra/2-piping.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,37 @@
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(pirse) {
return `£${pirse}`;
}

const startingValue = 2;

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

/* BETTER PRACTICE */
/* BETTER PRACTICE */

let goodCode =
let goodCode =

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

To run these tests type `npm run extraTo run the tests for just this one file, type `npm run extra-tests -- --testPathPattern 2-piping` into your terminal
(Reminder: You must have run `npm install` one time before this will work!)
*/

To run these tests type `npm run extraTo run the tests for just this one file, type `npm run extra-tests -- --testPathPattern 2-piping` into your terminal
(Reminder: You must have run `npm install` one time before this will work!)
*/

test("add function - case 1 works", () => {
expect(add(1, 3)).toEqual(4);
});
test("add function - case 1 works", () => {
expect(add(1, 3)).toEqual(4);
});

test("add function - case 2 works", () => {
expect(add(2.4, 5)).toEqual(7.4);
Expand Down
38 changes: 21 additions & 17 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;

return "The total is total";
total = a + b;
return "The total is " + total;
}

/*
Expand All @@ -25,16 +25,20 @@ To run the tests for just this one file, type `npm test -- --testPathPattern 1-s
===================================================
*/

test("addNumbers adds numbers correctly", () => {
expect(addNumbers(3, 4, 6)).toEqual(13);
});
// test("addNumbers adds numbers correctly", () => {
// expect(addNumbers(3, 4, 6)).toEqual(13);
// });

// test("introduceMe function returns the correct string", () => {
// expect(introduceMe("Sonjide", 27)).toEqual(
// "Hello, my name is Sonjide and I am 27 years old"
// );
// });

test("introduceMe function returns the correct string", () => {
expect(introduceMe("Sonjide", 27)).toEqual(
"Hello, my name is Sonjide and I am 27 years old"
);
});
// test("getTotal returns a string describing the total", () => {
// expect(getTotal(23, 5)).toEqual("The total is 28");
// });

test("getTotal returns a string describing the total", () => {
expect(getTotal(23, 5)).toEqual("The total is 28");
});
console.log(addNumbers(3, 4, 6));
console.log(introduceMe("Sonjide", 27));
console.log(getTotal(23, 5));
Loading