Skip to main content
Code Review

Return to Answer

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

Really not much to review, here. I think you did a pretty good job. There are a few points I'd like to make, though:

  • Indents in Javascript (at least as far as I've seen) are four spaces, not two.
  • When you're continuing a line, you indent twice; this applies to things like where you defined scales.
  • (削除) Use || in place of | wherever possible. Functionally identicaly, but it's a free little performance boost at no cost. (削除ここまで) Oops! turns out that's wrong. Thanks to @Flambino for pointing that out pointing that out. I was just thinking in terms of logical operators, not bitwise ones. However, I would recommend using Math.floor instead of it; it's clearer.
  • Rather than using array[array.length] = ..., use array.push(...). Much cleaner.
  • You never seem to handle negative numbers. See below for how you could do that without changing lots of your code.

One big point: Your toWords function should do everything itself. You shouldn't have to call chunkify, then map, then map again, then filter, etc. etc. Wrap all that in a function and you'll be golden. Plus, that lets you do fancy stuff like handle negative numbers -- for example, this (should) do the trick:

function toWords(n) {
 var asString = chunkify(n).map(toWords).map(scalify).filter(notEmpty).reverse().join(", ");
 if (n < 0) {
 asString = "negative " + asString;
 }
 return asString
}

Anyway, that's about it! Nicely written.

Really not much to review, here. I think you did a pretty good job. There are a few points I'd like to make, though:

  • Indents in Javascript (at least as far as I've seen) are four spaces, not two.
  • When you're continuing a line, you indent twice; this applies to things like where you defined scales.
  • (削除) Use || in place of | wherever possible. Functionally identicaly, but it's a free little performance boost at no cost. (削除ここまで) Oops! turns out that's wrong. Thanks to @Flambino for pointing that out. I was just thinking in terms of logical operators, not bitwise ones. However, I would recommend using Math.floor instead of it; it's clearer.
  • Rather than using array[array.length] = ..., use array.push(...). Much cleaner.
  • You never seem to handle negative numbers. See below for how you could do that without changing lots of your code.

One big point: Your toWords function should do everything itself. You shouldn't have to call chunkify, then map, then map again, then filter, etc. etc. Wrap all that in a function and you'll be golden. Plus, that lets you do fancy stuff like handle negative numbers -- for example, this (should) do the trick:

function toWords(n) {
 var asString = chunkify(n).map(toWords).map(scalify).filter(notEmpty).reverse().join(", ");
 if (n < 0) {
 asString = "negative " + asString;
 }
 return asString
}

Anyway, that's about it! Nicely written.

Really not much to review, here. I think you did a pretty good job. There are a few points I'd like to make, though:

  • Indents in Javascript (at least as far as I've seen) are four spaces, not two.
  • When you're continuing a line, you indent twice; this applies to things like where you defined scales.
  • (削除) Use || in place of | wherever possible. Functionally identicaly, but it's a free little performance boost at no cost. (削除ここまで) Oops! turns out that's wrong. Thanks to @Flambino for pointing that out. I was just thinking in terms of logical operators, not bitwise ones. However, I would recommend using Math.floor instead of it; it's clearer.
  • Rather than using array[array.length] = ..., use array.push(...). Much cleaner.
  • You never seem to handle negative numbers. See below for how you could do that without changing lots of your code.

One big point: Your toWords function should do everything itself. You shouldn't have to call chunkify, then map, then map again, then filter, etc. etc. Wrap all that in a function and you'll be golden. Plus, that lets you do fancy stuff like handle negative numbers -- for example, this (should) do the trick:

function toWords(n) {
 var asString = chunkify(n).map(toWords).map(scalify).filter(notEmpty).reverse().join(", ");
 if (n < 0) {
 asString = "negative " + asString;
 }
 return asString
}

Anyway, that's about it! Nicely written.

Added some stuff about negatives.
Source Link
anon
anon

Really not much to review, here. I think you did a pretty good job. There are a few points I'd like to make, though:

  • Indents in Javascript (at least as far as I've seen) are four spaces, not two.
  • When you're continuing a line, you indent twice; this applies to things like where you defined scales.
  • (削除) Use || in place of | wherever possible. Functionally identicaly, but it's a free little performance boost at no cost. (削除ここまで) Oops! turns out that's wrong. Thanks to @Flambino for pointing that out. I was just thinking in terms of logical operators, not bitwise ones. However, I would recommend using Math.floor instead of it; it's clearer.
  • Rather than using array[array.length] = ..., use array.push(...). Much cleaner.
  • You never seem to handle negative numbers. See below for how you could do that without changing lots of your code.

One big point: Your toWords function should do everything itself. You shouldn't have to call chunkify, then map, then map again, then filter, etc. etc. Wrap all that in a function and you'll be golden. Plus, that lets you do fancy stuff like handle negative numbers -- for example, this (should) do the trick:

function toWords(n) {
 var asString = chunkify(n).map(toWords).map(scalify).filter(notEmpty).reverse().join(", ");
 if (n < 0) {
 asString = "negative " + asString;
 }
 return asString
}

Anyway, that's about it! Nicely written.

Really not much to review, here. I think you did a pretty good job. There are a few points I'd like to make, though:

  • Indents in Javascript (at least as far as I've seen) are four spaces, not two.
  • When you're continuing a line, you indent twice; this applies to things like where you defined scales.
  • (削除) Use || in place of | wherever possible. Functionally identicaly, but it's a free little performance boost at no cost. (削除ここまで) Oops! turns out that's wrong. Thanks to @Flambino for pointing that out. I was just thinking in terms of logical operators, not bitwise ones. However, I would recommend using Math.floor instead of it; it's clearer.
  • Rather than using array[array.length] = ..., use array.push(...). Much cleaner.

One big point: Your toWords function should do everything itself. You shouldn't have to call chunkify, then map, then map again, then filter, etc. etc. Wrap all that in a function and you'll be golden.

Anyway, that's about it! Nicely written.

Really not much to review, here. I think you did a pretty good job. There are a few points I'd like to make, though:

  • Indents in Javascript (at least as far as I've seen) are four spaces, not two.
  • When you're continuing a line, you indent twice; this applies to things like where you defined scales.
  • (削除) Use || in place of | wherever possible. Functionally identicaly, but it's a free little performance boost at no cost. (削除ここまで) Oops! turns out that's wrong. Thanks to @Flambino for pointing that out. I was just thinking in terms of logical operators, not bitwise ones. However, I would recommend using Math.floor instead of it; it's clearer.
  • Rather than using array[array.length] = ..., use array.push(...). Much cleaner.
  • You never seem to handle negative numbers. See below for how you could do that without changing lots of your code.

One big point: Your toWords function should do everything itself. You shouldn't have to call chunkify, then map, then map again, then filter, etc. etc. Wrap all that in a function and you'll be golden. Plus, that lets you do fancy stuff like handle negative numbers -- for example, this (should) do the trick:

function toWords(n) {
 var asString = chunkify(n).map(toWords).map(scalify).filter(notEmpty).reverse().join(", ");
 if (n < 0) {
 asString = "negative " + asString;
 }
 return asString
}

Anyway, that's about it! Nicely written.

Fixed an error
Source Link
anon
anon

Really not much to review, here. I think you did a pretty good job. There are a few points I'd like to make, though:

  • Indents in Javascript (at least as far as I've seen) are four spaces, not two.
  • When you're continuing a line, you indent twice; this applies to things like where you defined scales.
  • Use(削除) Use || in place of | wherever possible. Functionally identicaly, but it's a free little performance boost at no cost. (削除ここまで) Oops! turns out that's wrong. Thanks to @Flambino for ||pointing that out . I was just thinking in placeterms of logical operators, not bitwise ones. However, I would recommend using |Math.floor wherever possible. Functionally identicaly, butinstead of it; it's a free little performance boost at no costclearer.
  • Rather than using array[array.length] = ..., use array.push(...). Much cleaner.

One big point: Your toWords function should do everything itself. You shouldn't have to call chunkify, then map, then map again, then filter, etc. etc. Wrap all that in a function and you'll be golden.

Anyway, that's about it! Nicely written.

Really not much to review, here. I think you did a pretty good job. There are a few points I'd like to make, though:

  • Indents in Javascript (at least as far as I've seen) are four spaces, not two.
  • When you're continuing a line, you indent twice; this applies to things like where you defined scales.
  • Use || in place of | wherever possible. Functionally identicaly, but it's a free little performance boost at no cost.
  • Rather than using array[array.length] = ..., use array.push(...). Much cleaner.

One big point: Your toWords function should do everything itself. You shouldn't have to call chunkify, then map, then map again, then filter, etc. etc. Wrap all that in a function and you'll be golden.

Anyway, that's about it! Nicely written.

Really not much to review, here. I think you did a pretty good job. There are a few points I'd like to make, though:

  • Indents in Javascript (at least as far as I've seen) are four spaces, not two.
  • When you're continuing a line, you indent twice; this applies to things like where you defined scales.
  • (削除) Use || in place of | wherever possible. Functionally identicaly, but it's a free little performance boost at no cost. (削除ここまで) Oops! turns out that's wrong. Thanks to @Flambino for pointing that out . I was just thinking in terms of logical operators, not bitwise ones. However, I would recommend using Math.floor instead of it; it's clearer.
  • Rather than using array[array.length] = ..., use array.push(...). Much cleaner.

One big point: Your toWords function should do everything itself. You shouldn't have to call chunkify, then map, then map again, then filter, etc. etc. Wrap all that in a function and you'll be golden.

Anyway, that's about it! Nicely written.

deleted 98 characters in body
Source Link
anon
anon
Loading
Source Link
anon
anon
Loading
default

AltStyle によって変換されたページ (->オリジナル) /