Question: You are to create a number of Computer objects. Each Computer object will contain the following properties: name: a string containing the name of the
You are to create a number of Computer objects. Each Computer object will contain the following properties: name: a string containing the name of the computer (such as TRS-80) manufacturer: a string containing the computers manufacturer (such as Radio Shack) description: a string containing a brief description of the computer imageFilename: a string containing the path to the image file of the computer relative to your HTML page (such as media/trs80.jpg) ram: a number containing the bytes of RAM that the computer possesses
You are to create a Computer constructor that takes five parameters, one for each of the above properties. It will initialize the properties of the Computer object that it creates. You are to create an array of at least four Computer objects that the web site visitor can view.
You are to create a method convertRAM() on the Computer objects. This method should take the number of bytes in the ram property and convert it to either bytes, KB, MB, or GB. For instance, if the computer has 128 bytes of RAM, the method should return the string "128 bytes". If the computer has 65536 bytes of RAM, the method should return the string "66 KB" (or "64 KB" if you choose to interpret a KB of RAM as 1024 bytes). You should use a single convertRAM() method for all Computer objects.
This is my current constructor
class Computer {
constructor(name, manufacturer, description, src, ram) { this.name = name; this.manufacturer = manufacturer; this.descriptiom = description; this.imageFilename = imageFilename; this.ram = ram; } }
How do I create an array with my constructors and I can't figure out how to convert the RAM.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
