function diamond(arg) { if(arg === 1) {return "*"} var str = "" for(var j = arg; j > 1; j--) { str += Array(j).join(' ') + Array(j).join('*') + '\n' } return str } diamond(5) -> **** *** ** *
** ****
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)