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 Class_8-Busra Erdogan-JS-Week_1 #253
Closed
Closed
Changes from all commits
Commits
Show all changes
3 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
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 @@ | ||
| console.log("Hello world"); | ||
| console.log(8, "Murat", "Busra"); |
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 a string"; | ||
| 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 messageStart = "Hello, my name is "; | ||
| let name = "Busra" | ||
| let message = messageStart + name; | ||
| 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,9 @@ | ||
| // Start by creating a variable `message` | ||
| let name = "Busra"; | ||
| let nameLength = name.length; | ||
|
|
||
| let messageStart = 'My name is '; | ||
| let messageEnd = " characters long"; | ||
| let message = messageStart + name + ' and '+ messageStart.toLocaleLowerCase() + nameLength + messageEnd; | ||
|
|
||
| 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,8 @@ | ||
| const name = " Daniel "; | ||
| let name = ' Busra ' | ||
| let nameLength = name.trim().length; | ||
| let messageEnd = " characters long"; | ||
|
|
||
| console.log(message); | ||
| let messageStart = 'My name is '; | ||
| let messageTrimmed = messageStart + name.trim() + ' and '+ messageStart.toLocaleLowerCase() + nameLength + messageEnd; | ||
|
|
||
| console.log(messageTrimmed); |
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 +1,11 @@ | ||
| // Start by creating a variables `numberOfStudents` and `numberOfMentors` | ||
|
|
||
| let students = 'Number of students: '; | ||
| let numberOfStudents = 33 + 16; | ||
| console.log(students + numberOfStudents); | ||
| let mentors = "Number of mentors: "; | ||
| let numberOfMentors = 8 * 2; | ||
| console.log(mentors + numberOfMentors); | ||
| let totalText = 'Total number of students and mentors: '; | ||
| let total = numberOfMentors + numberOfStudents; | ||
|
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. Very good choice of variable names, the code is easy to follow. |
||
| console.log(totalText + total); | ||
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,12 @@ | ||
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
| let numberOfStudents = 15; | ||
| let numberOfMentors = 8; | ||
|
|
||
| let studentsText = 'Percentage students: ' | ||
| let percentageStudents = (numberOfStudents / (numberOfStudents + numberOfMentors)) * 100; | ||
| let roughPercentageStudents = Math.round(percentageStudents) + '%'; | ||
| console.log(studentsText + roughPercentageStudents); | ||
|
|
||
| let mentorsText = 'Percentage mentors: ' | ||
| let percentageMentors = (numberOfMentors / (numberOfStudents + numberOfMentors)) * 100; | ||
| let roughPercentageMentors = Math.round (percentageMentors) + '%'; | ||
| console.log(mentorsText + roughPercentageMentors); |
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,12 @@ | ||
| function halve(number) { | ||
| // complete the function here | ||
| } | ||
| return number / 2; | ||
| } | ||
|
|
||
| var result = halve(12); | ||
| let result = halve(12); | ||
| let result1 = halve(6); | ||
| let result2 = halve(8); | ||
|
|
||
| console.log(result); | ||
| console.log(result1); | ||
| console.log(result2); | ||
|
|
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 * 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
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 | ||
|
|
||
| var result = divide(3, 4); | ||
| function divide (num1, num2) { | ||
| return num1 / num2; | ||
| }; | ||
| var result = divide(40, 4); | ||
|
|
||
| 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,7 @@ | ||
| // Write your function here | ||
|
|
||
| var greeting = createGreeting("Daniel"); | ||
| function createGreeting (text) { | ||
| return 'Hello ' + text; | ||
| } | ||
| let greeting = createGreeting("Daniel"); | ||
|
|
||
| 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,5 +1,7 @@ | ||
| // Declare your function first | ||
|
|
||
| function add (num1, num2) { | ||
| return num1 + num2; | ||
| } | ||
| // Call the function and assign to a variable `sum` | ||
|
|
||
| let sum = add ( 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,7 @@ | ||
| // 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); | ||
|
|
||
| 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,5 +1,32 @@ | ||
| var mentor1 = "Daniel"; | ||
| var mentor2 = "Irina"; | ||
| var mentor3 = "Mimi"; | ||
| var mentor4 = "Rob"; | ||
| var mentor5 = "Yohannes"; | ||
| let mentor1 = "Daniel"; | ||
| let mentor2 = "Irina"; | ||
| let mentor3 = "Mimi"; | ||
| let mentor4 = "Rob"; | ||
| let mentor5 = "Yohannes"; | ||
| let greeting = "Hello "; | ||
|
|
||
|
|
||
| function greetingMentors (grt, name){ | ||
| return grt + name; | ||
| }; | ||
|
|
||
| let write = greetingMentors(greeting, mentor1); | ||
|
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. All these 5 greetings below are essentially the same code, only the mentor name is different. Could you create another function to reduce duplication of the code? |
||
| let result = write.toUpperCase(); | ||
| console.log(result); | ||
|
|
||
| write = greetingMentors(greeting, mentor2); | ||
| result = write.toUpperCase(); | ||
| console.log(result); | ||
|
|
||
| write = greetingMentors(greeting, mentor3); | ||
| result = write.toUpperCase(); | ||
| console.log(result); | ||
|
|
||
| write = greetingMentors(greeting, mentor4); | ||
| result = write.toUpperCase(); | ||
| console.log(result); | ||
|
|
||
| write = greetingMentors(greeting, mentor5); | ||
| result = write.toUpperCase(); | ||
| 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
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,9 @@ | |
| Sales tax is 20% of the price of the product. | ||
| */ | ||
|
|
||
| function calculateSalesTax() {} | ||
|
|
||
| function calculateSalesTax(productPrice) { | ||
| return productPrice * 0.2 + productPrice; | ||
| }; | ||
| /* | ||
| CURRENCY FORMATTING | ||
| =================== | ||
|
|
@@ -17,7 +18,10 @@ function calculateSalesTax() {} | |
| Remember that the prices must include the sales tax (hint: you already wrote a function for this!) | ||
| */ | ||
|
|
||
| function addTaxAndFormatCurrency() {} | ||
| function addTaxAndFormatCurrency(productPrice) { | ||
| const total = productPrice + productPrice * 0.2 ; | ||
| return `£${total.toFixed(2)}`; | ||
|
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. Hi Busra, good job with using string interpolation. Well done!! |
||
| }; | ||
|
|
||
| /* | ||
| =================================================== | ||
|
|
||
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.
👍 :) Thanks for fixing the spelling errors! It happens all the time in real projects. It's very useful to have a spellchecker configured in your IDE