Question
Write a program that takes three names as inputs from the prompt. a. Write a class that contains a constructor that initiate three string properties
Write a program that takes three names as inputs from the prompt.
a. Write a class that contains a constructor that initiate three string properties using the input values. There should be a getter method called classmates that returns two names as classmates. Note that if the getter method is defined correctly, you should not need to use a pair of () after the method names to call them as shown in the textbook. 10 points off if not using a correct getter method.
b. Create an object from the class. Call its getter method and print the names of the two classmates.
JAVASCRIPT ONLY PLEASE
What I have so far:
// Constructor to initialize the properties with input values class Students(name1,name2,name3) { // Assign the input values to the properties this.name1 = name1; this.name2 = name2; this.name3 = name3; }
// Getter method to return the two classmates get classmates() return this.name1 && this.name2 { } } // Prompt the user to enter the students first name Let name1= prompt("Enter first student name."); Let name1= prompt("Enter second student name."); Let name1= prompt("Enter third student name.");
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