-
-
Notifications
You must be signed in to change notification settings - Fork 481
london10| Akram Izedi | javascript |week1 #537
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,16 +1,16 @@ | ||
// The syntax for these functions is valid but there are some errors, find them and fix them | ||
|
||
function trimWord(word) { | ||
return wordtrim(); | ||
return word.trim(); | ||
} | ||
|
||
function getStringLength(word) { | ||
return "word".length(); | ||
return word.length; | ||
} | ||
|
||
function multiply(a, b, c) { | ||
a * b * c; | ||
return; | ||
function multiply(a,b,c) { | ||
let times= a*b*c; | ||
return times ; | ||
} | ||
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. Consider: This is how I wrote. Just different names. 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. @softacoder have you used this button in the Github UI? |
||
|
||
/* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,23 @@ | |
function getRandomNumber() { | ||
return Math.random() * 10; | ||
} | ||
//Math.random() The Math.random() static method returns a floating-point, pseudo-random number that's greater than or equal to 0 and less than 1, with approximately uniform distribution over that range // | ||
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. Comment: Well done. You written the code as I have on these three questions. |
||
|
||
|
||
// Add comments to explain what this function does. You're meant to use Google! | ||
function combine2Words(word1, word2) { | ||
return word1.concat(word2); | ||
} | ||
//The concat() method is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array.// | ||
|
||
|
||
|
||
|
||
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 this function is expected to return. | ||
let sentence = firstWord.concat(" ",secondWord , " ",thirdWord); | ||
return sentence; | ||
} | ||
|
||
/* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,10 @@ | |
Sales tax is 20% of the price of the product. | ||
*/ | ||
|
||
function calculateSalesTax() {} | ||
function calculateSalesTax(productPrice) { | ||
let salesTaxForProduct = (productPrice + ((productPrice * 20) / 100)) | ||
return salesTaxForProduct; | ||
}; | ||
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. Comment: Well done. Here is another way to consider |
||
|
||
/* | ||
CURRENCY FORMATTING | ||
|
@@ -17,7 +20,13 @@ function calculateSalesTax() {} | |
Remember that the prices must include the sales tax (hint: you already wrote a function for this!) | ||
*/ | ||
|
||
function addTaxAndFormatCurrency() {} | ||
function addTaxAndFormatCurrency(productPrice) { | ||
let salesTaxForProduct = (productPrice + ((productPrice * 20) / 100)).toFixed(2); | ||
let showTaxAmount = "£".concat(salesTaxForProduct) | ||
return showTaxAmount; | ||
}; | ||
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. Comment: Interesting solution. It works? |
||
|
||
|
||
|
||
/* | ||
=================================================== | ||
|
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.
Comment: These three first questions has the same code as mine