JSFiddle - React, Tailwind, and code Playground

by CommandLineDesign

JavaScript

let commandsMap = {
	'SET' : setCommand,
	'GET' : getCommand,
	'DELETE' : deleteCommand,
	'COUNT' : countCommand,
	'END' : endCommand
}

let dataStore = {}

let countMap = {}

var setCommand = function(myVar, value){
	dataStore[myVar] = value;
	countMap[value] = myVar
}

var getCommand = function(myVar){
	return dataStore[myVar] || 'NULL'
}

var deleteCommand = function(myVar){
	delete dataStore[myVar]
}

var countCommand = function(value){
	return countMap[value]|| 'NULL'
}