A ticket costs 25 bitcoins, how much change can you give to a customer without an initial checkout?
-
A task. A movie ticket costs 25 conventional units, initially there is no money at the box office. Clients come one by one and they need to sell tickets giving change. If change is return YES, if not then NO. Question, am I dumb or is the task broken?
The task itself: https://www.codewars.com/kata/vasya-clerk/javascript < / a>
My solution to the problem:
peopleInLine = [ 25, 25, 25, 25, 50, 100, 50 ]; function tickets(peopleInLine){ ticket = 0; for (i = 0; i < peopleInLine.length; i++){ peopleInLine[i] == 25 ? ticket += 25 : ticket -= peopleInLine[i] - 25; } if (ticket < 0){ return "NO"; } else { return "YES"; } }
Error on the code: "YES was expected, the code returned NO". WHERE IS CARL ERROR?
[25, 25, 25, 25, 50, 100, 50]JavaScript Anonymous, Dec 10, 2019 -
you always add the same number to your balance, even when the client gives more and you give him changeGenevieve Rodriguez
1 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!