Why is add method and clear method wrong?

Tell us what’s happening:
why is add method and clear method wrong?

Your code so far


class Map{

constructor(){
 this.collection = {};
 this.length = 0
}

add(key, value){
    this.collection[key] = value
    this.length++
}

remove(key){
  delete this.collection[key];
  this.length--
}
 
get(key){
  return this.collection[key]
} 

has(key){
 return this.collection[key] ? true : false
}
values(){
  return Object.values(this.collection)
}

clear(){
  this.collection = {};
  this.length = 0
  return;
}

size(){
 return this.length;
}
}


let map = new Map()

map.add(1, 2)
map.add(2, 2)
console.log(map.get(1))
map.clear()
console.log(map)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36.

Challenge: Create a Map Data Structure

Link to the challenge:

If you run the code you will get the following errors
Because the add methode should add the items to the map
You did made a set of key value paris but you don’t seem to do antyhing with them
otherwise then set it to a value and inscrease it

The clear method should empty the map and the size method should return the number of items present in the map
You are returning it but are not clearing it