var input1 = 'a234'
var input2 = '1234'
function solution(s) {
let len = s.length;
let answer = Number(s);
if((len === 4 || len === 6) && answer === parseInt(s)) {
return answer = true;
}else {
return answer = false;
}
}
console.log('input1: ' + solution(input1))
console.log('input2: ' + solution(input2))
var absolutes = [4,7,12]
var signs = [true, false, true]
function solution(absolutes, signs) {
let answer = 0;
for (let i = 0; i < absolutes.length; i++) {
if(signs[i] === true) {
answer += absolutes[i];
} else {
answer -= absolutes[i];
}
}
return answer;
}
console.log('answer: ' + solution(absolutes, signs))