<script>
"use strict";
// 객체 배열
var students = [ {
name : '홍길동',
kor : 100,
eng : 90,
math : 80
}, {
name : '임꺽정',
kor : 90,
eng : 95,
math : 100
}, {
name : '장길산',
kor : 95,
eng : 50,
math : 65
} ];
for (var i = 0; i < students.length; i++) {
console.log(students[i].name, students[i].kor, students[i].eng,
students[i].math);
}
// task : 위의 code를 forEach() 사용 code로 바꾸시오.
students.forEach(function(parameter) {
console.log(parameter.name, parameter.kor, parameter.eng,
parameter.math);
});
// Solution
students.forEach(function(student, index, array) {
console.log(index, array, student, student.name, student.kor,
student.eng, student.math);
});
var a = [7,8,2,5];
a.forEach(function(ele, i, arr){
var temp;
for(var j=0; j<arr.length;j++){
if(ele<arr[i+1]) console.log('<<');
else console.log('>>');
}
});
</script>
댓글 없음:
댓글 쓰기