+ {array.length === 0 ? (
+
Stack is empty
+ ) : (
+ array.map((value, idx) => {
+ let cls = COLORS.default;
+
+ if (highlight) {
+ if (highlight.type === "push" && highlight.array && highlight.array[0] === value && idx === 0) {
+ cls = COLORS.push;
+ }
+ if ((highlight.type === "pop" || highlight.type === "pop-start") && idx === 0) {
+ cls = COLORS.pop;
+ }
+ if (highlight.type === "peek" && highlight.index === idx) {
+ cls = COLORS.peek;
+ }
+ if (highlight.type === "underflow") {
+ cls = COLORS.underflow;
+ }
+ if (highlight.type === "clear" && array.length === 0) {
+ cls = COLORS.default;
+ }
+ }
+
+ return (
+
+
{String(value)}
+
#{array.length - idx}
+
+ );
+ })
+ )}
+