Good day everyone!
I’m new on coding game. I have written some code solution for a puzzle, but I don’t know how to run test cases. The instruction at the bottom of the editor says “Write an answer using console.log()”. I’m use to just writing my codes and clicking run on other platforms like Repl.it, Please I need someone to help explain how I can run my codes here. Thank you.
Good day everyone!
If you have maximized your IDE frame you cannot see the test buttons. Restore frame to its smaller size. You will see buttons “PLAY TESTCASE”.
@java_coffee_cup asnwered the question well, but another tip.
People do not look at the forum too often, so responses may come a bit late, it is better to post questions in the “World” or your national chat for speedy answers.
Good Luck! hope to see you in a contest.
Thank you bro. I’ve seen the “PLAY TESTCASE”. But when I clicked it I don’t get the expected behavior. There’s a line of auto generated code at the bottom => console.log(“answer”) <= I replaced the ‘answer’ with my function a then clicked the “PLAY TESTCASE”. It displayed ‘failure: Found: nothing’. Please, am I doing it right? If no, how will I do it? Thank you
Okay sir. Please where can I find the ‘World’ section? Thank you
The chat bar should be on the right of your screen at all times provided you are level 3 or above, solving onboarding and the descent should unlock the chat for you.
When it says found nothing, it means that you did not print anything, it sounds like an error in your code rather than one in your testing method.
To know whether you are actually printing anything, use the debug output.
If you are writing in js, debug by
// To debug: console.error(‘Debug messages…’);
So, assume you have a variable ans containing your answer,
add a statement near the end
console.error(‘ans=’ + ans);
test run and find out what was printed by that extra command.
You can add similar debug messages to show the value of any intermediate variables in the middle of your processing.
I have seen the World chart window. Thank you
Thank you Java for your help, but I’m confused.
I’m doing the longest Palindrome puzzle. My answer is a function called longestPalindrome();
The function accepts a string ‘s’ like this: longestPalindrome(s) and outputs the longest palindrome within the string. After writing my code solution I’m normally suppose to invoke it at the end in order to run it like this… longestPalindrome(‘madam’);
I do exactly that but it tells me ‘found nothing’.
If I run the same code with the Test cases in an outside console like Google Chrome console or repl.it the code runs without a problem.
But here there’s no ‘Run’ button. Which means it is built-in somehow.
If I comment out every auto-generated code like the console.log(‘answer’) leaving only my codes and click PLAY ALL TESTCASES, it says ‘failure Found: Nothing’
If I replace ‘answer’ with my function ‘longestPalindrome(s)’ in console.log(‘answer’) at the bottom and click PLAY ALL TESTCASES, it also says ‘failure Found: Nothing’
Sorry to bother you but honestly I’m confused. How do I run my codes against the test cases?
Nothing found does not necessarily mean that you gave no ouput. It can also mean incomplete output.
For example, if he asked for the length of the palindrome as well,
Madam 5 is the answer, but you may print Madam
This will also give that error.
Another possible reason is that you timed out. It id quite possible that you timed out on the test case but given a greater time allowance offline, you printed the answer.
If you write console.log(your_function(s));
but got “Found Nothing” error, are you sure your_function() has something to return?
While having something to return is necessary, having enough data to return is also needed.
This puzzle requires one or multiple lines of output. If it expects two output lines but you write only one line, it will say “Found Nothing” while checking the second line.
Hi Java! The code solution is now successfully running against each test case.
The mistake I did was instead of putting each string for each test case in the function like this console.log(longestPalindrome(‘madam’)) I was busy writing this => console.log(longestPalindrome(s)),
There’s no issue now.
Thank you very much for your help. God bless you!
The issue has been resolved. Thanks for your help
Well done, hope to compete against you in the Fall Challenge
If you really have to hardcode the input string into the argument, instead of using a variable name, it doesn’t look good to pass any validators. Just click submit to see what happens.