Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Sort an Array Alphabetically</title> </head> <body> <script> let fruits = ["Banana", "Orange", "Apple", "Papaya", "Mango"]; let sorted = fruits.sort(); document.write(fruits + "<br>"); // Outputs: Apple,Banana,Mango,Orange,Papaya document.write(sorted); // Outputs: Apple,Banana,Mango,Orange,Papaya </script> </body> </html>