FCC cash register

Hi All,

I’m working through the cash register app at the moment.
I’m having difficult ticking off the criteria from the test.

I’m trying to complete the alert section. I cannot complete it despite believing I have hit all of the criteria.

When price is 20 and the value in the #cash element is 10 , an alert should appear with the text "Customer does not have enough money to purchase the item" .

In my test, price is 20, the value in cash input is 10 and the alert triggers. But doesn’t pass the test.

Please see code pen. Forgive the messy code.

I should add how to use the features so far(there are some bugs to be fixed).

Whilst on transactions page, add various item prices by typing any number and pressing next ‘>’.

Press ‘<’ to go back to previous entries. Type new number and hit sale to change entry.

Press ‘cid’ to change to cid page.

Press ‘<’ and ‘>’ to change between denominations.

Type new number and hit sale to enter it as the new amount of that denomination.

Press trns to go back to transactions.

Once happy with transactions, with an empty entry screen, press sale to go to cash in screen.

The cash in screen works the same as the trns screen. Alerts will work on this screen if cash is less than price or cash is the same as price.

you need to have a program that works as described by the user stories, otherwise it’s not going to pass

you are missing cid and price as global values, and have the button to click.

script goes at the end of the body element, defer doesn’t work in the fcc editor

cid must be declared with let, the tests reassign it

this is the behaviour that is tested, and is required by the user stories:

function test () {
    price = 20
   // cid = [["PENNY", 0.5], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]
    document.querySelector('#cash').value = '10'
    document.querySelector('#purchase-btn').click()

}

test()

your app doesn’t allow this at all.

I don’t understand.

I do have price as a global value. Admittedly, it is further down the page and not well organised.
I have changed cid to ‘let’.
I have changed the script tag. Stupidly, I have already made this mistake once before.

I have also gotten rid of the formatting of #cash.value to get rid of ‘$’ and any decimals to better match the test - #cash element is 10

For some reason I’m unable to upload a photo of my debugging but when testing the value of price and cash before and after inputting values, it updates correctly:

console.log(price, document.querySelector(‘#cash’).value)
20 ‘10’

The alert is also triggering correctly.

Is it because I haven’t yet finished the cid array display requirement for the tests?

I would really discourage negative self-talk like this. Programming is hard and we all make mistakes, sometimes the same mistake many times. Go easy on yourself, it’s not stupid, this is just what it’s like to learn.

You are on freeCodeCamp pushing yourself to learn computer programming yourself, that proves that you’re smart and hard working.

"Students that reported using positive self-talk exclusively during those 30 seconds were able to hold their balance a full second longer than those who used exclusively negative or had a mix of both negative and positive self-talk.

The positive self-talk resulted in an average balance time of 9.29 seconds, while the other two groups averaged out at 8.29 seconds. This is more than an 11% increase in performance"

https://coachingtoolbox.net/mental-toughness/coaching-basketball-the-truth-about-positive-self-talk.html

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.