-
-
Notifications
You must be signed in to change notification settings - Fork 475
LONDON9-LOVELACE-BOSHRA-MAHMOUDI-JS1-WEEK1 #426
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| console.log("Hello world"); | ||
| console.log("hello world! i just started learning Java Script");// printed out inside quotes | ||
| console.log(2345);//printed out number | ||
| console.log(hello world i am 33 i just leaning java script);//running error | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| // Start by creating a variable `greeting` | ||
|
|
||
| var greeting = "I am BOshra"; | ||
| console.log(greeting); | ||
| console.log(greeting); | ||
| console.log(greeting); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| // Start by creating a variable `message` | ||
|
|
||
| let message = "this is a string"; | ||
| console.log(message); | ||
| console.log(typeof message); |
| 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 = "Boshra"; | ||
| let message = greeting + " " + myName; | ||
|
Contributor
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. This looks good. |
||
| console.log(message); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,15 @@ | ||
| // Start by creating a variable `message` | ||
| let myName = "BOSHRA"; | ||
| let message = | ||
| "my name is " + | ||
| myName + | ||
| " and my name is" + | ||
| myName.length + | ||
| " characters long"; | ||
| console.log(message); | ||
|
|
||
| let nameLowerCase = myName.toLowerCase(); | ||
| console.log(nameLowerCase); | ||
|
|
||
| message = myName.trim(); | ||
| console.log(message); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| const name = " Daniel "; | ||
|
|
||
| let myName = " Daniel "; | ||
| let message = myName.trim(); | ||
| console.log(message); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| // Start by creating a variables `numberOfStudents` and `numberOfMentors` | ||
| let numberOfStudents = 25; | ||
| let numberOfMentors = 10; | ||
| let message = numberOfMentors + numberOfStudents; | ||
| console.log(message); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,8 @@ | ||
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
| let totalNumber = numberOfMentors + numberOfStudents; | ||
| let percentageOfStudents = (numberOfStudents / totalNumber) * 100; | ||
| let roughPercentageOfStudents = Math.round(percentageOfStudents); | ||
|
Contributor
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. Why did you decide to call this variable |
||
| console.log(roughPercentageOfStudents); | ||
| let percentageOfMentors = (numberOfMentors / totalNumber) * 100; | ||
| console.log(Math.round(percentageOfMentors)); | ||
| 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); | ||
|
|
||
| console.log(result); | ||
| result = halve(43); | ||
| console.log(result); | ||
| result = halve(23453); | ||
| console.log(result); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| function triple(number) { | ||
| // complete function here | ||
| return number * 3; | ||
| } | ||
|
|
||
| var result = triple(12); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| // Declare your function first | ||
| function divide(a, b) { | ||
| return a / b; | ||
| } | ||
|
|
||
| var result = divide(3, 4); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,11 @@ | ||
| // Write your function here | ||
| function createGreeting(string) { | ||
| return "my name is " + string; | ||
| } | ||
|
|
||
| var greeting = createGreeting("Daniel"); | ||
|
|
||
| console.log(greeting); | ||
|
|
||
| var greeting = createGreeting("Boshra"); | ||
|
Contributor
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. 👓 Watch out for |
||
| console.log(greeting); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| // Declare your function first | ||
|
|
||
| function add(a, b) { | ||
| return a + b; | ||
| } | ||
| // Call the function and assign to a variable `sum` | ||
| sum = add(13, 124); | ||
|
|
||
| console.log(sum); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,17 @@ var mentor2 = "Irina"; | |
| var mentor3 = "Mimi"; | ||
| var mentor4 = "Rob"; | ||
| var mentor5 = "Yohannes"; | ||
|
|
||
| function upperCaseName(mentor) { | ||
| return mentor.toUpperCase(); | ||
| } | ||
|
|
||
| function greeting(mentor) { | ||
| return `HELLO ${upperCaseName(mentor)}`; | ||
|
Contributor
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. Nice use of template literals here! 😄 |
||
| } | ||
|
|
||
| console.log(greeting(mentor1)); | ||
| console.log(greeting(mentor2)); | ||
| console.log(greeting(mentor3)); | ||
| console.log(greeting(mentor4)); | ||
| console.log(greeting(mentor5)); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| function greeting(mentor) { | ||
| return "HELLO " + upperCaseName(mentor); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 price * 1.4; | ||
| } | ||
|
|
||
| /* | ||
| CURRENCY CONVERSION | ||
|
|
@@ -15,8 +17,10 @@ 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) { | ||
| let newPrice = price * 0.99 * 5.7; | ||
|
Contributor
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. This solution looks good to me - I like your use of multiplication by |
||
| return Number(newPrice.toFixed(2)); | ||
| } | ||
| /* ======= TESTS - DO NOT MODIFY ===== | ||
| There are some Tests in this file that will help you work out if your code is working. | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,9 @@ | |
| Sales tax is 20% of the price of the product. | ||
| */ | ||
|
|
||
| function calculateSalesTax() {} | ||
| function calculateSalesTax(price) { | ||
| return price + (price * 20) / 100; | ||
| } | ||
|
|
||
| /* | ||
| CURRENCY FORMATTING | ||
|
|
@@ -17,8 +19,10 @@ function calculateSalesTax() {} | |
| Remember that the prices must include the sales tax (hint: you already wrote a function for this!) | ||
| */ | ||
|
|
||
| function addTaxAndFormatCurrency() {} | ||
|
|
||
| function addTaxAndFormatCurrency(price) { | ||
| return `£${calculateSalesTax(price).toFixed(2)}`; | ||
|
Contributor
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. Possibly think about adding another variable in here to make the final return value a bit more readable. |
||
| } | ||
| //console.log(addTaxAndFormatCurrency(34)); | ||
| /* | ||
| =================================================== | ||
| ======= TESTS - DO NOT MODIFY BELOW THIS LINE ===== | ||
|
|
||
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.
Hi there @BoshraM,
We've just updated our coursework with a change to the variable declarations.
From now on when you're writing variable declarations be sure to use
let/constovervar.