Function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Function

what this command do arr.indexof(x)

30th Jul 2018, 3:26 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
9 Answers
+ 1
9 is not present in the array. (index <0)? 1: 0; is a ternary operator. Some people consider it as shorthand if/else. What the code is saying if (index < 0){ result = 1; }else{ result = 0; }
30th Jul 2018, 3:40 PM
Akib
Akib - avatar
0
finds the index value of the argument in an array.
30th Jul 2018, 3:31 PM
Akib
Akib - avatar
0
I don't understand look this code
30th Jul 2018, 3:32 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
What is the output of this code? var arr = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8]; var index = arr.indexOf(9); var result = index < 0 ? 1 : 0; console.log(result);
30th Jul 2018, 3:32 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
thanks
30th Jul 2018, 3:40 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
a[I] showing the value of the index a.indexof(x) showing the index of the value
30th Jul 2018, 3:41 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
thank you so much for help
30th Jul 2018, 3:42 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
😂😂glad to help👍.
30th Jul 2018, 3:43 PM
Akib
Akib - avatar