DEV Community

Cover image for Solving the Cash Register challenge in Free Code Camp

Solving the Cash Register challenge in Free Code Camp

ainaperez on July 28, 2021

Welcome to my first post ever in Dev! If you are also taking FreeCodeCamp's Javascript Algorithms and Data Structures certification, this post may...
Collapse
 
herculeskan profile image
Carlos E. Lara

Thank u so much <3

Collapse
 
codenameshy profile image
codeName-Shy

THANKS

Collapse
 
mayuraalahakoon profile image
mayura_andrew
if(cidSum < originalDiff || sumResult < originalDiff){
    objectReturn.status = 'INSUFFICIENT_FUNDS';
    }else if(cidSum == originalDiff){
      objectReturn.status = 'CLOSED';
      objectReturn.change = cid.reverse(); // add .reverse again
    }else{
Enter fullscreen mode Exit fullscreen mode
Collapse
 
martaev85 profile image
MartaEV85

I still don't understand how to solve it but at least now I have something plain and understandable to read and try to figure it out :)

Collapse
 
ainaperez profile image
ainaperez

Don't give up 💪
In the end, what I learned most completing this project is to carefully read the problem and try to break it into smaller tasks that you can start working on separately. Hopefully, you will get it soon!😊

Collapse
 
howhowtocook profile image
howhowtocook
while(difference.toFixed(2)>=arrCurrency[i][1] && bill>=1){
        difference -= arrCurrency[i][1];
        returnMoney += arrCurrency[i][1];
        bill--;
Enter fullscreen mode Exit fullscreen mode

i have a question with this code, what if difference = 6, while we have one 0.25 and six 1left, when the code run for 0.25, (difference.toFixed(2)>=arrCurrency[i][1] && bill>=1)=true, so we will add 0.25to return money, but after that, we cannot make 0.35 out of 6*0.1,

Collapse
 
colonelxy profile image
Harold Oliver 🛡️

Just amazing, awesome storytelling!

Collapse
 
colonelxy profile image
Harold Oliver 🛡️

When i redo these steps, the last test fails, 'CLOSED' doesn't resolve.

Collapse
 
federicocapucci profile image
federicocapucci

for the 'CLOSED' case, i figured after doing a console.log(), that the change array was being provided in the wrong order, so I just appended .reverse to the case, and it worked.

Collapse
 
sebzg profile image
Seb Z.G

A beautiful story

Collapse
 
mayuraalahakoon profile image
mayura_andrew

Thank you for your brief explanation

Collapse
 
muhammai2000_94 profile image
muhammai2000

Thank you for sharing your solution in this step-by-step format! Very beneficial!

Collapse
 
anabeatrizzz profile image
Ana Beatriz

GitHub link not working :(

Collapse
 
federicocapucci profile image
federicocapucci • Edited

Here's the code, I just copied/pasted all parts, and made a small change on the closed case.

codeshare.io/X8oNE8