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
13 changes: 8 additions & 5 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,24 @@ Please complete the details below this message

# Your Details

- Your Name:
- Your City:
- Your Slack Name:
- Your Name: Davood Khoshnood
- Your City: London
- Your Slack Name: Davood

# Homework Details

- Module:
- Week:
- Module: JavaScript
- Week: 1

# Notes

- What did you find easy?
All of them were easy.

- What did you find hard?
Nothing.

- What do you still not understand?
First time as usual I confused about all questions I must answered. It wasn't clear.

- Any other notes?
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{

}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{

}
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? I'll get an error.
- What happens when you console.log() just a number without quotes? It'll print the number on console.
7 changes: 6 additions & 1 deletion exercises/B-hello-world/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
console.log("Hello world");
console.log("Hello world!");
console.log("Hello world. I just started learning JavaScript!");
console.log("Happy new year!");
console.log("I'm trying to use more console.log!");

console.log(456);
3 changes: 3 additions & 0 deletions exercises/C-variables/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Start by creating a variable `greeting`
let greeting='Hello world'

console.log(greeting);
console.log(greeting);
console.log(greeting);
6 changes: 5 additions & 1 deletion 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`

console.log(message);
let message = 'This is a string'
let 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);
const greetingStart = 'Hello, my name is '
const myName = 'Daniel'

let greeting = greetingStart + myName

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

console.log(message);
let name = 'Davood'
let lengthName = name.length

let message =
'My name is ' + name + ' and my name is ' + lengthName + ' characters long'

console.log(message)
12 changes: 10 additions & 2 deletions exercises/F-strings-methods/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
const name = " Daniel ";
const name = ' Daniel '
let lengthName = name.length

console.log(message);
let message =
'My name is ' +
name.trim() +
' and my name is ' +
lengthName +
' characters long'

console.log(message)
9 changes: 9 additions & 0 deletions exercises/G-numbers/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
// Start by creating a variables `numberOfStudents` and `numberOfMentors`

let numberOfMentors = 22
let numberOfStudents = 43

let total = numberOfStudents + numberOfMentors

console.log('Number of mentors: ' + numberOfMentors)
console.log('Number of students: ' + numberOfStudents)
console.log('Total number of mentors and students: ' + total)
12 changes: 10 additions & 2 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;
let numberOfStudents = 15
let numberOfMentors = 8

let total = numberOfStudents + numberOfMentors

let percentageStudents = (numberOfStudents * 100) / total
let percentageMentors = (numberOfMentors * 100) / total

console.log('Percentage students: ' + Math.round(percentageStudents) + '%')
console.log('Percentage mentors: ' + Math.round(percentageMentors) + '%')
9 changes: 7 additions & 2 deletions exercises/J-functions/exercise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
function halve(number) {
// complete the function here
return number * 2
}

var result = halve(12);
let result = halve(12)
let result2 = halve(52)
let result3 = halve(6)

console.log(result);
console.log(result)
console.log(result2)
console.log(result3)
5 changes: 3 additions & 2 deletions 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);
let result = triple(12)

console.log(result);
console.log(result)
7 changes: 4 additions & 3 deletions exercises/K-functions-parameters/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// 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`
var result = multiply(3, 4);
let result = multiply(3, 4)

console.log(result);
console.log(result)
7 changes: 5 additions & 2 deletions exercises/K-functions-parameters/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Declare your function first
function divide(num1, num2) {
return num1 / num2
}

var result = divide(3, 4);
let result = divide(3, 4)

console.log(result);
console.log(result)
7 changes: 5 additions & 2 deletions 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(name) {
return 'Hello, my name is ' + name
}

var greeting = createGreeting("Daniel");
let greeting = createGreeting('Daniel')

console.log(greeting);
console.log(greeting)
6 changes: 5 additions & 1 deletion exercises/K-functions-parameters/exercise4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Declare your function first
function sumNumbers(num1, num2) {
return num1 + num2
}

// Call the function and assign to a variable `sum`
let sum = sumNumbers(13, 124)

console.log(sum);
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) {
return "Hello, my name is "+name+" and I'm "+age+" years old"
}


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

Expand Down
14 changes: 14 additions & 0 deletions exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
function greeting(name) {
return 'HELLO ' + name.toUpperCase();
}


var mentor1 = "Daniel";

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 Davood, i would recommend you use let rather than var. It is an outdated way to name variables and let is better.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi Teniolao, I've changed and committed it again. thanks.

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));

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

function convertToUSD() {}
function convertToUSD(price) {
return parseFloat((price * 1.4).toFixed(2));
}

/*
CURRENCY CONVERSION
Expand All @@ -15,7 +17,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 parseFloat((((price * 99) / 100) * 5.7).toFixed(2));
}

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

function add() {

function add(num1, num2) {
return num1 + num2
}

function multiply() {

function multiply(num1, num2) {
return num1 * num2
}

function format() {

function format(num) {
return '£' + num
}

const startingValue = 2;
const startingValue = 2

// Why can this code be seen as bad practice? Comment your answer.
let badCode =
// Because it makes confused someone to read and understand and debug.
let badCode = format(multiply(add(startingValue, 10), 2))

/* BETTER PRACTICE */
let sum = add(startingValue, 10)
let multi = multiply(sum, 2)

let goodCode =
let goodCode = format(multi)

/* ======= TESTS - DO NOT MODIFY =====
There are some Tests in this file that will help you work out if your code is working.
Expand All @@ -44,30 +47,30 @@ To run the tests for just this one file, type `npm test -- --testPathPattern 2-p
(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