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: 3 additions & 1 deletion exercises/B-hello-world/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
console.log("Hello world");
console.log("Hello World!");
console.log("My name is Amelia");
console.log(27)
2 changes: 1 addition & 1 deletion exercises/C-variables/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
When you write code, you'll want to create shortcuts to data values so you can don't have to write out the same value every time.
When you write code, you'll want to create shortcuts to data values so you don't have to write out the same value every time.

We can use _variable_ to create a reference to a value.

Expand Down
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! My name is Amelia.";
console.log(greeting);
console.log(greeting);
console.log(greeting);
4 changes: 3 additions & 1 deletion 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`

var message = "This is a string";
var messageType = typeof message;
console.log(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 = "Hello my name is ";
var name = "Amelia";
var message = greeting + name;
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 name = "Amelia";
var nameLength = name.length;

var message = "My name is " + name + " and my name is " + nameLength + " characters long.";

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 nameTrimmed = name.trim();
var nameLength = name.length;
var message = "My name is " + nameTrimmed + " and my name is " + name.length + " characters long."
console.log(message);
2 changes: 1 addition & 1 deletion exercises/G-numbers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Unlike strings, numbers do not need to be wrapped in quotes.
var age = 30;
```

You can use mathematical operators to caclulate numbers:
You can use mathematical operators to calculate numbers:

```js
var sum = 10 + 2; // 12
Expand Down
7 changes: 7 additions & 0 deletions exercises/G-numbers/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
// Start by creating a variables `numberOfStudents` and `numberOfMentors`
var numberOfStudents = 30;
var numberOfMentors = 10;
var numberOfParticipants = numberOfStudents + numberOfMentors;

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

var studentsPercent = numberOfStudents/(numberOfStudents + numberOfMentors)*100;
var mentorsPercent = numberOfMentors/(numberOfStudents + numberOfMentors)*100;
studentsPercent = Math.round(studentsPercent);
mentorsPercent = Math.round(mentorsPercent);

console.log ("Percentage of students: " + studentsPercent + "%");
console.log ("Percentage of mentors: " + mentorsPercent + "%");
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);

result = halve(7);
console.log(result);

result = halve(10);
console.log(result);

result = halve(64);
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
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
4 changes: 3 additions & 1 deletion exercises/K-functions-parameters/exercise3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Write your function here

function createGreeting (name) {
return "Hello, my name is " + name;
}
var greeting = createGreeting("Daniel");

console.log(greeting);
6 changes: 4 additions & 2 deletions exercises/K-functions-parameters/exercise4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// 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: 3 additions & 1 deletion exercises/K-functions-parameters/exercise5.js
Original file line number Diff line number Diff line change
@@ -1,5 +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);

console.log(greeting);
2 changes: 1 addition & 1 deletion exercises/L-functions-nested/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function getAgeInDays(age) {
return age * 365;
}

function createCreeting(name, age) {
function createGreeting(name, age) {
var ageInDays = getAgeInDays(age);
var message =
"My Name is " + name + " and I was born over " + ageInDays + " days ago!";
Expand Down
16 changes: 16 additions & 0 deletions exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,19 @@ var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";

function uppercase (mentor) {
return mentor.toUpperCase();
}

function createGreeting (mentor) {
var name = uppercase(mentor);
var message = "HELLO " + name;
return message;
}

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