Total members 11895 |It is currently Mon Dec 30, 2024 6:55 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





I was wondering if any one knew how to make my code on math questions so that it would stop after a certain amount of time. For instance the user keeps on having questions asked until 30 seconds pass by.
Code:
//this is my function for random numbers//
var random = function(least,most){
return Math.floor(Math.random()*most + least);
};
//end of function//
var c;
var score=0;
confirm("New game");
console.log("new game");
var added = "";
for(c=1;c<=10;c++){
var num1=random(1,10);
var num2=random(1,10);
if(parseInt(prompt(added +"What is"+num1+"+"+num2+"?"))===(num1+num2)){
   score++;
   added="corect. You have "+score+" points ";
}
else{
   added="wrong You have "+score+" points ";
}


**Note this is only in JS




Author:
Newbie
User avatar Posts: 6
Have thanks: 0 time

You can use setTimeout function to sleep the thread for some time :

i used it in this example
javascript-examples/image-slide-show-t7775.html

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

I see that but how can you use the setTimeout function to make something stop after a certain amount of time?


Author:
Newbie
User avatar Posts: 6
Have thanks: 0 time

yes
U setTimeout it is like sleep function
setTimeout("imageSlider()", 2000);

u put the function u want to run and with time (For how long)

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

For this message the author DrRakha has received gratitude : billybobjoe855
Post new topic Reply to topic  [ 4 posts ] 

  Related Posts  to : Java script time parameter
 Passing arrays as function parameter in java     -  
 need help with java script in a pdf     -  
 How can I call a C program in a Shell Script from Java     -  
 How to create a file in java script using FireFox     -  
 Dynamic Frame-sets with java script protocols     -  
 How to get system time in java     -  
 Default Expire time for Session JAVA     -  
 Java Websphere Portal Developer Full-time position in IL     -  
 get url parameter     -  
 using parameter with name query     -  



Topic Tags

JavaScript Time






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com