I am stuck on this challenge help me

I have attached event handler to the noOfPeople input and in the event handler I call another function which is called validate field which calls validator on each input and from the validators whcih the validateField calls in the validatorSelectTip function the this keyword refers to undefined. why is that because I have attached the bind keyword when I call the event handler on the "noOfPeople" input. this is the live-site url: https://aemrobe.github.io/Tip-calculator-app-main/ this is the git repo: https://github.com/aemrobe/Tip-calculator-app-main.git
GitHub
GitHub - aemrobe/Tip-calculator-app-main
Contribute to aemrobe/Tip-calculator-app-main development by creating an account on GitHub.
11 Replies
ἔρως
ἔρως14mo ago
you are trying to add event listeneds to strings remove the .value from the end it won fix everything, but that is the first huge blinder
Aemro11
Aemro11OP14mo ago
which one is string noOfPeople isnot a string
ἔρως
ἔρως14mo ago
yes it is
ἔρως
ἔρως14mo ago
.value means "the value in the element" which is a string
Aemro11
Aemro11OP14mo ago
I stopped doing them. I have changed it and it is working. the error was I should use the call keyword when I call the valildators in the validateField function.
ἔρως
ἔρως14mo ago
🤔
Aemro11
Aemro11OP14mo ago
ἔρως
ἔρως14mo ago
i will later not gonna lie, your solution is exactly the type of thing you should never do but, it's just for a challenge, and the code sorta kinda almost works, which is fine
Aemro11
Aemro11OP14mo ago
I have learned oob and I put it to practice then. What is the best practice for it. Would you suggest me.
ἔρως
ἔρως14mo ago
well, the big bad one is that you are using global variables to a class that has a constructor and then, you are re-implementing things that are already implemented into html and javascript, but you cant use them because you didnt use the right attributes and elements you have a button that has javascript that manually clears the inputs, instead of using a form with a <button type="reset"> to do everything for you you can even listen to the reser event in the form
Want results from more Discord servers?
Add your server