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
14 changes: 7 additions & 7 deletions exercises/B-hello-world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ 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 B-hello-world`)
* Run the program using node (`node exercise.js`)
- Open a terminal window
- Change directory to this folder (`cd B-hello-world`)
- Run the program using node (`node exercise.js`)

### 2. Experiment

* 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?
- 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? You get a syntax error
- What happens when you console.log() just a number without quotes? It prints the number
3 changes: 3 additions & 0 deletions 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. I just started learning JavaScript!');
console.log("My name is Aisha");
console.log(25);
5 changes: 5 additions & 0 deletions exercises/C-variables/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Start by creating a variable `greeting`


var greeting = "Hello World";

console.log(greeting);
console.log(greeting);
console.log(greeting);
4 changes: 4 additions & 0 deletions exercises/D-strings/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Start by creating a variable `message`

var message = "This is a string";
var messageType = typeof message;

console.log(message);
console.log(messageType);
7 changes: 6 additions & 1 deletion exercises/E-strings-concatenation/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Start by creating a variable `message`

console.log(message);
var greetingStart = "Hello, my name is ";
var name = "Aisha";

var greeting = greetingStart + name;

console.log(greeting);
6 changes: 5 additions & 1 deletion exercises/F-strings-methods/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Start by creating a variable `message`

console.log(message);
var name = "Aisha";
var nameLength = name.length;
var message = "My name is " + name + " and the length of name is " +nameLength +" characters long."

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe we could do with a pronoun just before name on " and the length of name is " and a space before nameLength.


console.log(message);
4 changes: 3 additions & 1 deletion exercises/F-strings-methods/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const name = " Daniel ";
var nameLength = name.length;
message = "My name is " + name+" and my name is "+ nameLength + " characters long"

console.log(message);
console.log(message.trim());
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 = numberOfStudents + numberOfMentors;

console.log("The total number of students and mentors is " + sum);
11 changes: 11 additions & 0 deletions exercises/I-floats/exercise.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
var numberOfStudents = 15;
var numberOfMentors = 8;

const sum = numberOfStudents+ numberOfMentors;


const percentageStudents = numberOfStudents / sum *100;
const roughPercentageStudents = Math.round(percentageStudents);
console.log(roughPercentageStudents);

const percentageMentors = numberOfMentors / sum *100;
const roughPercentageMentors = Math.round(percentageMentors);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Lovely labelling of variables

console.log(roughPercentageMentors);
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
6 changes: 5 additions & 1 deletion exercises/J-functions/exercise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
function halve(number) {
// complete the function here
return number/2;
}

var result = halve(12);


console.log(result);

var result = halve(40);
console.log(result);
2 changes: 1 addition & 1 deletion exercises/J-functions/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function triple(number) {
// complete function here
return number*3;
}

var result = triple(12);
Expand Down
4 changes: 2 additions & 2 deletions exercises/K-functions-parameters/exercise.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Complete the function so that it takes input parameters
function multiply() {
// Calculate the result of the function and return it
function multiply(num1,num2) {
return num1*num2;
}

// Assign the result of calling the function the variable `result`
Expand Down
6 changes: 4 additions & 2 deletions exercises/K-functions-parameters/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Declare your function first

function divide(num1,num2){
return num1/num2;
}

var 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,4 +1,7 @@
// Write your function here
function createGreeting(name) {
const message = "Hello, my name is " + name;
return message;
}

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,5 +1,10 @@
// Declare your function first
function add (num1,num2){
return num1+num2;
}

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

var sum = add(13,124);

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

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

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

function calculatePercent(num,sum) {
return Math.round(num/sum *100);
}

var percentageOfStudents = calculatePercent(15,23);
var percentageOfMentors = calculatePercent(8,23);


function percentageMessage(individual,percentage){
message = "The percentage of " +individual + " is " + percentage +"%.";
return message;

}

console.log(percentageMessage("students",percentageOfStudents));
console.log(percentageMessage("mentors",percentageOfMentors));


function greeting(name){
return "HELLO " + name;
}

var mentor1 = "Daniel";
var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";

console.log(greeting(mentor1));
console.log(greeting(mentor2));
console.log(greeting(mentor3));
console.log(greeting(mentor4));
console.log(greeting(mentor5));
11 changes: 6 additions & 5 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;
total = a + b;

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

/*
Expand Down