V50js代码

依然范儿特西
2022-11-10 / 0 评论 / 14 阅读 / 正在检测是否收录...

疯狂星期四, v50

let arr = [
        [1, 9, 12, 13, 14, 15, 16, 18, 19, 20, 21, 22],
        [2, 8, 12, 18, 22],
        [3, 7, 12, 13, 14, 15, 16, 18, 22],
        [4, 6, 16, 18, 22],
        [5, 5, 12, 13, 14, 15, 16, 18, 19, 20, 21, 22],
    ];

    function demo(arr) {
        let str = "";
        let style=[];
        for (let i = 0; i < arr.length; i++) {
            for (j = 0; j < 30; j++) {
                if (arr[i].indexOf(j) > -1) {
                    str += "%c█";
                    style.push(j< 12 ? "color:red" : "color:green")
                } else {
                    str += " ";
                }
            }
            str += "\n";
        }
        return [str,...style];
    }
    console.log(...demo(arr));
0

评论 (0)

取消