This repository was archived by the owner on Jan 14, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 475
London_9_Meysam-Arshadi_ JavaScript-Core-1-Coursework-Week_01 #432
Open
Meysam-Arshadi
wants to merge
2
commits into
CodeYourFuture:master
Choose a base branch
from
Meysam-Arshadi:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| console.log("Hello world"); | ||
| console.log("Hello world. This is a Test"); | ||
| console.log("Hjkl;fe c"); | ||
| console.log("Hellodsxzwsaz`is a Test"); | ||
| console.log("Hello world. Tlllllllllllllllllll"); | ||
| console.log(8); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| // Start by creating a variable `greeting` | ||
|
|
||
| let greeting = "Hello World!"; | ||
| console.log(greeting); | ||
| console.log(greeting); | ||
| console.log(greeting); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| // Start by creating a variable `message` | ||
|
|
||
| let message = "This is my message"; | ||
| let messageType = typeof message; | ||
| console.log(message); | ||
| console.log(messageType); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| // Start by creating a variable `message` | ||
|
|
||
| let greeting = "My name is "; | ||
| let myName = "Meysam Arshadi"; | ||
| let message = greeting + myName; | ||
| console.log(message); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| // Start by creating a variable `message` | ||
|
|
||
| let name = "Daniel"; | ||
| let nameLength = name.length; | ||
| let message = | ||
| "My name is " + name + " and it is " + nameLength + " charachter."; | ||
| console.log(message); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| const name = " Daniel "; | ||
|
|
||
| const name = "Daniel"; | ||
| let nameLength = name.length; | ||
| let message = | ||
| "My name is " + name + " and it is " + nameLength + " charachter."; | ||
| console.log(message); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,13 @@ | ||
| // Start by creating a variables `numberOfStudents` and `numberOfMentors` | ||
| let numberOfStudents = 15; | ||
| let studentMessage = "Total No of students: " + numberOfStudents; | ||
| console.log(studentMessage); | ||
|
|
||
| let numberOfMentors = 5; | ||
| let mentorsMessage = "Total No of mentors: " + numberOfMentors; | ||
| console.log(mentorsMessage); | ||
|
|
||
| let total = numberOfStudents + numberOfMentors; | ||
| let message = "Total number of students and mentors: " + total; | ||
|
|
||
| console.log(message); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,8 @@ | ||
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
| let numberOfStudents = 15; | ||
| let numberOfMentors = 8; | ||
| let total = numberOfStudents + numberOfMentors; | ||
| console.log("Total:" + " " + total); | ||
| let studentPercentage = (numberOfStudents * 100) / total; | ||
| console.log("Student percentage:" + " %" + Math.round(studentPercentage)); | ||
| let mentorPercentage = (numberOfMentors * 100) / total; | ||
| console.log("Mentor percentage:" + " %" + Math.round(mentorPercentage)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| function halve(number) { | ||
| // complete the function here | ||
| return (number = number / 2); | ||
| } | ||
|
|
||
| var result = halve(12); | ||
| var result = halve(125698); | ||
|
|
||
| console.log(result); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| function triple(number) { | ||
| // complete function here | ||
| return (number = number * 3); | ||
| } | ||
|
|
||
| var result = triple(12); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() { | ||
| // Calculate the result of the function and return it | ||
| function logGreeting(name) { | ||
| let captalizedName = name.toUpperCase(); | ||
| return "HELLO " + captalizedName; | ||
| } | ||
|
|
||
| // Assign the result of calling the function the variable `result` | ||
| var result = multiply(3, 4); | ||
|
|
||
| console.log(result); | ||
| console.log(logGreeting("Daniel")); | ||
| console.log(logGreeting("Irina")); | ||
| console.log(logGreeting("Mimi")); | ||
| console.log(logGreeting("Rob")); | ||
| console.log(logGreeting("Yohannes")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| // Declare your function first | ||
| function divide(a, b) { | ||
| return (divide = a / b); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
| } | ||
|
|
||
| var result = divide(3, 4); | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| // Declare your function first | ||
|
|
||
| function addNumbers(a, b) { | ||
| return a + b; | ||
| } | ||
| // Call the function and assign to a variable `sum` | ||
|
|
||
| let sum = addNumbers(13, 124); | ||
| console.log(sum); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,16 @@ | ||
| // Declare your function here | ||
|
|
||
| function createLongGreeting(name, age) { | ||
| return ( | ||
| "Hello! My name is" + | ||
| " " + | ||
| name + | ||
| "and I am" + | ||
| " " + | ||
| age + | ||
| " " + | ||
| "year old." | ||
| ); | ||
| } | ||
| const greeting = createLongGreeting("Daniel", 30); | ||
|
|
||
| console.log(greeting); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,24 @@ | ||
| // There are syntax errors in this code - can you fix it to pass the tests? | ||
|
|
||
| function addNumbers(a b c) { | ||
| return a + b + c; | ||
| function addNumbers(a, b, c) { | ||
| let total = a + b + c; | ||
| return total; | ||
| } | ||
|
|
||
| function introduceMe(name, age) | ||
| return "Hello, my name is " + name "and I am " age + "years old"; | ||
| console.log(addNumbers(3, 4, 6)); | ||
|
|
||
| function getTotal(a, b) { | ||
| total = a ++ b; | ||
| function introduceMe(name, age) { | ||
| return "Hello, my name is " + name + " and I am " + age + " years old"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just as side note, it is also possible to use interpolation if that is more practical |
||
| } | ||
|
|
||
| return "The total is total"; | ||
| console.log(introduceMe("Sonjide", 27)); | ||
|
|
||
| function getTotal(a, b) { | ||
| total = a + b; | ||
| return "The total is " + total; | ||
| } | ||
|
|
||
| console.log(getTotal(23, 5)); | ||
| /* | ||
| =================================================== | ||
| ======= TESTS - DO NOT MODIFY BELOW THIS LINE ===== | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,8 +5,14 @@ | |
| Sales tax is 20% of the price of the product. | ||
| */ | ||
|
|
||
| function calculateSalesTax() {} | ||
|
|
||
| function calculateSalesTax(price) { | ||
| const itemTax = (price * 20) / 100; | ||
| const total = itemTax + price; | ||
| return total; | ||
| } | ||
| console.log(calculateSalesTax(15)); | ||
| console.log(calculateSalesTax(17.5)); | ||
| console.log(calculateSalesTax(34)); | ||
| /* | ||
| CURRENCY FORMATTING | ||
| =================== | ||
|
|
@@ -17,7 +23,15 @@ function calculateSalesTax() {} | |
| Remember that the prices must include the sales tax (hint: you already wrote a function for this!) | ||
| */ | ||
|
|
||
| function addTaxAndFormatCurrency() {} | ||
| function addTaxAndFormatCurrency(price) { | ||
| const itemTax = (price * 20) / 100; | ||
| const total = itemTax + price; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as chatted int he meeting you could have used: calculateSalesTax(price) |
||
| return "£" + total.toFixed(2); | ||
| } | ||
|
|
||
| console.log(addTaxAndFormatCurrency(15)); | ||
| console.log(addTaxAndFormatCurrency(17.5)); | ||
| console.log(addTaxAndFormatCurrency(34)); | ||
|
|
||
| /* | ||
| =================================================== | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to overwrite the variable. You can just go : return (variable * 3)