Question
(COPY AND PASTE INTO NOTEPAD++ AND DO NOT CHANGE THE PRE-WRITTEN CODE. I NEED THE CODE WRITTEN IN JAVASCRIPT FOLLOWING THE INSTRUCTIONS PROVIDED.) Modify the
(COPY AND PASTE INTO NOTEPAD++ AND DO NOT CHANGE THE PRE-WRITTEN CODE. I NEED THE CODE WRITTEN IN JAVASCRIPT FOLLOWING THE INSTRUCTIONS PROVIDED.)
Modify the studentRecord object as indicated below.
1. Change the name property to fname and assign a first name of your choosing
2. Add an lname property and assign a last name of your choosing
3. Set the major property to a major of your choosing
4. Add a gpa property and set it to zero
5. Modify the displayStudentRecord method to print all of the studentRecord properties in the following order: fname, lname, major, gpa
6. Add an else clause to the if statement in the setMajor method that displays an error message if a new major value was not passed in.
7. Add a setGPA method that has one parameter called newGPA.
Set the student gpa property equal to the newGPA parameter. Make sure to
verify that a new gpa value was passed in. If a new gpa value was not
passed in display an error message. The setGPA method is similar to the
setMajor method.
*/
//Turn on strict mode
"use strict";
//Create and initialize the studentRecord object
var studentRecord = {
name : "",
major: "",
//Method to display all properties in the studentRecord object
displayStudentRecord : function(){
document.write("Name: " + this.name + " ");
document.write("Major: " + this.major + " ");
},
//Method to set the studentRecord object's major property
setMajor : function (newMajor) {
if (newMajor) {
this.major = newMajor;
}
},
//Add a new method called setGPA. This method
//will be used to update the gpa property.
}; //end object
//****Begin using the studentRecord object methods****
//Remember to always prefix the properties and methods with
//the name of the object using . (dot) notation.
//1. Call the studentRecord's displayStudentRecord method
//2. Call the studentRecord's setMajor method to change the major
// Use any major you want
//3. Call the studentRecord's setGPA method to change the GPA
// Use any GPA you want
//4. Call the studentRecord's displayStudentRecord method
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started