Skip to content

Commit 6e7b67b

Browse files
Merge pull request ryanmcdermott#220 from GrzegorzZajac000/patch-1
Capital letters in const, remove default data in class Car
2 parents 5168312 + 465c380 commit 6e7b67b

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

README.md

+12-16
Original file line numberDiff line numberDiff line change
@@ -1114,10 +1114,10 @@ and you can chain further class methods onto it.
11141114
**Bad:**
11151115
```javascript
11161116
class Car {
1117-
constructor() {
1118-
this.make = 'Honda';
1119-
this.model = 'Accord';
1120-
this.color = 'white';
1117+
constructor(make, model, color) {
1118+
this.make = make;
1119+
this.model = model;
1120+
this.color = color;
11211121
}
11221122

11231123
setMake(make) {
@@ -1137,20 +1137,18 @@ class Car {
11371137
}
11381138
}
11391139

1140-
const car = new Car();
1140+
const car = new Car('Ford','F-150','red');
11411141
car.setColor('pink');
1142-
car.setMake('Ford');
1143-
car.setModel('F-150');
11441142
car.save();
11451143
```
11461144

11471145
**Good:**
11481146
```javascript
11491147
class Car {
1150-
constructor() {
1151-
this.make = 'Honda';
1152-
this.model = 'Accord';
1153-
this.color = 'white';
1148+
constructor(make, model, color) {
1149+
this.make = make;
1150+
this.model = model;
1151+
this.color = color;
11541152
}
11551153

11561154
setMake(make) {
@@ -1178,10 +1176,8 @@ class Car {
11781176
}
11791177
}
11801178

1181-
const car = new Car()
1179+
const car = new Car('Ford','F-150','red')
11821180
.setColor('pink')
1183-
.setMake('Ford')
1184-
.setModel('F-150')
11851181
.save();
11861182
```
11871183
**[⬆ back to top](#table-of-contents)**
@@ -1945,8 +1941,8 @@ class Alpaca {}
19451941
const DAYS_IN_WEEK = 7;
19461942
const DAYS_IN_MONTH = 30;
19471943

1948-
const songs = ['Back In Black', 'Stairway to Heaven', 'Hey Jude'];
1949-
const artists = ['ACDC', 'Led Zeppelin', 'The Beatles'];
1944+
const SONGS = ['Back In Black', 'Stairway to Heaven', 'Hey Jude'];
1945+
const ARTISTS = ['ACDC', 'Led Zeppelin', 'The Beatles'];
19501946

19511947
function eraseDatabase() {}
19521948
function restoreDatabase() {}

0 commit comments

Comments
 (0)