#need help with javacsript
37 messages · Page 1 of 1 (latest)
Brawnm
Try a console.log(day) in line 14 and see what comes to the day
Use let or const
idk, it could be because of the order or those checks
for example I can't really understand why you have to check if it's saturday or sunday, as this sets the price 10 like that else block.
okay, but why do you need to check if the day is sunday or saturday and then set the price 10, when you could get the same price in else block?
You could getrid of that first if then?
The thing is its the museum ticket generator
If you go on weekends the ticket price is 10
If you go on working days the tickets is 5
But if you go on friday and have a discount code then price is 0
Its 10
@uncut locust
@long onyx
For safety reasons we do not allow file and video attachments.
You can share your code using triple backticks like this:
```
YOUR CODE
```
For longer scripts use Hastebin or GitHub Gists and share the link here
- 20230113_092229.mp4
Did you do the console log?
Cus if you log the input of what day it is you can see whats wrong
Using var here is weird ye, but also... Maybe check if your dropdown is actually not equal by the case sensitivity of your program? I aint exactly sure what else could cause it
What is actually your problem you didn't really explain?
Log all your variables and your outputs and just see what isn't what it's supposed to be
e,g add
//before the if statement
console.log(day);
console.log(age);
console.log(discount);
//after thje if statement
console.log(price);
Make sure everything is exactly as you expect it to be, it doesn't just skip if statements by accident so if it's not triggering it means one of them must be wrong
@green forge
So my problem is my if statement does not run even though I have all the conditions true in if statement but it jumps into if else statement
Then your variables probably aren't returning what you expect, log them and check