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";
}
}
see this issue: http://www.codewars.com/users/Elistan/comments https://codewars.com/users/isbadawi/replies
from coding point of view first store the lower case value then compare:you need to do something like this:
function areYouPlayingBanjo(name) {
// Implement me
var person = name.split('');
console.log(person);
var x= person[0].toLowerCase();
console.log(person[0],x);// see difference here
if(x === 'r'){// if you will use person[0] it will not match from given input because it will be R
return name + " plays banjo";
}
else{
return name + " does not play banjo";
}
}
var out = areYouPlayingBanjo('Rikke, rikke and Martin');
console.log(out);
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.com/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.
Link about this question : https://www.codewars.com/kata/are-you-playing-banjo/train/javascript
const areYouPlayingBanjo = n => (n[0] == 'R' || n[0] == 'r') ? `${n} plays banjo` : `${n} does not play banjo` console.log(areYouPlayingBanjo("Martin"), "Martin does not play banjo"); console.log(areYouPlayingBanjo("Rikke"), "Rikke plays banjo");
This worked for me:
Console.Out.WriteLine("Print stuff to output here.");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.