I filled out the matrix according to the data and according to the stipulated condition … but no result appears to me, which means that the matrix is empty or something similar.
function ser(h) { var dataX = []; var dataY = []; for (i = 0; i < h.length; i++) { if(h.charAt(i) == '0'){ //---- 1 ----- dataX.push(i); dataY.push(30); //---- 2 ----- dataX.push(i); dataY.push(10); //---- 3 ----- dataX.push(i+5); dataY.push(10); //---- 4 ----- dataX.push(i+5); dataY.push(30); //----- dataX.push(i+10); dataY.push(30); } } console.log(dataY[0]); } ser(00); // test
Advertisement
Answer
Maybe you want to pass it as a string:
ser("00")
This expression returns undefined
:
var h = 00 console.log(h.length)
and also this will always evaluate to false:
h.charAt(i) == '0'
since charAt() is a string method.