Run ยป
<!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> <script> const str = 'title of the document'; function capitalize(str) { return str.charAt(0).toUpperCase() + str.slice(1); } const caps = str.split(' ').map(capitalize).join(' '); alert(caps); </script> </body> </html>