Skip to main content
added 7 characters in body
Source Link
200_success
  • 144.2k
  • 22
  • 188
  • 473

That looks like a classic case for a lookup table. This function should be a one-liner.

We know that parameters are inputs. What kind of input? Also, the input isn't Arabic; it's just abstractly a number. It would be better to rename the parameter and function to number.

function numberToGreek(number) {
    return "αβγδεϝζηθι".charAt(number - 1);
}

That looks like a classic case for a lookup table. This function should be a one-liner.

We know that parameters are inputs. What kind of input? Also, the input isn't Arabic; it's just abstractly a number. It would be better to rename the parameter and function to number.

function numberToGreek(number) {
    "αβγδεϝζηθι".charAt(number - 1);
}

That looks like a classic case for a lookup table. This function should be a one-liner.

We know that parameters are inputs. What kind of input? Also, the input isn't Arabic; it's just abstractly a number. It would be better to rename the parameter and function to number.

function numberToGreek(number) {
    return "αβγδεϝζηθι".charAt(number - 1);
}
Source Link
200_success
  • 144.2k
  • 22
  • 188
  • 473

That looks like a classic case for a lookup table. This function should be a one-liner.

We know that parameters are inputs. What kind of input? Also, the input isn't Arabic; it's just abstractly a number. It would be better to rename the parameter and function to number.

function numberToGreek(number) {
    "αβγδεϝζηθι".charAt(number - 1);
}