The bug here is that filter() returns a new array, so I have to assign
the return value to the original reference for this code to have any
effect.
/* Returns the number of remaining connections after this one is removed. */
remove_connection(connection) {
/* Returns the number of remaining connections after this one is removed. */
remove_connection(connection) {
- this.connections.filter(c => c !== connection);
+ this.connections = this.connections.filter(c => c !== connection);
return this.connections.length;
}
return this.connections.length;
}