jonasschmedtmann / ultimate-react-course

Starter files, final projects, and FAQ for my Ultimate React course
3.25k stars 1.99k forks source link

Bug in The WildOasis Project #76

Open arnold-zhang-jlu opened 4 months ago

arnold-zhang-jlu commented 4 months ago

image Discount Validation has some problems

yonathandevpro commented 2 months ago

In case, anybody is stuck on this problem, The problem arised because both the type of VALUES and GETVALUES() is a string. When you compare two strings, Javascript compares them lexicographically, basically treating the numbers as strings.

For example, when it compares 100 and 90, it first compares the first digits: 1 and 9. Since 9 is greater, it assumes 90 is greater than 100. So, to correct that, put both VALUES AND GETVALUES as arguments in Number(). e.g. Number(values)..

This will ensure correct comparison.

jakhongir20 commented 2 months ago

Nice job, @yonathandevpro 👍🏻