-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (28 loc) · 939 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
let text = document.getElementById("text")
const btnTMa = document.getElementById("btnTMa")
const btnTMi = document.getElementById("btnTMi")
const btnIMa = document.getElementById("btnIMa")
const btnClear = document.getElementById("btnClear")
btnTMa.addEventListener("click", allCaps)
btnTMi.addEventListener("click", allLowercase)
btnIMa.addEventListener("click", capitalInitial)
btnClear.addEventListener("click", allClear)
function allCaps() {
let textTwo = text.value
textTwo = textTwo.toUpperCase()
text.value = textTwo
}
function allLowercase() {
let textTwo = text.value
textTwo = textTwo.toLowerCase()
text.value = textTwo
}
function capitalInitial() {
let textTwo = text.value
//textTwo = textTwo.charAt(0).toUpperCase()+textTwo.slice(1)
textTwo = textTwo.replace(/\b\w/g, textTransform => textTransform.toUpperCase())
text.value = textTwo
}
function allClear() {
text.value = ''
}