You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.
The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[
^]
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html[
^]
https://www.jetbrains.com/idea/help/debugging-your-first-java-application.html[
^]
If this code
function randomArray (z) {
var realArrayLength = z.length + 1 ;
var random_0toLength = Math.round(Math.floor()*realArrayLength);
for (var x =0; x <= realArrayLength ; x++){
if (random_0toLength === x) {
var y = z [x];
}}
return y ;
};
is supposed to do what I think, it is overly complicated, heavily bugged and not even near what it is intended to do.
Read documentation about
Math.round
and
Math.floor
Advice: stop doing random cha,ges in the code and use the debugger to understand what the code is doing.