JavaScript organizando monedas

// leetcode arranging coins
var arrangeCoins = function(n) {
    let i = 1, j = 0
    
    while(n>0){
        n -= i
        j++
        i++
    }
    
    if(n === 0) return j
    else return --j
};
kouqhar