please help me with my code the step 6 and 7 and 8 what am i doing wrong? why doesn’t it pass?
Please post your actual code instead of a screenshot. Also, please post a link to the Step. Also, please talk about what specifically in the instructions or error message is confusing and how.
const checkButton = document.getElementById('check-btn');
checkButton.addEventListener("click", () => {
const input = document.getElementById('text-input').value;
if (!input) {
alert("Please input a value");
return;
}
const result = document.getElementById('result')
// check A is a palindrome
if (input === "A") {
result.textContent = "A is a palindrome";
}
// check eye is a palindrome
else if (input === "eye") {
result.textContent = '"eye is a palindrome"';
}
// check _eye is a palindrome
else if (input ==="_eye") {
result.textContent = "_eye is a palindrome";
}
// check race car is a palindrome
else if (input === "race car") {
result.textContent = "race car is a palindrome";
}
});
this is my code and i am trying to solve these steps 6 7 and 8. My problem is step 5 passes but 6, 7 and 8 doesn’t . i tried putting ’ ’ in step 6 but it still doesn’t pass and tried adding template literal also like ${input}
. thank you for your advice.
Step 5. When the #text-input
element only contains the letter A
and the #check-btn
element is clicked, the #result
element should contain the text "A is a palindrome"
step 6. When the #text-input
element contains the text eye
and the #check-btn
element is clicked, the #result
element should contain the text "eye is a palindrome"
step 7. When the #text-input
element contains the text _eye
and the #check-btn
element is clicked, the #result
element should contain the text "_eye is a palindrome"
step 8. When the #text-input
element contains the text race car
and the #check-btn
element is clicked, the #result
element should contain the text "race car is a palindrome"
when i input eye,the result is “eye is a palindrome” but it still doesn’t pass. as shown in the screenshot.
You should not hard code the answers. You need to write a function that checks any string.
thank you for answering. i would do that now.
Mode edit: code removed
Thank you Jeremy
FYI, I edited your post to remove the solution code. (Please avoid posting solution code on the forum unless there is a question that is being asked about it)
Okay i will remember that, thanks
Thank you so much for the solution, It helped me.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.