0

I wanna know why is greater than is responding as less than? or I myself don't know? | confused :-(

let msgs = { msg1: "You're eligible to join our community", msg2: "Sorry, you're not eligible to join our community", }; let age = 18; let age2 = 20; if (age > age2) { document.write(msgs.msg1); } else { document.write(msgs.msg2); }

19th Mar 2023, 8:29 AM
Dinesh Pal :)
Dinesh Pal :) - avatar
3 Antworten
+ 3
I am confused bro what's your question, your question is incomplete what you want to say? But I explain to you what in this code:- if age>age2 That means 18>20 and you want to print msg1 "You're eligible to join our community" and if the condition false then msg2 print that's it. Hope you understand what I mean.
19th Mar 2023, 9:04 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 2
// If you are confused in greater than and lesser than signs, you have to work on that yourself, I was too in starting but the solution is to make your code as self-explanatory as possible, not for someone else to read but yourself. That is the key. I have made your code a bit more readable and working. Enjoy. Ask more questions if you want to. let msgs = { eligible: "You're eligible to join our community", notEligible: "Sorry, you're not eligible to join our community", }; let ageRestriction = 18; let candidateAge = 20; if (ageRestriction < candidateAge) { document.write(msgs.eligible); } else { document.write(msgs.notEligible); };
25th Mar 2023, 9:45 AM
Harman Maan
Harman Maan - avatar
+ 2
Harman Maan Shukriya bhai :-)
26th Mar 2023, 12:44 AM
Dinesh Pal :)
Dinesh Pal :) - avatar