Question

write a Node.js function searchString() that receives three parameters: a positive integer in the range of...

write a Node.js function searchString() that receives three parameters: a positive integer in the range of 1 to 20, a target string of characters of that length, and a single character. It then checks whether or not the target string contains the given character. If it does, this function returns the index of the target string where the character is first found. Otherwise, it returns -1.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

function searchString(a,data,b) {
    for(var i = 0; i < a; i++)
    {
       if(data[i].indexOf(b) != -1)
        {
           return data[i].indexOf('s');
        }
    }
    return -1;
}

Add a comment
Know the answer?
Add Answer to:
write a Node.js function searchString() that receives three parameters: a positive integer in the range of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT