niyazpk/Chess.js — comment on commit 68f872afe8767e76be4bdc7968cb306b54503cb3
File: scripts/chess.js line 37
By hugobr:

Wouldn't it be cleaner if you use an object to store the names, instead of the noisy switch/case?

Like:

var PIECE_NAMES = {
WHITE_KING: 'WHITE_KING',
BLACK_QUEEN: 'BLACK_QUEEN'
};

function getPieceName(pieceValue) {
return PIECE_NAMES[pieceValue] || 'EMPTY';
}