function solution(bandage, health, attacks) {
    var answer = 0;
    var success = 0;
    var now = health;
    var keep = 0;
    var last_attack = attacks[attacks.length-1][0];
    var time = bandage[0];
    var heal = bandage[1];
    var bonus = bandage[2];
    
    for(let i=1; i<=last_attack; i++){
       if(i == attacks[0][0]){
            now = now - attacks[0][1]
            attacks.shift();
            keep=0;
            console.log("attack",now)
           if(now<1){
               now = -1;
               break;
           }
       }
        else{
            if(now+heal>health)
                now = health;
            else now = now+heal;
            keep++;
            
            if(time==keep){
                keep=0;
                now +bonus < health? now = now + bonus : now = health;
            }
            
        }
       
        
    }
    
    
    return now;
}

삼항연산자 쓰면 심심찮게 오타나서 계속 틀리는데도 

깔끔해보여서 자꾸 쓰게된다 헷 

+ Recent posts