获得徽章 0
赞了这篇沸点
赞了这篇沸点
下班下班,加班的你需要检查检查身体,看看自己的眼镜,看看自己的头发,那脆弱的身体都是上班造成的,还加班,加个锤子,别被老板的饼撑着,身体是自己的,别到老了拿年轻赚的钱去治病,88
1
4
赞了这篇沸点
今天去面试被问到了这个题,jym,看看答案是什么:
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 = "";
for (let i = 0; i < arr.length; i++) {
for (j = 0; j < 30; j++) {
if (arr[i].indexOf(j) > -1) {
str += "█";
} else {
str += " ";
}
}
str += "\n";
}
return str;
}
console.log(demo(arr));
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 = "";
for (let i = 0; i < arr.length; i++) {
for (j = 0; j < 30; j++) {
if (arr[i].indexOf(j) > -1) {
str += "█";
} else {
str += " ";
}
}
str += "\n";
}
return str;
}
console.log(demo(arr));
展开
16
13
赞了这篇沸点
赞了这篇沸点
赞了这篇文章
![[流泪]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_6.dde0d83.png)
![[泣不成声]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_40.348108b.png)