
JavaScript Scenario Task:
1)Shopping Discount System: In online shopping websites, discounts are applied based on the purchase amount. Rules Amount ≥ 5000 → 20% discount Amount ≥ 2000 → 10% discount Otherwise → No discount Members get an extra 10% discount let Amount = 5000 ; let isMember = true ; let discount = 0 ; if ( Amount >= 5000 ){ discount = 0.20 ; } else if ( Amount >= 2000 ){ discount = . 10 ; } if ( isMember ){ discount = discount + . 10 ; } let finalPrice = Amount - ( Amount * discount ); console . log ( " The final Price is " + finalPrice ); O / P : The final Price is 3500 2) Login Access Check: Username = "admin" Password = "1234" User is not blocked let username = " admin " ; let password = " 1234 " ; let isBlocked = true ; if ( username == " admin " ){ if ( password == " 1234 " ){ if ( ! isBlocked ){ console . log ( " User verified " ); } else { console . log ( " User Blocked " ); } } else { console . log ( " Not a valid password " ) } } else { console . log ( " Not a valid username " ) } O / P
Continue reading on Dev.to Tutorial
Opens in a new tab


