189k views
1 vote
Define a JavaScript function named showGrades which does not have any parameters. Your function should create and return an array containing 3 Numbers. The values for each of these entries should be: get the value from the div whose id is "GradeA" and store it at index 0 of your array; get the value from the div whose id is "Passing" and store it at index 1 of your array; and get the value from the div whose id is "Learning" and store it at index 2 of your array. Your must then encode the array as a JSON blob and return that JSON blob.

User MarioVilas
by
6.0k points

1 Answer

1 vote

Answer:

see explaination

Step-by-step explanation:

//selective dev elements by id name

var gradeA = document.querySelector("#GradeA");

var passing = document.querySelector("#Passing");

var learning = document.querySelector("#Learning");

//function showGrades

function showGrades() {

var arr = [];

//converting string to int and inserting into array

arr[0] = parseInt(gradeA.textContent);

arr[1] = parseInt(passing.textContent);

arr[2] = parseInt(learning.textContent);

//creating json blob

var blob = new Blob(new Array(arr), {type:"text/json"});

return blob;

}

User Lynn
by
7.1k points