Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

Why is there an "undefined" line in my loop output for JavaScript

$
0
0

Hello, I am making a simple page, it is just 2 text boxes, 1 text box that you will type a word, the second text box for how many times you want that word repeated in the output. I got it to repeat the word as many times as i typed in, but the first line of output says undefined. Help Please!! my code is:

function repeatWord() {

var word = document.getElementById("word").value;
var repeatnum = parseInt( document.getElementById("repeatnum").value);

for( var count = 1; count <= repeatnum; count++ ) {

var msg = msg + "<div>" + word + "</div>";
console.log;
}

document.getElementById("results").innerHTML = msg;

}


Viewing all articles
Browse latest Browse all 3527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>