8 kyu

A Needle in the Haystack

76,865 of 183,396andrewMacmurray

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 Trained248731
Total Skips16746
Total Code Submissions394690
Total Times Completed183396
JavaScript Completions76865
C# Completions9001
Java Completions16859
CoffeeScript Completions79
Python Completions66402
Elixir Completions581
PHP Completions4578
Ruby Completions4064
C Completions2073
TypeScript Completions3189
Haskell Completions687
Racket Completions53
COBOL Completions13
Scala Completions140
C++ Completions2690
Total Stars1297
% of votes with a positive feedback rating91% of 12066
Total "Very Satisfied" Votes10020
Total "Somewhat Satisfied" Votes1811
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