Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

Mandatory & Extra(I have a problem with Magic Ball #531

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

KristinaDudnyk
Copy link

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 repository

Your Details

  • Your Name: Kristina Dudnyk
  • Your City: KristinaDudnyk
  • Your Slack Name: KristinaDudnyk

Homework Details

  • Module: JS
  • Week: 1

Notes

  • What did you find easy?

  • What did you find hard?

  • What do you still not understand?
    Magic Ball

  • Any other notes?

Comment on lines 90 to 91
let answer = shakeBall();
console.log(answer);
Copy link

@Mpanasetckiy Mpanasetckiy Feb 24, 2023

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

"Very doubtful.",
];

console.log("The ball has shaken!");
Copy link

@Mpanasetckiy Mpanasetckiy Feb 24, 2023

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 (
Copy link

@Mpanasetckiy Mpanasetckiy Feb 24, 2023

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 = [
Copy link

@Mpanasetckiy Mpanasetckiy Feb 24, 2023

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]

}

console.log(shakeBall());

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;
Copy link

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));
Copy link

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);
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants