Syntax Error Java Script code restaurant bill

0

I am running this code and I really do not find the error ... I would like to know more points of view or suggestions so that the execution of the code results without error. Thank you in advance!:)

In the following image, tax is the tax and bill is my total expense (without added tax), adding tax to bill should get the final total and divide it by 5 (necessarily), so the result of this would close my test . However, to raise it in this way still tells me that there is an error: /

  • Add parseInt to keep the value of my variables as integers. I have the doubt of whether it is correct or should I use another function?
  • This is the answer thrown by the lms platform where I am doing the test. Uncaught SyntaxError: missing) after argument list
  • RESTAURANTBILL () SHOULD RETURN $ 11, FOR 50 expected 55 to deeply equal '$ 11'

    SHOULD RETURN $ 22, FOR 100 expected 110 to deeply equal '$ 22'

    SHOULD RETURN $ 18.7, FOR 85 expected 93.5 to deeply equal '$ 18.7'

        
    asked by Winnie Le Po 16.08.2018 в 09:58
    source

    1 answer

    4

    I think the problem, quite typical when it is being debugged, comes from the fact that on the one hand you show information in the console, and on the other, you return a different value. So, with console.log() samples total/5 , which according to your question seems to be the correct answer, while you are returning total (and not total / 5 ), which It would explain that tests will not happen.

    I would change the code to:

    var tax = bill * .1;
    var total = parseInt( bill + tax ) / 5;
    
    console.log('$', total);
    return total;
    

    ... returning the same as samples.

        
    answered by 16.08.2018 / 11:06
    source