0
exercice of array
Hello world somebody could explain me why the result of this exercice is 6 ? thank you https://www.sololearn.com/Play/JavaScript What is the output of this code? var arr = new Array(3, 6, 8); document.write(arr[1]);
11 Respostas
+ 4
.... -_- stack up stack up
array pattern : [3,6,8]
stack pattern
_______
8 floor 2
6 floor 1
3 floor 0
_______
Get arr[1] value = Get the value that Stack at floor 1
Get it?
+ 1
new Array() same thing to [ ]
so
new Array(3,6,8) equilvalent to [3,6,8]
(just try to think that array is object from "new Array()" )
__________________________________
Ok now more
with this function "new Array()" you can define empty array{
var a = new Array(4);//If you paste only one argument and that argument is number
alert(a.length);
}
what is it for then?:
{
var a = new Array(4);
for(i=0;i<a.length;i++){
//some code here
}
}
+ 1
:/...
Then Do you know what stack is?
+ 1
the answer is 6
0
thank you guys
but sorry i still didnt understand why the result is 6 ?
https://www.sololearn.com/Play/JavaScript
What is the output of this code?
var arr = new Array(3, 6, 8);
document.write(arr[1]);
0
:/...
Then Do you know what stack is? = I think it is a bracket in comment isnt?
0
Fill in the blanks to output only the even numbers in the array.
var arr = arrayOf(1, 2, 5, 6, 2, 8, 9)
for(x in arr) {
if
(x % 2 != 0) {
}
println(
)
}
any help..?
0
use continue
after
if(x%2!=0)
{
continue
}
println(x)
0
fun main(args: Array<String>) {
val arr = arrayOf(42, 3, 10, 4, 6, 1)
val res = arr.filter({ it > 5 })
println(res)
}
- 1
The counting in array starts from 0 1 2 3 ....
So are[1] would be 6
- 1
thank you so much i get it !!
great your explanation
... -_- stack up stack up
array pattern : [3,6,8]
stack pattern
_______
8 floor 2
6 floor 1
3 floor 0
_______
Get arr[1] value = Get that Stack at floor 1
Get it?