[JavaScript] 纯文本查看 复制代码 function printGridWord(word) {
const characterGrid = createCharacterGrid(word);
if (characterGrid) {
for (let rowNum = 0; rowNum < characterGrid.length; rowNum++) {
let rowString = "";
for (let colNum = 0; colNum < characterGrid[rowNum].length; colNum++)
{rowString += characterGrid[rowNum][colNum] + " ";
}
return rowString
}
} else {
console.log("无法生成回宫格字!");
}
}
function createCharacterGrid(word) {
if (word.length === 4) {
const topLeft = word.charAt(0);
const topRight = word.charAt(1);
const bottomLeft = word.charAt(2);
const bottomRight = word.charAt(3);
const characterGrid = [[topLeft, topRight], [bottomLeft, bottomRight], [bottomRight, bottomLeft], [topRight, topLeft], ];
return characterGrid;
} else {
return null;
}
}
.版本 2
.程序集 程序集1
.子程序 _启动子程序, 整数型, , 本子程序在程序启动后最先执行
V8.InitializeV8 ()
调试输出 (WT_JS_Eval (#常量1))
返回 (0) ' 可以根据您的需要返回任意数值
.子程序 WT_JS_Eval, 文本型, , WT-JS_DEBUG
.参数 script, 文本型, , 常量JS脚本
.参数 word, 文本型, 可空, 参数1
.局部变量 ret, 文本型
ret = v8.ExecJavaScriptV8 (script, “printGridWord("+#引号+word+#引号+")”, 真, 真)
返回 (ret)
|