Skip to content
Advertisement

Tag: numbers

I need to write difficult palindrome

That’s my example. String are given. Implement a function – detectPalindrom, that can detect palindrome string. Given argument not an string – return ‘Passed argument is not a string’. Given string is empty – return ‘String is empty’. Given string palindrome – return ‘This string is palindrome!’. Given string is not a palindrome – return ‘This string is not a

Mapping Array in Javascript with sequential numbers

The following code: Creates the following Array: I just don’t understand why. I can’t find anything on the internet that explains this behavior. Does anyone know why this works the way it does? Perhaps a link to some documentation? Answer creates an array of length 10 with all elements being undefined. will invoke Number.call for each element with the arguments

Convert number to alphabet letter

I want to convert a number to its corresponding alphabet letter. For example: Can this be done in javascript without manually creating the array? In php there is a range() function that creates the array automatically. Anything similar in javascript? Answer Yes, with Number#toString(36) and an adjustment.

parseInt() parses number literals with exponent incorrectly

I have just observed that the parseInt function doesn’t take care about the decimals in case of integers (numbers containing the e character). Let’s take an example: -3.67394039744206e-15 I expected that the parseInt will also return 0. What’s going on at lower level? Why does parseInt return 3 in this case (some snippets from the source code would be appreciated)?

Advertisement