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
Is it me or is it a bug?
[ 15, 125, 8 ]
product = 15000
pairs = { '0': 1 }
singles = ['0', '1', '5' ]
highest single = 5
result = 050
= 5
✘ Expected: 8, instead got: 5
Everything worked except for the last test, 300.11. The error it got was '✘ Expected: -300.10, instead got: -300.11' It's suppose to be 300.11, right? That's what my code returns, and it's wrong
My code is:
var numberToPrice = function(num) {
var sign = '';
num = ((Math.floor(num*100))/100).toFixed(2).toString()
if (num.slice(0,1) =='-') {
sign = num.split('').shift()
num = num.split('')
num.shift()
num = num.join('')
}
if (num.indexOf('.')>3) {
num = num.replace(/(\d{3}.)/g,',$1');
for (var i=0; i<(num.indexOf(',')); i++) {
num = num.replace(/(\d)(\d{3},)/g,'$1,$2')
}
}
return sign + num
}
Thanks for reading
Can someone please tell me how to "add print line" in my code to get the input? I can't debug my code until I figure out which tests my code failed!
This comment is hidden because it contains spoiler information about the solution
ok thanks!
Great training katas btw :)
This comment is hidden because it contains spoiler information about the solution