Practice: Build a New Object with Constructor
This is the code for the Microphone class.
/**
* Creating classes:
*
* Class declaration: class Name {}
* Class expression: const Name = class {}
*/
class Microphone {
constructor(
// Defines parameters:
brand,
colour,
price,
text
) {
// Define properties:
this.brand = brand;
this.colour = colour;
this.price = price;
this.text = "";
}
// Add methods like normal functions:
record(audio) {
this.text = audio;
}
}
export default Microphone;