function solution(dartResult) {
var answer = 0;
const parts=
{
"S":1,
"D":2,
"T":3,
}
const options=
{
"*":2,
"#":-1,
}
let now=0;
const partsKeys=Object.keys(parts);
const optionsKeys=Object.keys(options);
const answerArray=[];
const resArray=[...dartResult];
for(const letter of resArray){
if(partsKeys.includes(letter)){
answerArray[now]= answerArray[now]**parts[letter];
answerArray[now]= answerArray[now];
now+=1;
continue;
}
if(optionsKeys.includes(letter)){
if(letter==="*"){
if(now-1==0){
answerArray[now-1]*=options[letter];
}else{
answerArray[now-2]*=options[letter];
answerArray[now-1]*=options[letter];
}
}else{
answerArray[now-1]*=options[letter];
}
continue;
}
if(letter==='0'){
if(answerArray[now]!==undefined)
{
answerArray[now]*=10;
continue;
}
}
answerArray[now]=letter;
}
answer=answerArray.reduce((a,b)=>a+b);
return answer;
}
2018년도 카카오 문제는 쉬운편이었던 것 같다.
놀지말고 코딩공부해서 지원해볼걸...