Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
var data = [
{
"firstname": "John",
"lastname": "Smith",
"dob": "1/15/1999",
"test1": 30,
"test2": 30,
"test3": 30,
},
{
"firstname": "Thomas",
"lastname": "Edison",
"dob": "1/15/2010",
"test1": null,
"test2": 60,
"test3": 64,
},
{
"firstname": "Nicolas",
"lastname": "Tesla",
"dob": "1/15/1825",
"test1": 80,
"test2": null,
"test3": 90,
},
{
"firstname": "Walter",
"lastname": "White",
"dob": "1/15/1960",
"test1": 100,
"test2": 90,
"test3": 97,
},
{
"firstname": "Bruce",
"lastname": "Wayne",
"dob": "1/15/1960",
"test1": 50,
"test2": 90,
"test3": 97,
},
]
$(function () {
start(data);
})
//Create a jQuery ready function and call start() method in it , Pass data as argument to start method.
function calcAge() {
var date = new Date();
var d = date.getFullYear();
var temp = [];
for (var i in data) {
temp.push(Math.abs(parseInt(data[i].dob.slice(-4) - (d - 1))));
}
return temp;
//accept date of birth and return the age based on birth year.
}
function fullname() {
var temp = [];
for (var i in data) {
temp.push(data[i].firstname.concat(" ", data[i].lastname));
}
return temp;
//accept firstname and lastname and return full name.
}
function grade(test1, test2, test3) {
var grade = [];
for (var i = 0; i < test1.length; i++) {
var total = (test1[i] + test2[i] + test3[i]) / 3;
if (total >= 90) {
grade.push("A");
} else if (total >= 70 && total < 90) {
grade.push("B");
} else if (total >= 50 && total < 70) {
grade.push("C");
} else if (total < 50) {
grade.push("D");
}
}
return grade;
// Calculate the average of the marks and find grade based on it.
// >= 90 : A
// >= 70 : B
// >= 50 : C
// < 50 : D
}
function remarks(grade) {
var remark = [];
for (var i in grade) {
if (grade[i] == "A") {
remark.push("Excellent");
} else if (grade[i] == "B") {
remark.push("Good");
} else if (grade[i] == "C") {
remark.push("Need improvement");
} else if (grade[i] == "D") {
remark.push("Take the test again");
}
}
return remark;
//Accept grade and return a remark based on the grade.
// A : Excellent
// B : Good
// C : Need improvement
// D : Take the test again
}
function start(studentData) {
// Display the given raw data in tabular format as shown in output in the first table(Student data)
// Hint : The id of the first table body is "data"(#data)
//Write the code to find null values in the data and delete the entire record if a null value is present
//Display the inference from the raw data in the second table(Inference) as shown in the output
// Columns:
// Fullname - use fullname()
// Age - use calcAge()
// Grade - use grade()
// Remarks - combine grade() and remarks()
//// Hint : The id of the second table body is "data" (#inference)
var fname = fullname();
var age = calcAge();
var test1 = [];
var test2 = [];
var test3 = [];
for (var i = 0; i < studentData.length; i++) {
test1.push(studentData[i].test1);
test2.push(studentData[i].test2);
test3.push(studentData[i].test3);
}
var grd = grade(test1, test2, test3);
var rm = remarks(grd);
for (var i in studentData) {
$('#data').append('<tr><td>' + studentData[i].firstname + '</td><td>' + studentData[i].lastname + '</td><td>' + studentData[i].dob + '</td><td>' + studentData[i].test1 + '</td><td>' + studentData[i].test2 + '</td><td>' +
studentData[i].test3 + '</td></tr>');
}
for (var i = 0; i < fname.length; i++) {
if (studentData[i].firstname != null && studentData[i].lastname != null && studentData[i].dob != null && studentData[i].test1 != null && studentData[i].test2 != null && studentData[i].test3 != null) {
$('#inference').append('<tr><td>' + fname[i] + '</td><td>' + age[i] + '</td><td>' + grd[i] + '</td><td>' + rm[i] + '</td></tr>');
}
}
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team