Skip to content
This repository was archived by the owner on Oct 26, 2020. It is now read-only.

Week3 amended #93

Open
wants to merge 65 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
6c893ee
Update pull_request_template.md
nouri89 Jun 18, 2020
5189eb2
testing the console
nouri89 Jun 18, 2020
756cf5d
printing Hello world three times
nouri89 Jun 18, 2020
6dc1425
solve exercise D
nouri89 Jun 19, 2020
d923411
solving exercise D
nouri89 Jun 19, 2020
b9d7400
solving exercise E
nouri89 Jun 19, 2020
9a6edf6
solving excercise1
nouri89 Jun 19, 2020
4a7c672
solving exercise
nouri89 Jun 19, 2020
f00e033
solve exercise G
nouri89 Jun 19, 2020
ecf75a6
solving float exercise
nouri89 Jun 19, 2020
b3c20c5
solving exercise
nouri89 Jun 19, 2020
7d84ec7
solving Function exercise
nouri89 Jun 19, 2020
fa1e45c
solve exercise
nouri89 Jun 19, 2020
4e50e82
solve exercise
nouri89 Jun 19, 2020
fd04331
update exercise
nouri89 Jun 19, 2020
75a7612
solve exercise4.js
nouri89 Jun 19, 2020
71490ad
Solve exercise5.js
nouri89 Jun 19, 2020
6aa1514
sove exercise L
nouri89 Jun 19, 2020
3626e06
Solving currency conversion exercise
nouri89 Jun 19, 2020
7cfd051
solve piping exercise
nouri89 Jun 19, 2020
d648fd9
mark as done
nouri89 Jun 25, 2020
5c71bac
Mark as done
nouri89 Jun 25, 2020
4526f42
Complete Exercise
nouri89 Jun 25, 2020
1eedd9c
Complete Comparison exercise
nouri89 Jun 25, 2020
6f848d3
Complete Predicates exercise
nouri89 Jun 25, 2020
3cdf839
Complete conditional exercise
nouri89 Jun 25, 2020
635eaaf
complete logical exercise
nouri89 Jun 25, 2020
b3069f6
complete logical exercise2
nouri89 Jun 25, 2020
8e260a4
Update exercise-1.js
nouri89 Jun 25, 2020
9c603f5
Solve Exercise2
nouri89 Jun 25, 2020
3a801d8
Solve exercise 3
nouri89 Jun 25, 2020
8ca4cfc
Solve exercise4
nouri89 Jun 25, 2020
dd837fe
solve array exercise
nouri89 Jun 25, 2020
952cc2c
solve array exercise
nouri89 Jun 25, 2020
929fd83
solve array exercsie
nouri89 Jun 25, 2020
fa65fda
solve exercise
nouri89 Jun 25, 2020
f9f74da
solve exercise 2
nouri89 Jun 25, 2020
fd97683
solve fix-functions exercise
nouri89 Jun 25, 2020
01a7765
solve function-creation exercise
nouri89 Jun 25, 2020
9e9acbf
solve plying-computer exercise
nouri89 Jun 25, 2020
72f97b0
solving sorting-algorithm exercise
nouri89 Jun 25, 2020
07880c1
solving first question of radio-stations exercise
nouri89 Jun 25, 2020
b94d3c5
updating week number
nouri89 Jun 26, 2020
1cf6135
Solving radio stations exercise
nouri89 Jun 26, 2020
ad6acba
solved
nouri89 Jul 3, 2020
b1bbb6a
solved
nouri89 Jul 3, 2020
c952303
solved
nouri89 Jul 3, 2020
a4e3f82
Update week number
nouri89 Jul 5, 2020
cb14d9e
solved
nouri89 Jul 5, 2020
ba940e2
solved
nouri89 Jul 5, 2020
b90c06f
solved
nouri89 Jul 5, 2020
be658f7
solved
nouri89 Jul 5, 2020
3b5b4e4
solved
nouri89 Jul 5, 2020
8c59b19
solved
nouri89 Jul 5, 2020
26c9b87
solved
nouri89 Jul 5, 2020
7e426be
solved
nouri89 Jul 5, 2020
3b5579c
solved
nouri89 Jul 5, 2020
71051f5
solved
nouri89 Jul 5, 2020
5ac4e9d
Update 3-space-colonies.js
nouri89 Jul 5, 2020
7cf1c65
solved
nouri89 Jul 5, 2020
a969270
solved
nouri89 Jul 6, 2020
78d6df1
solved
nouri89 Jul 6, 2020
c11ba23
solved
nouri89 Jul 6, 2020
2e639a4
solved
nouri89 Jul 6, 2020
436c1e3
solved
nouri89 Jul 7, 2020
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
10 changes: 5 additions & 5 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Your Details

