javascript - 洗牌列 2d 数组 javascript/typescript
问题描述
我正在尝试洗牌我的二维数组,但只有列。我有一个函数,它使用用户给出的字符串生成一个由字母和黑色正方形组成的二维数组(当我按下 0 时):
creerGrilleHaut(inputCitation: string) {
this.citation = inputCitation.trim();
for (var i = 0; i < this.citation.length; i++) {
if ([' ', ',', '-', '.', "'"].indexOf(this.citation[i]) >= 0) {
this.monArray.push(0);
} else {
this.monArray.push(this.citation[i].toUpperCase());
}
}
while (this.monArray.length) {
var monTableau = (this.monArray.splice(0, 13));
this.monArray2DHaut.push(monTableau);
}
this.nbLignes = this.citation.length / this.nbColonnes;
if (this.citation.length % this.nbColonnes != 0) {
this.nbLignes++;
}
}
结果:
L E C H A T N E S T
P A S L A L E S S
O U R I S D A N S E N T
我随机想要的:
L U R C S D L E S E N T
O E I L A A N E S T
L U S H A T N S S
解决方案
推荐阅读
- c++ - 如何做到这一点: Objet.getsObject().setssObject()
- php - cake php calling a function, but the controller wont execute it
- docker - Building Docker file
- dart - 颤振错误“无法导航到初始路线”
- reactjs - 如何使用axios分别调用七个api(s)进行反应
- javascript - 如何在对每个元素执行函数时循环遍历 HTML 元素
- networking - 在 Windows 中需要有关 tracert 的作业帮助
- identityserver4 - Identity server 4: intercept 302 and replace it with 401
- c# - Blazor app getting ERR_CONNECTION_RESET on dll file
- android - 如何在recyclerview xamarin android中更改textview的背景颜色