15 lines
553 B
JavaScript
15 lines
553 B
JavaScript
class MoveTable {
|
|
static buildScoresRows(reasoning) {
|
|
const scores = reasoning && typeof reasoning === "object" ? reasoning.scores : null;
|
|
const moveOrder = ["up", "down", "left", "right"];
|
|
return moveOrder.map((move) => {
|
|
const hasScore = scores
|
|
&& typeof scores === "object"
|
|
&& !Array.isArray(scores)
|
|
&& Object.prototype.hasOwnProperty.call(scores, move);
|
|
const value = hasScore ? scores[move] : "-";
|
|
return `<tr><td>${move}</td><td>${Utils.safeString(value)}</td></tr>`;
|
|
}).join("");
|
|
}
|
|
}
|