I am pretty new to Javascript and I am struggling with one of my assignments.
This is the context:
Manipulate this data
var grades = "jim|25, sue|32, mary|34, ann|22, ted|28, frank|15, lisa|19, mike|30, ahn|26, vishaya|27";
Create an HTML page with inline JavaScript code that displays student data in a more readable format like so:
Name1 - score1
Name2 - score2
Your program should:
display each student name and score
capitalize the first letter of student name
display the total # of students,
display the lowest, highest, and average scores
Now, I was able to print the names and grades in a more readable format but I don't know how to go about capitalizing the first letter of each name and how to output the lowest, highest and average grades.
Here is my code:
<body>
<p id="demo"></p>
<script>
var grades =
"jim|25, sue|32, mary|34, ann|22, ted|28, frank|15, lisa|19, mike|30, ahn|26, vishaya|27";
let result = grades.split(", ");
function getNameAndGrade(Str) {
for (let i in result) {
document.write(
` <b>Name: </b>${result[i].slice(
0,
result[i].indexOf("|")
)} <b>Grade: </b>${result[i].slice(-2)} <br>`
);
}
}
getNameAndGrade(grades);
</script>
</body>