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: 4 additions & 0 deletions exercises/A-setup-ide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ There are some tools that will help you to write code. One of these, [Prettier](
- Search for `Prettier - Code formatter`
- Click install on the top result

Installed.

### 2. Enable formatting on save

- In Visual Studio open the settings file (see https://code.visualstudio.com/docs/getstarted/settings#_creating-user-and-workspace-settings)
- Search for `editor format`
- Set `editor.formatOnSave` and `editor.formatOnPaste` to true

Both set.
2 changes: 2 additions & 0 deletions exercises/B-hello-world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ 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?
"I received an error
- What happens when you console.log() just a number without quotes?
the number is still shows but as a value not string.
6 changes: 5 additions & 1 deletion exercises/B-hello-world/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
console.log("Hello world");
console.log("Hello world!");
console.log("I just started learning JavaScript!")
console.log("I'm Benjamin")
console.log(30)
console.log("30")
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, This is Benjamin!"
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 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 greetingStart = "Hi, my name is ";
var name = "Benjamin";
var message = greetingStart + name + "!";
console.log(message);
3 changes: 3 additions & 0 deletions exercises/F-strings-methods/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Start by creating a variable `message`
var name = "Benjamin";
var nameLength = name.length;
var message = "My name is " + name + " and my name is " + nameLength + " characters long!";

console.log(message);
5 changes: 4 additions & 1 deletion exercises/F-strings-methods/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const name = " Daniel ";
const name = "Benjamin";

var nameTrimmed = name.trim();
var nameLength = name.length;
var message = "My name is " + nameTrimmed + " and my name is " + nameLength + " 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 @@ -25,5 +25,5 @@ var difference = 10 - 2; // 8
```
Number of students: 15
Number of mentors: 8
Total numnber of students and mentors: 23
Total number of students and mentors: 23
```
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 = 32;
var numberOfMentors = 6;
var totalParticipants = numberOfStudents + numberOfMentors;

console.log("Number of students: " + numberOfStudents);
console.log("Number of mentors: " + numberOfMentors);
console.log("Total number of students and mentors: " + totalParticipants);
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 percentValue = 100/(numberOfStudents + numberOfMentors);
var percentOfStudents = Math.round(numberOfStudents * percentValue);
var percentOfMentors = Math.round(numberOfMentors * percentValue);

console.log("Percentage students: " + percentOfStudents +"%");
console.log("Percentage mentors: " + percentOfMentors + "%");
7 changes: 7 additions & 0 deletions exercises/J-functions/exercise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
function halve(number) {
// complete the function here
return number/2;
}

var result = halve(12);

console.log(result);

var result = halve(5);
console.log(result);

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

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

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 sum(num1, num2){
return num1 + num2;
}
// Call the function and assign to a variable `sum`

var sum = sum(13, 124)
console.log(sum);
6 changes: 4 additions & 2 deletions exercises/K-functions-parameters/exercise5.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Declare your function here

const greeting = createLongGreeting("Daniel", 30);
function createLongGreeting(name, age){
return "Hello, my name is " + name + " and I'm " + age + " years old.";
}
const greeting = createLongGreeting("Ben", 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
10 changes: 10 additions & 0 deletions exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@ var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";

function shortGreeting(name){
return "Hello " + name.toUpperCase() +"!";
}

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