<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
let students = [
{
name: 'Rasel',
score1:50,
score2:30
},
{
name: 'Murad',
score1:30,
score2:30
},
{
name: 'Mehedi',
score1:20,
score2:30
},
{
name: 'Sporsha',
score1:60,
score2:30
},
];
let scores = [90,80,70,60];
let grades = ['A','B','C','D'];
function calculate(score1,score2){
return score1+score2;
}
var i;
for(i=0;i<students.length; i++){
students[i].sum = calculate(students[i].score1,students[i].score2);
if(students[i].sum >= 51){
for(var x=0;x<scores.length;x++){
if(students[i].sum >= scores[x]){
console.log(students[i].name + ' score is '+
students[i].sum + ' which is ' + grades[x]);
break;
}
}
}else{
console.log(students[i].name + ` score is `+
students[i].sum + ' which is failed' );
}
}
</script>
</body>
</html>