Your Name:
Your City:
Your Slack Name:
Your Name:Abdennour Hachemi
Your City:Birmingham
Your Slack Name:nouri89

# Homework Details

Module:
Week:
Module:javaScript
Week:3
4 changes: 3 additions & 1 deletion week-1/1-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. i have just started learning javaScript.' + 4 + ` testing the new methode over ${24} hours`);

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

console.log(greeting);
let greeting = 'Hello World';
for (i = 0; i < 3; i++) {
console.log(greeting);
}
5 changes: 3 additions & 2 deletions week-1/1-exercises/D-strings/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Start by creating a variable `message`
let message = 'Learning javaScript is Fun ';
let myMessage = typeof message;

console.log(message);
console.log(`${message} \n${myMessage}`);
6 changes: 4 additions & 2 deletions week-1/1-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`
let greeting = "Hello, my name is ";
let myName = "Abdennour";
let message = greeting + myName;

console.log(message);
console.log(message);
7 changes: 6 additions & 1 deletion week-1/1-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 myName = "Abdennour";
var myNameLowerCase=myName.toLowerCase();
var myNameLength = myName.length;
var message =
"My Name is "+ myName+" and iss " + myNameLength + " Characters Long.";
console.log(message);
console.log(myNameLowerCase);
5 changes: 4 additions & 1 deletion week-1/1-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 = " Daniel ".trim();
let nameLength = name.length;

var message =
"My Name is " + name + "and is " + nameLength + " Characters Long.";
console.log(message);
8 changes: 8 additions & 0 deletions week-1/1-exercises/G-numbers/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
// Start by creating a variables `numberOfStudents` and `numberOfMentors`
var numberOfStudents = 15;
var numberOfMentors = 8;
console.log(
`Number of students: ${numberOfStudents}\nNumber of mentors: ${numberOfMentors}\nTotal number of students and mentors: ${
numberOfStudents + numberOfMentors
}`
);

18 changes: 18 additions & 0 deletions week-1/1-exercises/I-floats/exercise.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
var numberOfStudents = 15;
var numberOfMentors = 8;
/* Using the variables provided in the exercise calculate the percentage of mentors and students in the group

## Expected result

```
Percentage students: 65%
Percentage mentors: 35%*/
var numberOfStudents = 15;
var numberOfStudents = 15;
var studentsPercentage = Math.round(
(numberOfStudents / (numberOfStudents + numberOfMentors)) * 100
);
var numberOfMentors = 8;
var mentorsPercentage = Math.round(
(numberOfMentors / (numberOfStudents + numberOfMentors)) * 100
);
console.log(`Percentage students: ${studentsPercentage}%`);
console.log(`Percentage mentors: ${mentorsPercentage}%`);
5 changes: 4 additions & 1 deletion week-1/1-exercises/J-functions/exercise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
function halve(number) {
// complete the function here

return number / 2;
}

var result = halve(12);

console.log(result);
console.log(halve(111));
console.log(halve(20.5));
2 changes: 1 addition & 1 deletion week-1/1-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: 3 additions & 1 deletion week-1/1-exercises/K-functions-parameters/exercise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Complete the function so that it takes input parameters
function multiply() {
function multiply(a,b) {
var multiple= a*b;
return multiple;
// Calculate the result of the function and return it
}

Expand Down
4 changes: 4 additions & 0 deletions week-1/1-exercises/K-functions-parameters/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// Declare your function first
function divide(a,b){
var division=a/b;
return division;
}

var result = divide(3, 4);

Expand Down
3 changes: 3 additions & 0 deletions week-1/1-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){
return `Hello, my name is ${name}`
}

var greeting = createGreeting("Daniel");

Expand Down
6 changes: 5 additions & 1 deletion week-1/1-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 addition(num1, num2) {
let result = num1 + num2;
return result;
}

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

let sum = addition(13, 124);
console.log(sum);
12 changes: 12 additions & 0 deletions week-1/1-exercises/K-functions-parameters/exercise5.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
// Declare your function here
/* * 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
```
*/
function createLongGreeting(string, num) {
let greet = `Hello, my name is ${string} and I'm ${num} years old `;
return greet;
}

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

Expand Down
29 changes: 29 additions & 0 deletions week-1/1-exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,32 @@ var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";
var students = 15;
var mentors = 8;
function percentage(calculatePercentage) {
var percent = Math.round((calculatePercentage / (students + mentors)) * 100);
return percent;
}

function message() {
console.log(
`Percentage Mentors: ${percentage(
students
)}%\nPercentage mentors: ${percentage(mentors)}%`
);
}
message();
/* In `exercise2.js` you have been provided with the names of some mentors. Write a program that logs a shouty greeting to each one.
- Your program should include a function that spells their name in uppercase, and a function that creates a shouty greeting.
- Log each greeting to the console. */
function upperCase(name) {
mentorName = name.toUpperCase();
return mentorName;
}
mentors = [mentor1, mentor2, mentor3, mentor3, mentor4, mentor5];
function greeting() {
for (i = 0; i < 5; i++) {
console.log(`HEllO ${upperCase(mentors[i])}`);
}
}
greeting();
32 changes: 22 additions & 10 deletions week-1/3-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(AmountToConvert) {
var usDollarEquivlent = AmountToConvert * 1.4;
return usDollarEquivlent; //.toFixed(2);
}

/*
CURRENCY FORMATTING
Expand All @@ -16,7 +19,16 @@ function convertToUSD() {}
Find a way to add 1% to all currency conversions (think about the DRY principle)
*/

function convertToBRL() {}
function convertToBRL(AmountToConvert) {
var realBrazilianEquivlent = AmountToConvert * 5.7;
realBrazilianEquivlent = addOnePercentFee(realBrazilianEquivlent);
return realBrazilianEquivlent; //.toFixed(2);
}
function addOnePercentFee(transactionAmount) {
var fee = transactionAmount * 0.01;
transactionPlusFee = transactionAmount + fee;
return transactionPlusFee;
}

/* ======= TESTS - DO NOT MODIFY =====
There are some Tests in this file that will help you work out if your code is working.
Expand All @@ -25,14 +37,14 @@ To run these tests type `node 1-currency-conversion` into your terminal
*/

function test(test_name, expr) {
let status;
if (expr) {
status = "PASSED";
} else {
status = "FAILED";
}

console.log(`${test_name}: ${status}`);
let status;
if (expr) {
status = "PASSED";
} else {
status = "FAILED";
}

console.log(`${test_name}: ${status}`);
}

test("convertToUSD function works", convertToUSD(32) === 44.8);
Expand Down
52 changes: 28 additions & 24 deletions week-1/3-extra/2-piping.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,30 @@
the final result to the variable goodCode
*/

