The assignment only asked for one parameter within the function (day). When i used the one parameter the code ran correctly and printed true. To help myself learn i try little things out to see if i can spot anymore logic and improve my basic skills.
So i added a new parameter called time. Both parameters are true so should print “true” but for some reason now i have entered a time parameter it always returns as false.
Can anyone take a look? Im sure its simple and a silly question to many of you, but its eating me up, i cant see for the life of me why this would be false.
sorry i dont understand what you mean? my if statement is asking
if day===‘wednesday’ + time===‘midday’
return true
I dont understand what you mean by 'you resolved the + operator (with argument values of parameter).
Can you please explain what you mean by" with argument values of parameter", this is not a course question so dont worry about giving away answers, this is an extra im just trying. thank you.
sorry if this is so basic but im very new to JS, about as new as it gets actually so any help is great. i just need answer for JS for dummies answers.
day===‘wednesday’ && time===‘midday’
or
day===‘wednesday’, time===‘midday’
so what should i use a , or && or +? All i want to ask is if both parameters are true, and if so print true ese print false.
How would you write the code? im realy lost. When asking just (day) i get a true but when asking both it always comes back flase no matter how i write the code.
which do you think it is? JS has excellent documentation on all these operators. So if you are unsure of which operator to use, that is the place to go
what is worrying me is that here you use wednesday (latest reply) and not Wednesday (screenshot), given string comparison is case sensitive, its important to pay attention to this kind of details in programming, particular if you are receiving help
because now i have two factors which might be causing problems (use of incorrect operator or case sensitivity)
and given your latest reply only contains a small snippet of code, i am unable to verify the whole thing. A mistake might be really small, and not in the snippet you provided
Just got it, it was a case of using simple commas! Trial and error gets their eventually. Now i can see the logic as to why too. Its always something simple that you just cant see, i walked away had a cofee and thought of it straight away. It is odd how it seems so obvious after the fact, before i could not work it out for the life of me.
I do understand the operator, the && means both have parameters must be true. i should of spotted that. I thought i tested it but i was only changing the time and seeing what prints. The day was always okay before so i never touched it.
The link said “The comma operator chains multiple expressions together, and the result of the operation is the value of the last operand…”
That explained what i was about to ask you. thanks for pointing that out. i would be misusing the , as a shorthand for &&.
I will go through the whole functions lesson again tommorow, the operators will become second nature in time just as basic maths operators.
Thats what i meant, i said the && operator means both “parameters” must be true. meaning both conditions of the parameters must be true. is that correct or am i using incorrect terminology?