Knowee
Questions
Features
Study Tools

0. You used to attend a place like this at some pointmandatoryImplement a class named ClassRoom:Prototype: export default class ClassRoomIt should accept one attribute named maxStudentsSize (Number) and assigned to _maxStudentsSizebob@dylan:~$ cat 0-main.jsimport ClassRoom from "./0-classroom.js";const room = new ClassRoom(10);console.log(room._maxStudentsSize)bob@dylan:~$ bob@dylan:~$ npm run dev 0-main.js 10bob@dylan:~$

Question

  1. You used to attend a place like this at some pointmandatoryImplement a class named ClassRoom:Prototype: export default class ClassRoomIt should accept one attribute named maxStudentsSize (Number) and assigned to _maxStudentsSizebob@dylan:~cat0main.jsimportClassRoomfrom"./0classroom.js";constroom=newClassRoom(10);console.log(room.maxStudentsSize)bob@dylan:  cat 0-main.jsimport ClassRoom from "./0-classroom.js";const room = new ClassRoom(10);console.log(room._maxStudentsSize)bob@dylan:~ bob@dylan:~npmrundev0main.js10bob@dylan:  npm run dev 0-main.js 10bob@dylan:~
...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

// 0-classroom.js
export default class ClassRoom {
  constructor(maxStudentsSize) {
    this._maxStudentsSize = maxStudentsSize;
  }
}

// 0-main.js
import ClassRoom from "./0-classroom.js";

const room = new ClassRoom(10);
console.log(room._maxStudentsSize);

To run the code, you can use the following command:

npm run dev 0-main.js

Similar Questions

1. Let's make some classroomsmandatoryImport the ClassRoom class from 0-classroom.js.Implement a function named initializeRooms. It should return an array of 3 ClassRoom objects with the sizes 19, 20, and 34 (in this order).bob@dylan:~$ cat 1-main.jsimport initializeRooms from './1-make_classrooms.js';console.log(initializeRooms());bob@dylan:~$ bob@dylan:~$ npm run dev 1-main.js [ ClassRoom { _maxStudentsSize: 19 }, ClassRoom { _maxStudentsSize: 20 }, ClassRoom { _maxStudentsSize: 34 }]bob@dylan:~$

2. A Course, Getters, and SettersmandatoryImplement a class named HolbertonCourse:Constructor attributes:name (String)length (Number)students (array of Strings)Make sure to verify the type of attributes during object creationEach attribute must be stored in an “underscore” attribute version (ex: name is stored in _name)Implement a getter and setter for each attribute.bob@dylan:~$ cat 2-main.jsimport HolbertonCourse from "./2-hbtn_course.js";const c1 = new HolbertonCourse("ES6", 1, ["Bob", "Jane"])console.log(c1.name);c1.name = "Python 101";console.log(c1);try { c1.name = 12;} catch(err) { console.log(err);}try { const c2 = new HolbertonCourse("ES6", "1", ["Bob", "Jane"]);}catch(err) { console.log(err);}bob@dylan:~$ bob@dylan:~$ npm run dev 2-main.js ES6HolbertonCourse { _name: 'Python 101', _length: 1, _students: [ 'Bob', 'Jane' ]}TypeError: Name must be a string ...TypeError: Length must be a number ...bob@dylan:~$

2. Extending the Teacher classmandatoryWrite an interface named Directors that extends Teacher. It requires an attribute named numberOfReports(number)Example:const director1: Directors = { firstName: 'John', lastName: 'Doe', location: 'London', fullTimeEmployee: true, numberOfReports: 17,};console.log(director1);// should print// Object// firstName: "John"// fullTimeEmployee: true// lastName: "Doe"// location: "London"// numberOfReports: 17

4. Writing a classmandatoryWrite a Class named StudentClass:The constructor accepts firstName(string) and lastName(string) argumentsThe class has a method named workOnHomework that return the string Currently workingThe class has a method named displayName. It returns the firstName of the studentThe constructor of the class should be described through an InterfaceThe class should be described through an InterfaceRequirements:You can reuse the Webpack configuration from the previous exercise to compile the code.When running npm run build, no TypeScript error should be displayed.Every variable should use TypeScript when possible.

Create a function named getListStudents that returns an array of objects.Each object should have three attributes: id (Number), firstName (String), and location (String).The array contains the following students in order:Guillaume, id: 1, in San FranciscoJames, id: 2, in ColumbiaSerena, id: 5, in San Franciscobob@dylan:~$ cat 0-main.jsimport getListStudents from "./0-get_list_students.js";console.log(getListStudents());bob@dylan:~$ bob@dylan:~$ npm run dev 0-main.js [ { id: 1, firstName: 'Guillaume', location: 'San Francisco' }, { id: 2, firstName: 'James', location: 'Columbia' }, { id: 5, firstName: 'Serena', location: 'San Francisco' }]bob@dylan:~$

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.