hw08_04_!Credentials.html 747 B

1234567891011121314151617181920212223
  1. <header>
  2. <h1>Credentials</h1>
  3. </header>
  4. <body>
  5. <script>
  6. const capitalize = str => {
  7. str = str.toLowerCase().trim();
  8. let result = str[0].toUpperCase() + str.slice(1);
  9. return result;
  10. }
  11. const credentials = () => {
  12. let sName = capitalize(prompt("Enter surname"));
  13. let name = capitalize(prompt("Enter name"));
  14. let fatherName = capitalize(prompt("Enter father name"));
  15. let fullName = sName + ' ' + name + ' ' + fatherName;
  16. return { name, sName, fatherName, fullName };
  17. }
  18. let res = credentials();
  19. alert(res.name + "\n" + res.sName + "\n" + res.fatherName + "\n" + res.fullName);
  20. </script>
  21. </body>