get latest file from s3 bucket javascript

JavaScript
aws s3api list-objects-v2 --bucket "my-awesome-bucket" --query 'sort_by(Contents, &LastModified)[-1].Key' --output=text

Source

Also in JavaScript: