Skip to content
This repository was archived by the owner on Oct 26, 2020. It is now read-only.
Open
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
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// 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
Copy link

Choose a reason for hiding this comment

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

Just to let you know, the reason this code has appeared red is because comments are not allowed in JSON files.

"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\week-1\\1-exercises\\B-hello-world\\exercise.js"
}
]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"launch": {

}
}
Binary file added week-1/0-freecodecamp/Screenshot (434).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions week-1/1-exercises/A-setup-ide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ There are some tools that will help you to write code. One of these, [Prettier](
* 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


I installed the prettier and Enabled the formatting on save.
2 changes: 2 additions & 0 deletions week-1/1-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?
If we pass string without quotes it gives a syntax error.
* What happens when you console.log() just a number without quotes?
The number is displayed on the console.
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 am very excited about learning JavaScript.");
console.log("My name is Ali Haider");
console.log(1234);
4 changes: 3 additions & 1 deletion week-1/1-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);
4 changes: 3 additions & 1 deletion week-1/1-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);
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`

console.log(message);
var greetingStart = "Hello, my name is ";
var name = "Daniel";
var greeting = greetingStart + name;
console.log(greeting);
8 changes: 7 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,9 @@
// Start by creating a variable `message`
var name = "Ali Haider";
var nameLength = name.length;
var greeting = "My name is ";
var greeting2 = " and my name is ";
var message = " characters long";
var totalMessage = greeting + name + greeting2+ nameLength + message;
console.log(totalMessage);

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

console.log(message);
const name = " Ali Haider ";
var orignalName = name.trim();
var orignalNameLength = orignalName.length;
var greeting = "My name is ";
var greeting2 = " and my name is ";
var message = " characters long";
var totalMessage = greeting + orignalName + greeting2 + orignalNameLength+ message;
console.log(totalMessage);
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;

total = numberofStudents+ numberofMentors;

console.log("Number of students: " + numberofStudents);
console.log("Number of mentors: " + numberofMentors);
console.log("Total number of students and mentors: "+ total);
2 changes: 1 addition & 1 deletion week-1/1-exercises/I-floats/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ var roughAge = Math.round(preciseAge); // 30
```
Percentage students: 65%
Percentage mentors: 35%
```
```
8 changes: 8 additions & 0 deletions week-1/1-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;

total = numberOfStudents + numberOfMentors;

var percentageOfStudents = Math.round((numberOfStudents/total) * 100);
var percentageOfMentors = Math.round((numberOfMentors / total) * 100);

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

var result = halve(12);
Expand Down
2 changes: 2 additions & 0 deletions week-1/1-exercises/J-functions/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function triple(number) {
// complete function here
var multiply = number * 3;
return multiply;
}

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,6 +1,8 @@
// Complete the function so that it takes input parameters
function multiply() {
function multiply(num1 , num2) {
// Calculate the result of the function and return it
var result = num1 * num2;
return result;
}

// Assign the result of calling the function the variable `result`
Expand Down
5 changes: 4 additions & 1 deletion week-1/1-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){
var result = num1/num2 ;
return result;
}
var result = divide(3, 4);

console.log(result);
5 changes: 4 additions & 1 deletion week-1/1-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){
var message = "Hello, my name is "+ name;
return message;
}
var greeting = createGreeting("Daniel");

console.log(greeting);
7 changes: 5 additions & 2 deletions week-1/1-exercises/K-functions-parameters/exercise4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Declare your function first

function add( num1 , num2){
var addition = num1 + num2 ;
return addition;
}
// Call the function and assign to a variable `sum`

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

function createLongGreeting(name , age){
var message = "Hello, my name is ";
var message2 = " and I'm ";
var message3 = " years old";
var finalMessage = message + name + message2+ age + message3;
return finalMessage;
}
const greeting = createLongGreeting("Daniel", 30);

console.log(greeting);
18 changes: 13 additions & 5 deletions week-1/1-exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
var mentor1 = "Daniel";
var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";
function Percentage(numberOfStudents, numberOfMentors){
var total = numberOfStudents + numberOfMentors;
var percentageOfStudents = Math.round((numberOfStudents / total) * 100);
var percentageOfMentors = Math.round((numberOfMentors / total) * 100);
return percentageOfMentors,percentageOfStudents;
}
function message(){
console.log("Percentage students: " + Percentage(15,8) + "%");
console.log("Percentage mentors: " + Percentage(8,15) + "%");

}

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

function captilize(str){

str.toUpperCase();
return str.toUpperCase();;
}

function greetings(){
// captilize(mentor1, mentor2, mentor3, mentor4, mentor5);
var msg = "HELLO ";
console.log( msg + captilize(mentor1));
console.log(msg + captilize(mentor2));
console.log(msg + captilize(mentor3));
console.log(msg + captilize(mentor4));
console.log(msg + captilize(mentor5));

}
greetings();
16 changes: 10 additions & 6 deletions week-1/2-mandatory/1-syntax-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

// There are syntax errors in this code - can you fix it to pass the tests?

function addNumbers(a b c) {
function addNumbers(a ,b, c) {
return a + b + c;
}

function introduceMe(name, age)
return "Hello, my name is " + name "and I am " age + "years old";

function introduceMe(name, age){
return "Hello, my name is "+name+ " and I am "+age+ " years old";
}
function getAddition(a, b) {
total = a ++ b
total = a + b;

// Use string interpolation here
return "The total is %{total}"
return `The total is ${total}`;
}
function getRemainder (a,b){

return "The remainder is "+ a % b;
}

/* ======= TESTS - DO NOT MODIFY ===== */
Expand Down
8 changes: 4 additions & 4 deletions week-1/2-mandatory/2-logic-error.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// The syntax for this function is valid but it has an error, find it and fix it.

function trimWord(word) {
return wordtrim();
return word.trim();
}

function getWordLength(word) {
return "word".length()
return word.length;
}

function multiply(a, b, c) {
a * b * c;
return;

return a * b * c;
}

/* ======= TESTS - DO NOT MODIFY =====
Expand Down
6 changes: 6 additions & 0 deletions week-1/2-mandatory/3-function-output.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
// Add comments to explain what this function does. You're meant to use Google!
// This function generate a random number between a range of 0 to 10.
// Math.random() generate a floating point number between a range of 0 to 1.
// In which 0 is inclusive and 1 is exclusive.
function getNumber() {
return Math.random() * 10;
}

// Add comments to explain what this function does. You're meant to use Google!
// concat() method is used to combine or join two strings.
// In this function w2 is added to the infront of w1.
Copy link

Choose a reason for hiding this comment

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

This is almost right! If you try running this function by providing string inputs w1 and w2 where does w2 go?

function s(w1, w2) {
return w1.concat(w2);
}

function concatenate(firstWord, secondWord, thirdWord) {
// Write the body of this function to concatenate three words together
// Look at the test case below to understand what to expect in return
return firstWord+" "+secondWord+" "+thirdWord
Copy link

Choose a reason for hiding this comment

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

This definitely works but could you think of another way of doing this, perhaps using concat?

}

/* ======= TESTS - DO NOT MODIFY =====
Expand Down
8 changes: 6 additions & 2 deletions week-1/2-mandatory/4-tax.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
Sales tax is 20% of the price of the product
*/

function calculateSalesTax() {}
function calculateSalesTax(price) {
return (price/100*20) + price;
}

/*
CURRENCY FORMATTING
Expand All @@ -17,7 +19,9 @@ function calculateSalesTax() {}
Remember that the prices must include the sales tax (hint: you already wrote a function for this!)
*/

function formatCurrency() {}
function formatCurrency(price) {
return "£"+calculateSalesTax(price).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