Adding items to a Map

Tell us what’s happening:
I watched the tutorial for how to build a map, this is what i gathered from it. I do not understand why it is failing the test to determine if items can be properly added to the array.

Your code so far


let Map = function() {
	this.collection = {};
	this.count = 0;
	this.size = function() {
		return this.count;
	};
	this.add = function(key, value) {
		this.collection[key] = value;
		this.count++;
 
	};
	this.has = function(key) {
		return (key in this.collection);
	};
	this.get = function(key) {
		return (key in this.collection) ? this.collection[key] : null;
	};
	this.remove = function(key) {
		if (key in this.collection) {
			delete this.collection[key];
			this.count--;
		}
	};
	this.values = function() {
		let result = new Array();
		for (let key of Object.keys(this.collection)) {
			result.push(this.collection[key]);
		};
		return (result.length > 0) ? result : null;
	};
	this.clear = function() {
		this.collection = {};
		this.count = 0;
	};
};

Your browser information:

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

Challenge: Create a Map Data Structure

Link to the challenge:
https://www.freecodecamp.org/learn/coding-interview-prep/data-structures/create-a-map-data-structure

It looks like the problem is with how you are keeping track of the size.

const test = new Map();
test.add(5, 6);
test.add(2, 3);
test.add(2, 5);

console.log(test.collection);
// { 2: 5, 5: 6 }
console.log(Object.keys(test.collection).length);
// 2
console.log(test.size());
// 3