Question

In: Computer Science

Javascipt Assignment: Create a document that includes a constructor function named Company in the document head...

Javascipt Assignment:

Create a document that includes a constructor function named Company in the document head area.

Include four properties in the Company object definition:

name, products, motto, and numEmployees (for number of employees.)

Instantiate a new Company object in the document body , then assign values to each of the properties

Print the name, products, motto, and the numEmployees properties to the screen using document.write methods.

Combine each printed property with a descriptive string.

For example, when you print the company name, it should read something like " The company name is MyComany."

Solutions

Expert Solution

Here is code:

<script>

// class company

function Company(name, products, motto, numEmployees) {

this.name = name;

this.products = products;

this.motto = motto;

this.numEmployees = numEmployees;

}

// Object for the company

var c = new Company("MyComany", "Pen", "NO #1 company", 2500);

// Display the data

document.write("The company name is " + c.name + "<br>");

document.write("The products name is " + c.products + "<br>");

document.write("The motto of the company is " + c.motto + "<br>");

document.write("The no. of Employees are " + c.numEmployees + "<br>");

</script>

Sample code to test with html:

<!doctype html>

<html>

<head>

<title>Company</title>

<script>

// class company

function Company(name, products, motto, numEmployees) {

this.name = name;

this.products = products;

this.motto = motto;

this.numEmployees = numEmployees;

}

// Object for the company

var c = new Company("MyComany", "Pen", "NO #1 company", 2500);

// Display the data

document.write("The company name is " + c.name + "<br>");

document.write("The products name is " + c.products + "<br>");

document.write("The motto of the company is " + c.motto + "<br>");

document.write("The no. of Employees are " + c.numEmployees + "<br>");

</script>

</head>

<body>

<h1></h1>

</body>

</html>

Output:


Related Solutions

Java program Create a constructor for a class named Signal that will hold digitized acceleration data....
Java program Create a constructor for a class named Signal that will hold digitized acceleration data. Signal has the following field declarations private     double timeStep;               // time between each data point     int numberOfPoints;          // number of data samples in array     double [] acceleration = new double [1000];          // acceleration data     double [] velocity = new double [1000];        // calculated velocity data     double [] displacement = new double [1000];        // calculated disp data The constructor...
VBA In this assignment you will create a Word Macro-Enabled Document. The document will contain procedures...
VBA In this assignment you will create a Word Macro-Enabled Document. The document will contain procedures with the following declarations: • Sub Main() • Sub GetGrades(grades() As Integer, total As Integer) • Sub CreateOutput(className As String, grades() As Integer, total As Integer) The Main sub-procedure will be the macro that initializes the task. In this procedure you will declare all necessary variables, prompt the user to enter the name of the class and the number of students, resize the grades...
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...
Create a function named ‘dividing’. This function will take one parameter value, which will be an...
Create a function named ‘dividing’. This function will take one parameter value, which will be an integer. For the function you will use ‘Exception Handling’ with the use of the try and except statements to try and return the results of a number divided by the parameter value given to the function. If the parameter passed to the function is the integer value of zero then your function should return ‘You tried to divide by zero!’ through the use of...
JAVA PROGRAMMING. In this assignment, you are to create a class named Payroll. In the class,...
JAVA PROGRAMMING. In this assignment, you are to create a class named Payroll. In the class, you are to have the following data members: name: String (5 pts) id: String   (5 pts) hours: int   (5 pts) rate: double (5 pts) private members (5 pts) You are to create no-arg and parameterized constructors and the appropriate setters(accessors) and getters (mutators). (20 pts) The class definition should also handle the following exceptions: An employee name should not be empty, otherwise an exception...
Create a function named getCreds with no parameters that will prompt the user for their username...
Create a function named getCreds with no parameters that will prompt the user for their username and password. This function should return a dictionary called userInfo that looks like the dictionaries below: # Administrator accounts list adminList = [ { "username": "DaBigBoss", "password": "DaBest" }, { "username": "root", "password": "toor" } ] Create a function named checkLogin with two parameters: the userInfo and the adminList. The function should check the credentials to see if they are contained within the admin...
Create a class named CollegeCourse that includes data fields that hold the department (for example, ENG),...
Create a class named CollegeCourse that includes data fields that hold the department (for example, ENG), the course number (for example, 101), the credits (for example, 3), and the fee for the course (for example, $360). All of the fields are required as arguments to the constructor, except for the fee, which is calculated at $120 per credit hour. Include a display() method that displays the course data. Create a subclass named LabCourse that adds $50 to the course fee....
Create the function named multiplyByAverage used below. The multiplyByAverage function is passed a float array and...
Create the function named multiplyByAverage used below. The multiplyByAverage function is passed a float array and its size and multiplies each element of the passed array by the array's average. in C++. const size_t SIZE = 4; float floatArray[SIZE] = { 42.5, 74.2, 12.4, 24.3 }; multiplyByAverage(floatArray, SIZE); //floatArray is now: { 1629.9, 2845.6, 475.5, 931.9 }
Challenge: Documents Description: Create a class in Python 3 named Document that has specified attributes and...
Challenge: Documents Description: Create a class in Python 3 named Document that has specified attributes and methods for holding the information for a document and write a program to test the class. Purpose: The purpose of this challenge is to provide experience creating a class and working with OO concepts in Python 3. Requirements: Write a class in Python 3 named Document that has the following attributes and methods and is saved in the file Document.py. Attributes __title is a...
Assignment: In this project, you’ll create a security infrastructure design document for a fictional organization. The...
Assignment: In this project, you’ll create a security infrastructure design document for a fictional organization. The security services and tools you describe in the document must be able to meet the needs of the organization. Your work will be evaluated according to how well you met the organization’s requirements. About the organization: This fictional organization has a small, but growing, employee base, with 50 employees in one small office. The company is an online retailer of the world's finest artisanal,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT