third.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // greeting
  2. let yourname = prompt("Write your name");
  3. alert("Hello, " + yourname) ;
  4. //gopnichek
  5. {
  6. let line = prompt("Write some text with ( , )")
  7. let result = line.split(",").join(",blin,")
  8. alert(result)
  9. }
  10. ///capitalize
  11. {
  12. let str = "cANbeBra"
  13. let result = str.split('')[0].toUpperCase() + str.slice(1,8).toLowerCase()
  14. console.log(result)
  15. alert(result)
  16. }
  17. //word count
  18. {
  19. let str = prompt("Write your sentence with space")
  20. let leng = str.split(' ').length
  21. console.log(leng)
  22. alert("Length is " + leng)
  23. }
  24. //Credentials
  25. {
  26. let firstname = prompt("Write your name")
  27. let surname = prompt("Write your surname")
  28. let thirdname = prompt("Write your thirdname")
  29. let padend = " "
  30. let result1 = firstname.split("")[0].toUpperCase() + firstname.slice(1,+Infinity).toLowerCase() + padend
  31. let result2 = surname.split("")[0].toUpperCase() + surname.slice(1,+Infinity).toLowerCase() + padend
  32. let result3 = thirdname.split("")[0].toUpperCase() + thirdname.slice(1,+Infinity).toLowerCase() + padend
  33. let fullname = (result1 + result2 + result3)
  34. alert(fullname)
  35. }
  36. //Beer
  37. {
  38. let str = "Было жарко. Василий пил пиво вприкуску с креветками"
  39. let firstcut = str.slice(0,24)
  40. let newword = "чай"
  41. let padend = " "
  42. let secondcut = str.slice(29,+Infinity)
  43. let newstr = firstcut + newword + padend + secondcut
  44. alert(newstr)
  45. }
  46. //No tag
  47. {
  48. let str = "какой-то текст в котором есть один тэг <br /> и всякое другое"
  49. let result = str.split('<br />').join('')
  50. alert(result)
  51. }
  52. //Big tag
  53. {
  54. let str = "какой-то текст в котором есть один тэг <br /> и всякое другое"
  55. let result = str.split('<br />').join('<BR />')
  56. alert(result)
  57. }
  58. //New line
  59. {
  60. let line = prompt("Write some text,you can use (\\n) for add new line")
  61. alert(line.split('\\n').join('\n'))
  62. }