Skip to content

Commit

Permalink
find fruits start with char
Browse files Browse the repository at this point in the history
  • Loading branch information
ohgyun committed Oct 29, 2012
1 parent f48b895 commit 8a85b15
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions target-code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var fruits = ['apple', 'banana', 'cherry', 'grape', 'mango'];

function findFruitsStartWith(char) {
for (i = 0; i < fruits.length; i++) {

This comment has been minimized.

Copy link
@ohgyun

ohgyun Oct 29, 2012

Author Owner

반복문 인덱스인 i에 var 선언을 넣지 않으면, i가 전역변수로 선언되요~

This comment has been minimized.

Copy link
@ohgyun

ohgyun Oct 29, 2012

Author Owner

개인 작업에 대해서는, 위처럼 Commits 히스토리에 댓글을 다는 식으로 리뷰합니다.

if (fruits[i].indexOf(char) === 0) {
return fruits[i];
}
}
}

console.log(findFruitsStartWith('c'));

0 comments on commit 8a85b15

Please sign in to comment.