The discountRate:0 will return discountRate 10 because of the if statement ?
2023-12-23 21:21:55
9
gabrielunplugged :
The code incorrectly assigns a default discount rate even when the discount is intentionally set to 0%.
2023-12-23 23:25:11
3
Husu :
if (!config?.discountRate) {}
2023-12-24 10:39:57
3
manteeray :
falsy check on config.discountRate will set discount rate to 10% when you pass in {discountRate: 0}, can replace if stmt to !config.hasOwnProperty("discountRate") or config.discountRate === undefined
2023-12-23 23:54:04
1
Renszit :
if (config.discountRate === undefined) should fix it. How you have it now, it checks for any falsy value, 0 also being a falsy
2023-12-24 09:41:31
0
Yikes! :
I don't know JS but looks like last usage passes in empty object so it will fail at accessing member of the object in if statement
2023-12-29 19:36:11
0
SymnSez :
Truthy-falsey 0
2023-12-30 10:29:13
0
Oz da Dev :
if(!config?.discountRate)
2024-01-07 19:20:51
0
Lego Charmander :
its checking for falsely instead of undefined.
2024-01-17 02:22:41
0
To see more videos from user @itstundealao, please go to the Tikwm
homepage.