| [ Web Proxy ] |
| Viewing: https://raw.githubusercontent.com/anasmak04/Problem-solving-with-JavaScript/master/problem-35.js | [Back] [Original] |
// "found the needle at position " plus the index it found the needle, so:
function findNeedle(haystack) {
let index = haystack.indexOf("needle")
for(let i of haystack){
if(i == "needle")
return `found the needle at position ${index}`
}
}
| Web Proxy Viewer | New URL | Original Page |