-
-
Notifications
You must be signed in to change notification settings - Fork 482
Mandatory & Extra(I have a problem with Magic Ball #531
base: master
Are you sure you want to change the base?
Conversation
extra/3-magic-8-ball.js
Outdated
let answer = shakeBall(); | ||
console.log(answer); |
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.
It is not necessary to call that function again, better to remove it
extra/3-magic-8-ball.js
Outdated
"Very doubtful.", | ||
]; | ||
|
||
console.log("The ball has shaken!"); |
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.
this console.log has to be within shakeBall() function in order to pass the test
function checkAnswer(answer) { | ||
//Write your code in here | ||
if ( |
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.
this loop with possible answers is pretty messed up, I tried it locally, but it makes mistakes. Just try to remove answers from the very positive section, it's going to give you "true" anyway. I would not say it's reliable. My advice is to rewrite it, using includes() method for each array with the answers
@@ -45,10 +45,39 @@ | |||
|
|||
// This should log "The ball has shaken!" | |||
// and return the answer. | |||
const answers = [ |
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.
Try to break this array into four arrays and then put them into one. e.g
veryPositive = [];
positive = [];
You can use spread operator
answers[...verypositive, ...positive]
extra/3-magic-8-ball.js
Outdated
} | ||
|
||
console.log(shakeBall()); |
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.
What's the purpose of it? :)
@@ -5,7 +5,9 @@ | |||
Write a function that converts a price to USD (exchange rate is 1.4 $ to £) | |||
*/ | |||
|
|||
function convertToUSD() {} | |||
function convertToUSD(pound) { | |||
return pound * 1.4; |
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.
a tip to make your code easier to understand for others, and yourself in future: you can assign numbers to variables so you know what they represent, e.g.
const exchangeRate = 1.4;
return pound * exchangeRate;
function convertToBRL(pound) { | ||
let fee = pound / 100; | ||
let converting = (pound - fee) * 5.7; | ||
return Number(converting.toFixed(2)); |
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.
Nice job using .toFixed() and then converting it back to a Number again 👍
function addTaxAndFormatCurrency() {} | ||
function addTaxAndFormatCurrency(sele) { | ||
let selesWithTaxes = calculateSalesTax(sele); | ||
let plusDecimalToSeles = selesWithTaxes.toFixed(2); |
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.
nice job breaking the steps down by assigning values to named variables
Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in
HOW_TO_MARK.md
in the root of this repositoryYour Details
Homework Details
Notes
What did you find easy?
What did you find hard?
What do you still not understand?
Magic Ball
Any other notes?