Advertisement
DidiHristova93

Untitled

Jan 28th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. function solve() {
  2.  
  3. let inputText = document.getElementById('arr').value;
  4.  
  5. let inputArr = JSON.parse(inputText);
  6.  
  7. inputArr.forEach((word, index, arr) => {
  8. arr[index] = word.split('').join('');
  9. });
  10.  
  11. let b = inputText.split(',').map(Number);
  12. let sorted = b.sort((a, b) => a - b);
  13.  
  14.  
  15. console.log(b.sort()); //descending ERROR [NaN, Nan, Nan....] why ?
  16. console.log(inputArr.sort()); //alphabetically - correctly
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement