Question

In: Computer Science

JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a...

JAVASCRIPT:

- Please create an object (grade) with 10 names and 10 grades.
- Create a method (inputGrade) that can put a name and a grade to the grade object.
- Create another method (showAlltheGrades) to show all the grade in that object.
- Create the third method (MaxGrade) that can display the maximum grade and the student name.
- Using “prompt” and inputGrade method input 10 student names and their grades.
- Display all the grades and names by using showAlltheGrades method.

NOTE: Make sure to use the push() method when adding elements to the arrays.

Please post the code and a screenshot of the output. Thanks!

Solutions

Expert Solution

I've declared the names initially as well as I have given them using the inputGrade method. Choose the one you are required.

Code:

var grade = {
   name: ["Name1","Name2","Name3","Name4","Name5","Name6","Name7","Name8","Name9","Name10"],
   score: ["44","83","74","54","65","66","44","76","56","71"],
   inputGrade: function(data1,data2){
       grade.name.push(data1);
       grade.score.push(data2);
   },
   showAlltheGrades: function(){
       for ( var i=0; i<grade.name.length; i++ ) {
           console.log(grade.name[i]+":"+grade.score[i]);
       }
   },
   MaxGrade: function(){

       var max = grade.score[0];
       var index = 0;

       for (var i = 1; i < grade.score.length; i++) {
           if (grade.score[i] > max) {
               index = i;
               max = grade.score[i];
           }
       }

       console.log("Maximum Grade: "+grade.name[index]+" , "+grade.score[index]);
   }
};

var name,score;
for (i = 0; i < 10; i++) {
   name=prompt("Please enter Student "+i+" Name : ");
   score=prompt("Please enter Student "+i+" Grade : ");
   grade.inputGrade(name,parseInt(score));
}

Output:


Related Solutions

JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a...
JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a method (inputGrade) that can put a name and a grade to the grade object. - Create another method (showAlltheGrades) to show all the grade in that object. - Create the third method (MaxGrade) that can display the maximum grade and the student name. - Using “prompt” and inputGrade method input 10 student names and their grades. - Display all the grades and names by...
JavaScript - Create a class using "names" as the identifier. Create a constructor. The constructor must...
JavaScript - Create a class using "names" as the identifier. Create a constructor. The constructor must have elements as follow: first ( value passed will be String ) last ( value passed will be String ) age ( value passed will be Numeric ) The constructor will assign the values for the three elements and should use the "this" keyword Create a function, using "printObject" as the identifier printObject: This function will have three input parameters: allNames , sortType, message...
JAVASCRIPT Create an array of 5 objects named "movies" Each object in the movies array, should...
JAVASCRIPT Create an array of 5 objects named "movies" Each object in the movies array, should have the following properties: Movie Name Director Name Year Released WasSuccessful (this should be a boolean and at least 2 should be false) Genre Loop through all of the objects in Array If the movie is successful, display all the movie information on the page. These movies were a success: Title: Forrest Gump Year Realeased: 1994 Director: Robert Zemeckis Genre: Comedy
[Javascript] Create a function(returnObjectFromId(case, ...idNum)) to return the case Object(s) for a given idNum, or list...
[Javascript] Create a function(returnObjectFromId(case, ...idNum)) to return the case Object(s) for a given idNum, or list of idNums. Calling with a single `idNum` value should return the case Object, and return NULL if an id value that's unknown is passed returnObjectFromId(case, 84838) would return the Object in the cases Array with an 'idNumber' of id, and use the .find() method of the cases Array to locate items by idNumber. returnObjectFromId(cases, -23298312) would return null. returnObjectFromId(cases, 161020, 161021) would return an...
Write a program that translates a letter grade into a number grade. Letter grades are A,...
Write a program that translates a letter grade into a number grade. Letter grades are A, B, C, D, and F, possibly followed by + or -. Their numeric values are 4, 3, 2, 1 and 0. There is no F+ or F-. A “+” increases the numeric value by 0.3, a “–“ decreases it by 0.3. However, an A+ has value 4.0.4 pts Enter a Letter grade: B- The numeric value is 2.7 Your code with comments A screenshot...
Please Use JavaScript and P5 1) Greeter Create an page with an input, and a button....
Please Use JavaScript and P5 1) Greeter Create an page with an input, and a button. When the button is clicked, output the phrase "Hello {Name}" to the developer console, with {Name} being the value the user put into the input field. Use a function that takes the name as an argument, and returns the full phrase as its output.
Please create an Event-Based JavaScript Program of your choice. Please write new code for this project...
Please create an Event-Based JavaScript Program of your choice. Please write new code for this project (starting from scratch). Thank you!!
Write a program in python to read from a file the names and grades of a...
Write a program in python to read from a file the names and grades of a class of students to calculate the class average, the maximum, and the minimum grades. The program should then write the names and grades on a new file identifying the students who passed and the students who failed. The program should consist of the following functions: a) Develop a getGrades() function that reads data from a file and stores it and returns it as a...
Please take the code below and add some javascript to it. Please use javascript inline. Please...
Please take the code below and add some javascript to it. Please use javascript inline. Please be sure to specify within the webpage with something like 'Click here' too show what was done and how to activate it. Please post in a format that can be directly copied. Thank you in advance HINT: add some fun widgets to the page index-css.html: <!DOCTYPE html> <html lang="en"> <head> <!-- title for web page --> <title>Index-CSS Page</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1">...
Create a C++ program that will accept any number of grades for an exam. The grades...
Create a C++ program that will accept any number of grades for an exam. The grades will be input as 4 for an A, 3 for a B, 2 for a C, 1 for a D, and 0 for an F. After all grades have been entered, allow the user to enter -1 to exit. Output the number of grades in each category. Using arrays.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT