I’ve got some code for a calculator which I’d now like to add a % to the result if there is a result there.
The current code is
var margins = num4.split(" ");
var topMarg = GetIntOrEmpty(margins[0]),
rightMarg = GetIntOrEmpty(margins[1]),
bottomMarg = GetIntOrEmpty(margins[2]),
leftMarg = GetIntOrEmpty(margins[3]);
console.log(topMarg, rightMarg, bottomMarg, leftMarg);
var shorthand1 = GetIntOrEmpty (topMarg);
shorthand1 += ' %';
if shorthand1 is empty I want it to not add the ‘ %’ to it and leave it blank.
Any ideas?
1 Answer