Answer the question
In order to leave comments, you need to log in
How to select last letter of text using js loop?
How do I select (iterate through) the last letter of a text using a loop?
There is such a structure:
Answer the question
In order to leave comments, you need to log in
Do you need a cycle? You can do this:
But if you need a loop, then for in is not very suitable in my opinion.
let endChar = $("h1").text().substr(-1);
let text = $("h1").text();
for(let i = 0; i < text.length; i++){
if (i == text.length - 1) console.log(text[i]);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question