Arranging Coins

JavaScript
var arrangeCoins = function(n) {
    let i = 1, j = 0
    
    while(n > 0){
        n -= i
        j++
        i++
    }
    
    if(n === 0) return j
    else return --j
};
Source

Also in JavaScript: