首页 > 试题广场 >

编程题

[编程题]编程题
  • 热度指数:362 时间限制:C/C++ 5秒,其他语言10秒 空间限制:C/C++ 256M,其他语言512M
  • 算法知识视频讲解
var a = ["Welcome", "to", "Lexin", "!"];
var b = ["Let", "us", "make", "the", "future", "together", "!"];
请用console.log打印,通过a和b两个变量组合成以下内容(注意:两句话中间需要换行,单词之间需要用空格进行分割):
Welcome to Lexin !
Let us make the future together !

备注:后期会人工阅卷打分;请务必点击“保存并调试”按钮保存答案,但不必以运行结果为准。

输入描述:


输出描述:
Welcome to Lexin !
Let us make the future together !
 var a = ["Welcome""to""Lexin""!"];
 var b = ["Let""us""make""the""future""together""!"];
 console.log(a.join(' '+ '\n' + b.join(' '))
发表于 2020-09-09 18:27:32 回复(0)
console.log(`${a.join(' ')}\n${b.join(' ')}`)
发表于 2020-03-06 14:33:45 回复(0)
function demo(a) {
  let txt = ""
  a.map(item => {
      txt += item + ' '
  })
  console.log(txt)
}
demo(["Welcome", "to", "Lexin", "!"])
demo(["Let", "us", "make", "the", "future", "together", "!"])
发表于 2020-01-07 10:56:15 回复(0)
console.log(...a);
console.log(...b);

发表于 2021-02-09 14:32:09 回复(0)
vara = ["Welcome", "to", "Lexin", "!"];
varb = ["Let", "us", "make", "the", "future", "together", "!"];
txt="",
txt1=""
for(vark ina){
  txt += a[k]+" "
}
for(vari inb){
  txt1 += b[i]+" "
}
varresult=txt+'\n'.concat(txt1)
console.log(result);


发表于 2020-08-10 10:06:21 回复(0)

a.concat(b).join(" ")

编辑于 2020-07-27 14:02:46 回复(0)

for of  + 字符串拼接

    var a = ["Welcome", "to", "Lexin", "!"];
    var b = ["Let", "us", "make", "the", "future", "together", "!"];
    var result = ''
    for (var i of a) {
      result += i + " "
    }
    result += '\n'
    for (var i of b) {
      result += i + " "
    }
    console.log(result);

编辑于 2020-02-14 12:50:14 回复(0)