Answers for "indexOf() usages"

0

indexOf() usages

function find(needle, haystack) {
    var results = [];
    var idx = haystack.indexOf(needle);
    while (idx != -1) {
        results.push(idx);
        idx = haystack.indexOf(needle, idx + 1);
    }
    return results;
}
Code language: JavaScript (javascript)
Posted by: Guest on December-23-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language