how to square a value in javascript
// Use Math.pow(a,b); where a is your value and b is the exponent
var num = Math.pow(4, 2);
//num returns 16
how to square a value in javascript
// Use Math.pow(a,b); where a is your value and b is the exponent
var num = Math.pow(4, 2);
//num returns 16
javascript print square
// make square function
function makeSquare(element, size, character){
// result string
var string = '';
// generating 2D string based on size and character parameter
for (var i = 0; i < size; i++) {
for (var j = 0; j < size; j++) {
string += character;
}
string += 'n';
}
// overriding element value with the generated string
element.innerHTML = string;
}
// using the function
makeSquare(document.querySelector('#square'), 5, '*')
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us