12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- // greeting
- let yourname = prompt("Write your name");
- alert("Hello, " + yourname) ;
- //gopnichek
- {
- let line = prompt("Write some text with ( , )")
- let result = line.split(",").join(",blin,")
- alert(result)
- }
- ///capitalize
- {
- let str = "cANbeBra"
- let result = str.split('')[0].toUpperCase() + str.slice(1,8).toLowerCase()
- console.log(result)
- alert(result)
- }
- //word count
- {
- let str = prompt("Write your sentence with space")
- let leng = str.split(' ').length
- console.log(leng)
- alert("Length is " + leng)
- }
- //Credentials
- {
- let firstname = prompt("Write your name")
- let surname = prompt("Write your surname")
- let thirdname = prompt("Write your thirdname")
- let padend = " "
- let result1 = firstname.split("")[0].toUpperCase() + firstname.slice(1,+Infinity).toLowerCase() + padend
- let result2 = surname.split("")[0].toUpperCase() + surname.slice(1,+Infinity).toLowerCase() + padend
- let result3 = thirdname.split("")[0].toUpperCase() + thirdname.slice(1,+Infinity).toLowerCase() + padend
- let fullname = (result1 + result2 + result3)
- alert(fullname)
- }
- //Beer
- {
- let str = "Было жарко. Василий пил пиво вприкуску с креветками"
- let firstcut = str.slice(0,24)
- let newword = "чай"
- let padend = " "
- let secondcut = str.slice(29,+Infinity)
- let newstr = firstcut + newword + padend + secondcut
- alert(newstr)
- }
- //No tag
- {
- let str = "какой-то текст в котором есть один тэг <br /> и всякое другое"
- let result = str.split('<br />').join('')
- alert(result)
- }
- //Big tag
- {
- let str = "какой-то текст в котором есть один тэг <br /> и всякое другое"
- let result = str.split('<br />').join('<BR />')
- alert(result)
- }
- //New line
- {
- let line = prompt("Write some text,you can use (\\n) for add new line")
- alert(line.split('\\n').join('\n'))
- }
|