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
4 changes: 1 addition & 3 deletions exercises/B-hello-world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ We'll do this in JavaScript, using something called `console.log()`.
Inside of `exercise.js` there's a line of code that will print "Hello world!".

### 1. Run the program

- Open a terminal window
- Change directory to this folder (`cd exercises/B-hello-world`) - assuming you're at the project root
('cd exercises/B-hello-world`) - assuming you're at the project root
- Run the program using node (`node exercise.js`)

### 2. Experiment
Expand Down
5 changes: 4 additions & 1 deletion exercises/B-hello-world/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
console.log("Hello world");
console.log('Hello world');
console.log("hello there!!!");
console.log("finally working!");
console.log("not working");
2 changes: 1 addition & 1 deletion exercises/C-variables/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The program above will print "Hello world" to the console. Notice how it uses th
- Add a variable `greeting` to exercise.js (make sure it comes _before_ the console.log)
- Print your `greeting` to the console 3 times

> Remember: to run this exercise you must change directory to the `C-variables`. If you already have a terminal window open for the previous exercise you can do this by running the command `cd ../C-variables`.
> Remember: to run this exercise you must change directory to the `C-variables`. If you already have a terminal window open for the previous exercise you can do this by running the command ``.

## Expected result

Expand Down
4 changes: 2 additions & 2 deletions exercises/C-variables/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Start by creating a variable `greeting`

console.log(greeting);
let greeting = "Isn't good day at all!"
console.log(greeting);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi Alex,

With this exercise I believe the aim was to print it 3 times. From this I understand you should have had 3 console.log greetings?

I hope the day went better after :)

5 changes: 4 additions & 1 deletion 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 string"

console.log(message);
var messageType = typeof message;

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

var greeting = "Good day, my name is ";
var myName = "Catalina";
var message = greeting + myName;
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`
var message1 = "My name is Catalina-Alexandra and my name is ";
var message2 = " characters long";
var myName = "Catalina-Alexandra";
var nameLength = myName.length;
var message = message1 + nameLength + message2;

console.log(message);
10 changes: 9 additions & 1 deletion exercises/F-strings-methods/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
const name = " Daniel ";
const myName = " Catalina-Alexandra ";
const trimmed = myName.trim();
var message1 = "My name is ";
var message2 = " and my name is ";
var message3 = " characters long";

var nameLength = myName.length;
var message = message1 + trimmed + message2 + nameLength + message3;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I am just suggesting a shorter way, you could have written this, however all the variables may have made it clearer. for the trimmed one u could have put myName.trim straight into the message statement. Also u could maybe have just used variables for things that may change. But what u did is also not wrong. Here is just another alternative.

var message = "My name is" + myName.trim + " and my name is " + myName.length + "characters long";



console.log(message);
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`
var numberOfStudents = 30 + 2;
var numberOfMentors = 8 + 1;
var total = numberOfStudents + numberOfMentors;
console.log("Number of students: " + numberOfStudents);
console.log("Number of mentors: " + numberOfMentors);
console.log("Total number of students and mentors: " + total);
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 proNrOfStudents = 1500 / 23;
var proNrOfMentors = 800 / 23;
var proNrOfStudentsRound = Math.round(proNrOfStudents);
var proNrOfMentorsRound = Math.round(proNrOfMentors);

console.log("Procent of students: " + proNrOfStudentsRound + "%");
console.log("Procent of mentors: " + proNrOfMentorsRound + "%");
3 changes: 2 additions & 1 deletion exercises/J-functions/exercise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
function halve(number) {
// complete the function here
return number / 2;
}

var result = halve(12);
var result = halve(200);

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

console.log(result);
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
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(myName) {
return "Hello, my name is " + myName;
}

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

console.log(greeting);
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(nr1, nr2) {
return nr1 + nr2;
}

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

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

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

console.log(greeting);
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 upCase(name) {
return name.toUpperCase();
}
function greeting(name) {
let shouty = upCase(name);
let message = "GOOD DAY " + shouty;
return message;
}
console.log(greeting(mentor1));
console.log(greeting(mentor2));
console.log(greeting(mentor3));
console.log(greeting(mentor4));
console.log(greeting(mentor5));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great simple way of doing this project.

Just suggesting alternatives, all the console.logs could have been done in the greeting as well but well done.

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

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

}
console.log(convertToUSD(32))
/*
CURRENCY CONVERSION
===================
Expand All @@ -15,8 +18,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(pound) {
return pound * 5.7;
}
console.log(convertToBRL(30));
/* ======= TESTS - DO NOT MODIFY =====
There are some Tests in this file that will help you work out if your code is working.

Expand Down
78 changes: 41 additions & 37 deletions extra/2-piping.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,58 +16,62 @@
the final result to the variable goodCode
*/

function add() {
// function add(2, 4) {
// return 2 + 4;

}
// }

function multiply() {
// function multiply(5, 6) {
// return 5 * 6;

}
// }

function format() {
// function format($, 20) {
// return "$" + "20"

}
// }

const startingValue = 2;
// const startingValue = 2;

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

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

let goodCode =

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

To run the tests for just this one file, type `npm test -- --testPathPattern 2-piping` into your terminal
(Reminder: You must have run `npm install` one time before this will work!)
*/
// /* ======= TESTS - DO NOT MODIFY =====
// There are some Tests in this file that will help you work out if your code is working.

// To run the tests for just this one file, type `npm test -- --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);
});
// test("add function - case 2 works", () => {
// expect(add(2.4, 5)).toEqual(7.4);
// });

test("multiply function works", () => {
expect(multiply(2, 3)).toEqual(6);
});
// test("multiply function works", () => {
// expect(multiply(2, 3)).toEqual(6);
// });

test("format function works for whole number", () => {
expect(format(16)).toEqual("£16");
});
// test("format function works for whole number", () => {
// expect(format(16)).toEqual("£16");
// });

test("format function works for decimal number", () => {
expect(format(10.1)).toEqual("£10.1");
});
// test("format function works for decimal number", () => {
// expect(format(10.1)).toEqual("£10.1");
// });

test("badCode variable correctly assigned", () => {
expect(badCode).toEqual("£24");
});
// test("badCode variable correctly assigned", () => {
// expect(badCode).toEqual("£24");
// });

test("goodCode variable correctly assigned", () => {
expect(goodCode).toEqual("£24");
});
// test("goodCode variable correctly assigned", () => {
// expect(goodCode).toEqual("£24");
// });
Loading