8 kyu

A Needle in the Haystack

4,088 of 187,200andrewMacmurray

Description:

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:

Example(Input --> Output)

["hay", "junk", "hay", "hay", "moreJunk", "needle", "randomJunk"] --> "found the needle at position 5" 

Note: In COBOL, it should return "found the needle at position 6"

Arrays
Fundamentals

Stats:

CreatedDec 8, 2015
PublishedDec 9, 2015
Warriors Trained253919
Total Skips17091
Total Code Submissions401938
Total Times Completed187200
JavaScript Completions78008
C# Completions9170
Java Completions17164
CoffeeScript Completions79
Python Completions68234
Elixir Completions583
PHP Completions4638
Ruby Completions4088
C Completions2123
TypeScript Completions3303
Haskell Completions697
Racket Completions55
COBOL Completions13
Scala Completions144
C++ Completions2885
Total Stars1324
% of votes with a positive feedback rating91% of 12170
Total "Very Satisfied" Votes10107
Total "Somewhat Satisfied" Votes1828
Total "Not Satisfied" Votes235
Ad
Contributors
  • andrewMacmurray Avatar
  • jhoffner Avatar
  • cris Avatar
  • GiacomoSorbi Avatar
  • NaMe613 Avatar
  • 1b8 Avatar
  • gttotev Avatar
  • Shivo Avatar
  • kazk Avatar
  • JohanWiltink Avatar
  • asedov Avatar
  • lilsweetcaligula Avatar
  • Blind4Basics Avatar
  • MaikelNabil Avatar
  • mitron6 Avatar
  • FArekkusu Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
  • user8436785 Avatar
  • ejini战神 Avatar
  • akar-0 Avatar
  • dfhwze Avatar
  • Just4FunCoder Avatar
  • o2001 Avatar
  • KayleighWasTaken Avatar
Ad