Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- let inputText = document.getElementById('arr').value;
- let inputArr = JSON.parse(inputText);
- inputArr.forEach((word, index, arr) => {
- arr[index] = word.split('').join('');
- });
- let b = inputText.split(',').map(Number);
- let sorted = b.sort((a, b) => a - b);
- console.log(b.sort()); //descending ERROR [NaN, Nan, Nan....] why ?
- console.log(inputArr.sort()); //alphabetically - correctly
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement