Race Condition in Counter Service
★★★★☆
📁 rails/rails 🔢
ghi9012 Concurrency ★★★★☆
Difficulty
+150 XP reward
Counter.js.js | 15 lines
Original (Buggy) Read-only
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Counter {
constructor() {
this.value = 0;
}
increment() {
this.value = this.value + 1;
return this.value;
}
decrement() {
this.value = this.value - 1;
return this.value;
}
}
Your Fix Editable
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0 added
0 removed
0 changed
Click lines on the left to mark as buggy
Submit Your Fix
Lines marked: 0
Edit the code on the right panel above to fix the bugs. Changes are highlighted in real-time.
■ Removed ■ Changed ■ Added Click lines on the left to mark buggy lines