given the array below ,please complete the expression to be alerted with "apple"? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

given the array below ,please complete the expression to be alerted with "apple"?

var frutis=new Array ("pear","orange ","apple","grapefruti"); alert (frutis---);

16th Oct 2016, 8:56 AM
M.Muthu
M.Muthu - avatar
7 Answers
+ 4
var fruits = new Array("pear", "orange", "apple", "grapefruit"); alert(fruits [2] );
23rd Mar 2018, 1:46 PM
Mahnoor Shahzad
Mahnoor Shahzad - avatar
+ 3
alert (fruitis [2])
16th Oct 2016, 9:07 AM
Jayce Rushton
+ 1
[2] Trust me..
2nd Oct 2019, 9:50 AM
Zenande Zilwa
Zenande Zilwa - avatar
+ 1
var fruits = new Array("pear", "orange", "apple", "grapefruit"); alert(fruits [2] ); This is the output
28th Jun 2020, 6:58 AM
Faith Mundi
Faith Mundi - avatar
+ 1
can anyone explain why 2?
6th Dec 2020, 7:51 PM
Jeina
0
2 because indices start from 0 and when you count it is on the second index
31st Dec 2020, 5:00 AM
Murenzi Confiance Tracy
 Murenzi Confiance Tracy - avatar
0
var fruits = new Array("pear", "orange", "apple", "grapefruit"); alert(fruits [2] );
7th Sep 2022, 12:36 PM
LIPSA BEHERA