8 kyu

A Needle in the Haystack

16,879 of 183,673andrewMacmurray

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 Trained249171
Total Skips16767
Total Code Submissions395240
Total Times Completed183673
JavaScript Completions76953
C# Completions9015
Java Completions16879
CoffeeScript Completions79
Python Completions66530
Elixir Completions581
PHP Completions4584
Ruby Completions4067
C Completions2075
TypeScript Completions3193
Haskell Completions688
Racket Completions53
COBOL Completions13
Scala Completions140
C++ Completions2708
Total Stars1299
% of votes with a positive feedback rating91% of 12075
Total "Very Satisfied" Votes10028
Total "Somewhat Satisfied" Votes1812
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