1
Personal I need to return 2 random strings 'John' or 'Mary' to implement in the following table.. I already did a Google search, but I could only return the WHOLE numbers and not the strings.. Thank you! Follows the code...
for(i = 1; i<=30; i++) {
var maximo = 5;
var a = parseInt(Math.random()*maximo+1);
var b = parseInt(Math.random()*maximo+1);
var name = // <= aqui vem a logica dos nomes!
table += '<tr><td>'+i+'</td>';
table += '<td>'+a+'</td>';
table += '<td>'+b+'</td>';
table += '<td>'+name+'</td>';
table += '<td>1</td>';
table += '<td>1</td>';
table += '<td>1</td></tr>';
}
Generates a number between 1 and 2. If give one is John, 2 is Mary.
– Oralista de Sistemas
Good alternative, I will test here...
– wDrik
If it becomes easier even or odd, you can check if any variable is even as follows. Suppose a number x, then x is even if
(x % 2) == 0
or odd if(x % 2) == 1
.– Oralista de Sistemas