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: 9 additions & 6 deletions exercises/A-setup-ide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ There are some tools that will help you to write code. One of these, [Prettier](

### 1. Install prettier

* In Visual Studio open the extensions panel (see https://code.visualstudio.com/docs/editor/extension-gallery#_browse-and-install-extensions)
* Search for `Prettier - Code formatter`
* Click install on the top result
- In Visual Studio open the extensions panel (see https://code.visualstudio.com/docs/editor/extension-gallery#_browse-and-install-extensions)
- Search for `Prettier - Code formatter`
- Click install on the top result

### 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
- 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

xxxx
All done for WSL-Ubuntu version
4 changes: 2 additions & 2 deletions exercises/B-hello-world/README.md
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?>>>>SyntaxError: missing ) after argument list
* What happens when you console.log() just a number without quotes?>>>>Without quotes it's just a number but with quotes it's string
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.I just started learning JavaScript!');
console.log(2021);
console.log('2021');
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);
9 changes: 9 additions & 0 deletions exercises/D-strings/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
// Start by creating a variable `message`
var message = 'This is a string';
var messageType = typeof message;
var messageOther = 'Here is an other string';
var messageType = typeof messageOther;
var messageAnother = 'There is an another string';
var messageType = typeof messageAnother;

console.log(message);
console.log(messageOther);
console.log(messageAnother);

5 changes: 4 additions & 1 deletion exercises/E-strings-concatenation/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Start by creating a variable `message`
var greetingStart ='Hello, My name is ';
var name ='Adem';

console.log(message);
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`
const name ='Adem';
const greetings ='My name is '+ name +' and my name is '+name.length +' characters long';
console.log(greetings);



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

console.log(message);
4 changes: 2 additions & 2 deletions exercises/G-numbers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ var difference = 10 - 2; // 8

## Exercise

* Create two variables `numberOfStudents` and `numberOfMentors`
* Log a message that displays the total number of students and mentors
- Create two variables `numberOfStudents` and `numberOfMentors`
- Log a message that displays the total number of students and mentors

## Expected result

Expand Down
12 changes: 12 additions & 0 deletions exercises/G-numbers/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
// Start by creating a variables `numberOfStudents` and `numberOfMentors`
var numberOfStudents =15;
var numberOfMentors =8;
var sum = numberOfStudents + numberOfMentors;
// var product =numberOfStudents * numberOfMentors;
// var quotient=numberOfStudents / numberOfMentors;
// var difference =numberOfStudents - numberOfMentors
console.log('Number of students:'+ numberOfStudents);
console.log('Number of mentors:'+ numberOfMentors);
console.log('Total number of students and mentors:'+ sum);
// console.log(product);
// console.log(quotient);
// console.log(difference);
6 changes: 6 additions & 0 deletions exercises/I-floats/exercise.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
var numberOfStudents = 15;
var numberOfMentors = 8;
const total =numberOfStudents + numberOfMentors;
let percentageOfStudents = Math.round(numberOfStudents/total*100);
let percentageOfMentors = Math.round(numberOfMentors/total*100);
console.log('Percentage Of Students:' + percentageOfStudents +'%');
console.log('Percentage Of Mentors:' + percentageOfMentors +'%');

11 changes: 9 additions & 2 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);

var result2 = halve(14);
var result3 = halve(16);
var result4 = halve(18);
var result5 = halve(20);
console.log(result);
console.log(result2);
console.log(result3);
console.log(result4);
console.log(result5);
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
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
5 changes: 4 additions & 1 deletion 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;

}// Declare your function first

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

var greeting = createGreeting("Daniel");

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

var sum =total(13,124);
console.log(sum);
11 changes: 10 additions & 1 deletion exercises/K-functions-parameters/exercise5.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
// Declare your function here

function createLongGreeting(name , age){
return 'Hello, my name is '+ name +' I am '+ age + ' years old'
}
const greeting = createLongGreeting("Daniel", 30);

console.log(greeting);

// * Write a function that takes a name (a string) and an age (a number) and returns a greeting (a string)

// ## Expected result

// ```
// Hello, my name is Daniel and I'm 30 years old
19 changes: 14 additions & 5 deletions exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
var mentor1 = "Daniel";
var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";

function percentage(num,total){
return Math.round(num/total*100);

};

function result(num,total){
const equal = percentage(num,total);
return equal;

}
console.log('percentage students: '+ result(15,23)+'%');
console.log('percentage mentors: '+ result(8,23)+'%');

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

function upperName(name){

return name.toUpperCase()
};

function shoutyGreeting(name){
var message = 'HELLO' + upperName(name);
return message;

};

console.log(shoutyGreeting(' Daniel'));
console.log(shoutyGreeting(' Irina'));
console.log(shoutyGreeting(' Mimi'));
console.log(shoutyGreeting(' Rob'));
console.log(shoutyGreeting(' Yohannes'));
9 changes: 7 additions & 2 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(price) {
return price*1.4;

}

/*
CURRENCY FORMATTING
Expand All @@ -15,7 +18,9 @@ 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(price) {
return (price*5.7)*0.99;
}

/* ======= TESTS - DO NOT MODIFY =====
There are some Tests in this file that will help you work out if your code is working.
Expand Down
24 changes: 17 additions & 7 deletions extra/2-piping.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,36 @@
the final result to the variable goodCode
*/

function add() {

}
function add(number1,number2) {

function multiply() {
return number1+number2;
}

function multiply(number1,number2) {
return number1*number2;
}

function format() {
function format(number3) {
return "£"+number3;

}

const startingValue = 2

// Why can this code be seen as bad practice? Comment your answer.
let badCode =
//It's hard to read it
// - add 10 to startingValue
// - multiply the result by 2
// - format it

/* BETTER PRACTICE */

let goodCode =
let badCode = format(multiply(add(startingValue,10),2));

/* BETTER PRACTICE */
let total = add(startingValue,10);
let product = multiply(total,2)
let goodCode = format(product);

/* ======= TESTS - DO NOT MODIFY =====
There are some Tests in this file that will help you work out if your code is working.
Expand Down
66 changes: 56 additions & 10 deletions extra/3-magic-8-ball.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,67 @@

// This should log "The ball has shaken!"
// and return the answer.

var givenAnswers= [
"It is certain",
"It is decidedly so.",
"Without a doubt.",
"Yes - definitely.",
"You may rely on it.",


"As I see it, yes.",
"Most likely.",
"Outlook good.",
"Yes.",
"Signs point to yes.",


"Reply hazy, try again.",
"Ask again later.",
"Better not tell you now.",
"Cannot predict now.",
"Concentrate and ask again.",


"Do not count on it.",
"My reply is no.",
"My sources say no.",
"Outlook not so good.",
"Very doubtful.",
];


function shakeBall() {
//Write your code in here
console.log ("The ball has shaken!");
var randomAnswer = Math.floor(Math.random()*19);
return givenAnswers[randomAnswer];
}

/*
This function should say whether the answer it is given is
- very positive
- positive
- negative
- very negative

// *This function should say whether the answer it is given is
// - very positive
// - positive
// - negative
// - very negative

// *This function should expect to be called with any value which was returned by the shakeBall function.

This function should expect to be called with any value which was returned by the shakeBall function.
*/
function checkAnswer(answer) {
//Write your code in here
var xxxx
if (){
return 'very positive'
}
else if (){
return 'positive'
}
else if (){
return 'negative'
}
else {
return 'very negative'
}

}

/*
Expand Down
Loading