<<<<<<< HEAD Code Wars - Brett Crafton

You only need one - Beginner

Question

Can you find the needle in the haystack? Write a function findNeedle() that takes an array full of junk but containing one "needle" After your function finds the needle it should return a message (as a string) that says: "found the needle at position " plus the index it found the needle, so:

findNeedle(['hay', 'junk', 'hay', 'hay', 'moreJunk', 'needle', 'randomJunk'])

Solution by -

My Solution


	function findNeedle(haystack) {
		let position = haystack.indexOf('needle')
		return "found the needle at position " + position
		}
				

Try it yourself - CodeWars

======= Code Wars - Brett Crafton

You only need one - Beginner

Question

Can you find the needle in the haystack? Write a function findNeedle() that takes an array full of junk but containing one "needle" After your function finds the needle it should return a message (as a string) that says: "found the needle at position " plus the index it found the needle, so:

findNeedle(['hay', 'junk', 'hay', 'hay', 'moreJunk', 'needle', 'randomJunk'])

Solution by -

My Solution


	function findNeedle(haystack) {
		let position = haystack.indexOf('needle')
		return "found the needle at position " + position
		}
				

Try it yourself - CodeWars

>>>>>>> 0e614172debaa009c8d31330edbeb3b765b59c39