Skip to content
Advertisement

Finding a ‘hello’ word in a different string, which it has ‘hello’ in it(additional)

Finding a ‘hello’ word in a different string, which it has ‘hello’ in it I should find a ‘hello’ word in a string, which I gave it from input too .I wrote this code by looking at the answer that someone gave to the below link’s question.

JavaScript

but I don’t want to use a def to solve the problem.

JavaScript

for hello string it works correct. also for pnnepelqomhhheollvlo. but when I give it ahhellllloou it doesn’t work. I can’t see where the bug is.

Advertisement

Answer

Your code is not the same. The return statement needs to be accounted for by breaking the loop

JavaScript

Note that a loop isn’t needed

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement