concatenation demo

concatenate a string and a number results in a string

by Vimla Ramdoo

JavaScript

// concatenate a string and a number
var str1 = "The answer is ";
var n1   = 42;
var result = str1 + n1;

// confirm the type of the concatenated result
alert("' " + result + " ' is a " + typeof(result));