Closed mybearworld closed 4 months ago
That's weird - I didn't experience it while play testing. I'll look more into it in ~3 hours, thanks for reporting it.
Could you also provide your TypeScript code? That's probably not the issue, but in case it is it would make debugging easier.
Sure - this is my code (I've been trying to not buy anything):
function romanToInt(
str: string,
value: any = null,
lastCharacter: any = null,
iterator: any = null
) {
value ??= 0;
lastCharacter ??= null;
iterator ??= str.matchAll("." as any);
const characterObj = iterator.next();
const character = characterObj.value.pop() as string;
const currentCharacterValue = romanCharacterToInt(character);
const lastCharacterValue = romanCharacterToInt(lastCharacter);
(lastCharacter !== null &&
lastCharacterValue < currentCharacterValue &&
((value += currentCharacterValue - lastCharacterValue),
(value -= lastCharacterValue))) ||
((lastCharacter = character), (value += currentCharacterValue));
return characterObj.value.index === str.length - 1
? value
: romanToInt(str, value, lastCharacter, iterator);
}
function romanCharacterToInt(str: string) {
return (
(str === "I" && 1) ||
(str === "V" && 5) ||
(str === "X" && 10) ||
(str === "L" && 50) ||
(str === "C" && 100) ||
(str === "D" && 500) ||
(str === "M" && 1000) ||
0
);
}
console.log(romanToInt("MIX"));
Side note: if I had to guess, removing the types could fix your issue (X: int, for example)
Side note: if I had to guess, removing the types could fix your issue (X: int, for example)
That did fix it! Thanks!
Quite odd that it didn't error out with the fact that you had types. I'll still look into it when I have time, but glad you got it working :)
fixed in v1.0.1
I got this error when trying to solve the roman numeral task:
What does that mean? Do I need to do something in my code to avoid this?
(Sorry for making another issue...)