1
2
3
4
5
6
7
8
9
10
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.
0,1,2,3,4,5,6,7,8,9
0
0
0
0
Fill in the blank for a class constructor. | class Nation { ___________(name, area, population) { |
constructor | constructor |
Fill in the blank for a class constructor. | ______ Nation { constructor(name, area, population) { |
class | class |
Convert this line to the first two lines of a class definition. | function Person(name, age) { | class Person { constructor(name, age) { |
classPerson{[\r\n]constructor\(name,age\){ |
Code the first two lines of a class constructor. The constructor's name is Planet. It has one parameter, size. | class Planet { constructor(size) { |
classPlanet{[\r\n]constructor\(size\){ | |
Code a class constructor that has a single parameter. Make up everything. | class Planet { constructor(size) { this.size = size; } } |
class[A-Z][a-zA-Z0-9_$]*{[\r\n]constructor\(([a-z_$][a-zA-Z0-9_$]*)\){[\r\n]this\.\1=\1;[\r\n]}[\r\n]} | |
Fill in the blanks to complete this class constructor, adding a method. The method returns the sum of this.width and this.height. Make up the name of the method. | class Dimensions { constructor(width, height) { this.width = width; this.height = height; } _________ ________________________________ _ _ |
sumEm() { return this.width + this.height; } } |
[a-z_$][a-zA-Z0-9_$]*\(\){[\r\n]returnthis\.width\+this\.height;[\r\n]}[\r\n]} |
Code a class constructor that has one parameter and a method that does nothing. Assign the parameter value to a variable the usual way. Make up everything. | class NotMuch { constructor(color) { this.color = color; } doNothing() { } } |
class[A-Z][a-zA-Z0-9_$]*{[\r\n]constructor\(([[a-z_$][a-zA-Z0-9_$]*)\){[\r\n]this\.\1=\1;[\r\n]}[\r\n][a-z_$][a-zA-Z0-9_$]*\(\){[\r\n]}[\r\n]} | |
Code a class constructor named Person with two string parameters, firstName and lastName. It has a method. The method concatenates the two values, adding a space between them, returning the string. Make up the name of the method. | class Person { constructor(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; } combine() { return this.firstName + " " + this.lastName; } } |
class[A-Z][a-zA-Z0-9_$]*{[\r\n]constructor\(firstName,lastName\){[\r\n]this\.firstName=firstName;[\r\n]this\.lastName=lastName;[\r\n]}[\r\n][a-z_$][a-zA-Z0-9_$]*\(\){[\r\n]returnthis\.firstName\+••\+this\.lastName;[\r\n]}[\r\n]} | |
|
|||
|