JS - iaccess - ES6 (3)

PHOTO EMBED

Sat Oct 19 2024 09:46:50 GMT+0000 (Coordinated Universal Time)

Saved by @signup #html #javascript

var fs = require('fs');

// Read the input from the file
var input = fs.readFileSync('input.txt').toString().trim();

// Convert the input into an array of numbers
var array = input.split('\n').map(Number).filter(Boolean);

// Sort the array in ascending order
var sortedArray = array.sort((a, b) => a - b);

// Print each element in the sorted array
sortedArray.forEach(num => console.log(num));
content_copyCOPY