+ 3
Could you help me on javaScript please
Could you translate that to code -> There is this number(random) in list var list=[]; function make(){ var random=Math.ceil(Math.random()*10); check(random) } function check(random){ if(There is this number(random) in list){make();} else{ write(random) list.push(random) }} function write(random){ alert(random); } setInterval(function(){make()},1000)
4 ответов
+ 11
@Serhat Merak wrote:
>> Maz, can you help me in my other question? <<
Maybe.
So, you have an empty array and three "main" functions, the make( ) is called every 1000ms (1s), that:
There is this number (random) in list
... could be a simple "if" control inside an item of your array, if the number is in your array, that function re-call the make( ) function, otherwise.. alert the random number through the write( ) function and adds a new item in that array.
The code maybe is provided by StackOverflow, it's right (?)
You could translate it in this way:
var list=[];
list[0] = 3;
function check(random){
if(list[0] == random) {
// console.log( ) is just for test
console.log( random );
}
}
As you can see, in the if condition i made a control with an item in the array, you could use a "for loop" for control all items inside your list[ ] array.
This is just my explanation, if i wrote something wrong, let me know. :)
+ 11
Do you mean for your English? I'm not the right person to ask this (i'm very bad in English), but yeah, i can understand you pretty well. ;)
0
that is very reasonable 😀 Thank you maz 😊
But I want to ask that
Can you understand me easily ???
0
Oh thank you 😀 I sometimes(maybe usually) make mistakes 😊😊😊