8 kyu

A Needle in the Haystack

75,729 of 179,741andrewMacmurray

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 Trained243821
Total Skips16432
Total Code Submissions387499
Total Times Completed179741
JavaScript Completions75729
C# Completions8847
Java Completions16559
CoffeeScript Completions78
Python Completions64722
Elixir Completions578
PHP Completions4498
Ruby Completions4040
C Completions2031
TypeScript Completions3090
Haskell Completions665
Racket Completions52
COBOL Completions13
Scala Completions138
C++ Completions2470
Total Stars1275
% of votes with a positive feedback rating91% of 11946
Total "Very Satisfied" Votes9914
Total "Somewhat Satisfied" Votes1798
Total "Not Satisfied" Votes234
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