• 카테고리

    질문 & 답변
  • 세부 분야

    알고리즘 · 자료구조

  • 해결 여부

    미해결

강의 7.10부제

22.07.06 18:35 작성 조회수 79

0

function solution(day,arr){
let answer = 0;
for(let x of arr){
if(x.toString().slice(-1)===day.toString)
parseInt(x)
answer++
}
return answer;
}
arr=[25,23,11,47,53,17,33]
console.log(solution(3, arr))
 
7로 나오는데 어 느 부분을 수정해야하면 좋을지 조언을 구하고싶습니다. 감사합니다

답변 1

답변을 작성해보세요.

0

안녕하세요^^

아래와 같이 if 부분을 중괄호로 묶어주세요.

function solution(day,arr){

	let answer = 0;
   
   for(let x of arr){
   
	if(x.toString().slice(-1)===day.toString()){
   
	parseInt(x)
   
	answer++
   }
   
   }
   
	return answer;
   
   }
   
	arr=[25,23,11,47,53,17,33]
   
   console.log(solution(3, arr))