+ 1
How can i write a function which add specific amount of whitespace to end of the string.
Eg. function("MyString",3) returns "MyString "
1 Respuesta
+ 1
window.onload = function() {
var p = document.getElementById("p-tag");
function addSpaces(str, spaces) {
for(var i = 0; i < spaces; ++i) {
str += " "
}
return str;
}
p.innerHTML = "*" + addSpaces("some text", 3) + "*";
}