I am trying to make the function give the paragraph the text.... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

I am trying to make the function give the paragraph the text....

...only if the last 2 letters of the a string are the same as the first 2 letters of the input value. I can't make it work. Help https://code.sololearn.com/WWjpi4z61zwH/?ref=app

7th May 2020, 1:49 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
5 Answers
+ 3
change event listener from "change" to "keyup"
7th May 2020, 2:15 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 2
Event for that is 'input' not 'change' Change is for radio buttons, checkboxes or dropdowns.
7th May 2020, 2:21 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 2
Wait, I just checked again and it works with change too. I think my mistake was, that I begun the word with Cd and not cd
7th May 2020, 2:45 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 1
but what are you trying to achive, given the string is "abcd" and if we type any string it matches the last two characters i.e. "cd" then only the <p> tag will get the text, but it is its actual implementation?
7th May 2020, 2:25 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 1
Sami Khan It seems to work with the keyup event, but I want the event to run only when I press enter in the input, that is why i used change event.
7th May 2020, 2:42 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar