in my function it runs document.write 10 times what i specified

javascript for loop
javascript function
javascript run function 10 times
javascript return function object
function that returns a function javascript
javascript run multiple times
a function can be called multiple times in a single file.
what is a function that returns a function called

when I try to run

 function thing(number) {
  for (i = 1; i < number+1; i++){
      document.write(i + ' ');
  }
}	
var otherthing = prompt("");
thing(otherthing);

as explained by Jaromanda X, data type of number argument on function thing is string not int, float or other number data type. So you need to change it to number first. Something like this :

function thing(number) {
    for (let i = 1; i < Number(number)+1; i++){
        document.write(i + ' ');
    }
}   
var otherthing = prompt("");
thing(otherthing);

Run a function a specified number of times, function foo() { var counter = document.getElementById('counter'); var counterValue = parseInt(counter.value, 10); alert('Run No. Cron utility is an effective way to schedule a routine background job at a specific time and/or day on an on-going basis. Linux Crontab Format. MIN HOUR DOM MON DOW CMD. Example::Scheduling a Job For a Specific Time. The basic usage of cron is to execute a job in a specific time as shown below.

Tell me if this works for you.

function thing(aNumber) { 
  aNumber = Number(aNumber) + 1;
  for (i = 1; i < aNumber; i++){ 
    document.write(i + ' ');

    }
}   
var otherthing = prompt(""); 
thing(otherthing);

Functions :: Eloquent JavaScript, In the following example, makeNoise does not list any parameter names, whereas count++) { result *= base; } return result; }; console.log(power(2, 10)); // → 1024 Every time the function is called, new instances of these bindings are created. The statement defines the binding square and points it at the given function. Interval mode: where Windows Service execute a task at regular intervals after some delay. 2. Daily mode: where the Windows Service will execute a task at specific (certain) time of day. Creating a Windows Service Project. The very first step is to add a new project of type Windows Service as shown below.

Try this you forget to parse it into integer

function thing(number) {
            for (i = 1; i < number+1; i++){
                document.write(i + ' ');
            }
        }   
var otherthing = parseInt(prompt(""));
thing(otherthing);

JavaScript Tutorial: The Basics, 2.1 Example 1: Functions alert() and document.write() 10. JavaScript Built-in Browser Objects: navigator , window , screen , history , location cross-platform JavaScript run-time environment), you can run your JavaScript standalone or Run the script by loading the HTML file into a JavaScript-enabled browser (e.g., One  Run a function a specified number of times. I can use the above code to run a function infinite number of times with an interval of one second. What is the standard way of running a function defined number of times.

Use Number for convert string to number :

for (i = 1; i < Number(number) + 1 ; i++) {

function thing(number) {
  for (i = 1; i < Number(number) +1 ; i++) {
    document.write(i + ' ');
  }
}	

var otherthing = prompt("");
thing(otherthing);

JavaScript: Loops, The For statements are best used when you want to perform a loop a specific document.write("<table border=2 width=50%"); Next example creates a function containing the For statement that counts the The loop will continue to run as long as i is less than, or equal to 10. i will increase by 1 each time the loop runs. I want my script to carry on, just for the call to foo to timeout after 10 seconds. – felipa Feb 17 '13 at 21:26 Write a function handler to do that, for example in every iteration in the function check for a global variable, and change that variable in the signal handler.

[PDF] Sample Exam 3, 1) Write the details of a function that prompts the user for a color and uses what they typed to set the 2) We are given the following function. we loop "size" many times using a loop counter variable "i" [10 pts.] <html>. <head>. <script type="text/javascript"> function greetKitty() Explain how public key encryption works. Given a singly linked list and a key, count number of occurrences of given key in linked list. For example, if given linked list is 1->2->1->2->1->3->1 and given key is 1, then output should be 4. Initialize count as zero. Loop through each element of linked list: a) If element data is equal to the passed number then increment the count.

The Complete Guide to Loops in JavaScript, But… sometimes it's good to write about something just so that these The blue dots are the statements that will run for a predetermined which can be any legal JavaScript statement, a function call, or even an A while loop will iterate for an indefinite number of times until the specified condition (there is  The Operator Invokes the Function. Using the example above, toCelsius refers to the function object, and toCelsius() refers to the function result. Accessing a function without will return the function object instead of the function result.

Functions, The call showMessage() executes the code of the function. Here we will see the message two times. This example clearly demonstrates one of  Dear all, i have a PC (Ms Excel) which run 24 hours a day and 365 days a year without any restart required, i want the Excel to print a page every day at the time of midnight 11pm ("23:00:00") , i am new to macro and below is my simple code which only do the task the first time after i save and open the excel, please advice in detail how to go about if my excel is open all the time and i do

Comments
  • otherthing and therefore number is a string ... so '1' + 1 is 11 - '2' + 1 is 21 ... you need to thing(+otherthing); to coerce the argument to a number
  • I guess @JaromandaX is playing give away credits :P
  • @Lokesh - I was actually trying to find a duplicate because this has been asked many times before :p
  • @JaromandaX let's dig and give chance others to dig :D
  • thanks all of these answers work. I really appreciate it.
  • "I suspect 'number' is a keyword that can't be used for variables" - No, it is not a reserved word.