Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
The general structure of a Codewars problem is that the tests call your function with dfferent inputs and check that it returns the correct value.
This is for consistency (it would be bad UX if some Kata expected you to write to console, and others expected you to return a value, etc. The reason for this being the chosen format is that most langauges unit-testing libraries are structured like this, making test writing for most of them easier.
It said you were wrong because you are expected to return a value, not print to console.
The
evenOrOdd
function was there in initial solution setup when you enter the trainer for the first time for this kata, or click RESET. When I enter the trainer, I see this stub:I think it was presented to you too, but you didnt know how to use it, so you deleted it and replaced with your code. Is this possible?
Did you check the page I linked? Is it understandable?
Description: "Create a function",
OP: pRoMpT()
Did you bypass the coding challenge to be able to register here somehow? It should've showed you that you're meant to write functions that return things to solve katas. Additionally, when you enter a kata, you should see a template of the function you need to write. Ignoring all these things leads you exactly where you are.
You are right, and you are wrong.
You are right that there can be more than one way to solve a problem. There is more than one algorithm to determine whether a number is odd or even, and your algorithm is a good one.
You are wrong that you can write whatever you want and it should be accepted, because when programming, your code usually has to conform to some interfaces or protocols. It can work however you like (almost), but it needs to communicate with other parts of the system in a predetermined way. You can rant as much as you want, but this doesn't change the fact that your code does not do that: it does not conform to general requirements of a Codewars solution. And it's not problem with just Codewars, because whatever code you are going to ever write, it has to fit into other places of the system like a jigsaw.
For some details, please check if this article is helpful.