function add() {

function add(x, y) {
let sum = (x * 10 + y * 10) / 10;
return sum;
}

function multiply() {

console.log(add(2.4, 5.3));
function multiply(x, y) {
let multiple = x * y;
return multiple;
}

function format() {

function format(number) {
return `£${number}`;
}

const startingValue = 2
const startingValue = 2;

// Why can this code be seen as bad practice? Comment your answer.
let badCode =
let badCode = format(multiply(add(startingValue, 10), 2));

/* BETTER PRACTICE */

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

/* ======= 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,19 +48,19 @@ To run these tests type `node 2-piping.js` into your terminal
*/

function test(test_name, expr) {
let status;
if (expr) {
status = "PASSED"
} else {
status = "FAILED"
}

console.log(`${test_name}: ${status}`)
let status;
if (expr) {
status = "PASSED";
} else {
status = "FAILED";
}

console.log(`${test_name}: ${status}`);
}

test('add function - case 1 works', add(1,3) === 4)
test('add function - case 2 works', add(2.4,5.3) === 7.7)
test('multiply function works', multiply(2,3) === 6)
test('format function works', format(16) === "£16")
test('badCode variable correctly assigned', badCode === "£24")
test('goodCode variable correctly assigned', goodCode === "£24")
test("add function - case 1 works", add(1, 3) === 4);
test("add function - case 2 works", add(2.4, 5.3) === 7.7);
test("multiply function works", multiply(2, 3) === 6);
test("format function works", format(16) === "£16");
test("badCode variable correctly assigned", badCode === "£24");
test("goodCode variable correctly assigned", goodCode === "£24");
2 changes: 1 addition & 1 deletion week-2/0-freecodecamp/0-freecodecamp.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## FreeCodeCamp
## FreeCodeCamp done

If you haven't already, you should complete all of these lessons on FreeCodeCamp - https://www.freecodecamp.org/learn

Expand Down
1 change: 1 addition & 0 deletions week-2/1-exercises/A-expressions/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/***********************DONE***************************************************************/
In JavaScript there are **expressions** and **statements**. We will use these words frequently to describe code.

### Expression
Expand Down
11 changes: 7 additions & 4 deletions week-2/1-exercises/B-boolean-literals/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
*/

var codeYourFutureIsGreat = true;
var mozafarIsCool = false;
var calculationCorrect = true;
var moreThan10Students = false;

/*
DO NOT EDIT BELOW THIS LINE
--------------------------- */

console.log("Is Code Your Future great?", codeYourFutureIsGreat);
console.log("Is Mozafar cool?", mozafarIsCool);
console.log("Does 1 + 1 = 2?", calculationCorrect);
console.log("Are there more than 10 students?", moreThan10Students);
console.log('Is Code Your Future great?', codeYourFutureIsGreat);
console.log('Is Mozafar cool?', mozafarIsCool);
console.log('Does 1 + 1 = 2?', calculationCorrect);
console.log('Are there more than 10 students?', moreThan10Students);

/*
EXPECTED RESULT
Expand Down
6 changes: 3 additions & 3 deletions week-2/1-exercises/C-comparison-operators/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

var studentCount = 16;
var mentorCount = 9;
var moreStudentsThanMentors; // finish this statement
var moreStudentsThanMentors= studentCount>mentorCount; // finish this statement

var roomMaxCapacity = 25;
var enoughSpaceInRoom; // finish this statement
var enoughSpaceInRoom=roomMaxCapacity>=(studentCount+mentorCount); // finish this statement

var personA = "Daniel";
var personB = "Irina";
var sameName; // finish this statement
var sameName=personA===personB; // finish this statement

/*
DO NOT EDIT BELOW THIS LINE
Expand Down
3 changes: 2 additions & 1 deletion week-2/1-exercises/D-predicates/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

// Finish the predicate function to test if the passed number is negative (less than zero)
function isNegative(number) {
return number<0;

}

// Finish the predicate function to test if the passed number is between 0 and 10
function isBetweenZeroAnd10(number) {

return (number >= 0 && number <=10) ;
}

/*
Expand Down
Loading