最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - console output does not appear in code wars - Stack Overflow

programmeradmin2浏览0评论

I'm doing some javascript exercises on code wars. I want to see what's going wrong in my programs by printing to the console, but nothing except the test results appears in the output window. Does anyone know how to print to the console in code wars? I can't find anything in their documentation.

function areYouPlayingBanjo(name) {
  // Implement me
  var person = name.split('');
  person[0].toLowerCase();
  console.log(person[0]);
  if(person[0] === 'r'){
    return name + " plays banjo";
  }
  else{
    return name + " does not play banjo";
  }
}

I'm doing some javascript exercises on code wars. I want to see what's going wrong in my programs by printing to the console, but nothing except the test results appears in the output window. Does anyone know how to print to the console in code wars? I can't find anything in their documentation.

function areYouPlayingBanjo(name) {
  // Implement me
  var person = name.split('');
  person[0].toLowerCase();
  console.log(person[0]);
  if(person[0] === 'r'){
    return name + " plays banjo";
  }
  else{
    return name + " does not play banjo";
  }
}
Share Improve this question asked Dec 6, 2014 at 5:49 user137717user137717 2,1854 gold badges28 silver badges51 bronze badges 5
  • Without a code no one can help you – Just code Commented Dec 6, 2014 at 5:52
  • What value for name is being passed? – Arthur Weborg Commented Dec 6, 2014 at 5:56
  • 1 Rikke, rikke and Martin, but they all print name + " does not play banjo" I just want to know how to print to console in code wars because console.log isn't doing it – user137717 Commented Dec 6, 2014 at 5:58
  • @BatScream "ReferenceError: print is not defined at areYouPlayingBanjo" is what i get for print(person[0]); – user137717 Commented Dec 6, 2014 at 6:38
  • Okay, my bad ;-(, no print function. – BatScream Commented Dec 6, 2014 at 6:42
Add a ment  | 

2 Answers 2

Reset to default 1

This worked for me:

Console.Out.WriteLine("Print stuff to output here.");

This is not exactly an answer to the question, but more of an extended answer in order to document a chrome extension that can allow debugging in the console for codewars.

Install this chrome extension: https://github./bojan88/Codewars-JavaScript-debugger

This allows you to use the debugger; statement to force the your code to run in the browser rather than the sandboxed environment on the codewars servers. Works great.

Caveat: I don't know if this is safe. Use at your own risk.

发布评论

评论列表(0)

  1. 暂无评论