Skip to content

Commit 9c5322a

Browse files
committed
Updated to ES6
1 parent 6b93492 commit 9c5322a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

script.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//Update the text in the output textArea
2-
function updateText() {
2+
updateText = () => {
33
let input = document.getElementById("text-input").value;
44
document.getElementById("text-output").innerText = input;
55
}
66

7-
function makeBold(elem) {
7+
makeBold = (elem) => {
88
//elem is the Bold button element
99
//Toggle the .active class (Bootstrap class)
1010
elem.classList.toggle("active");
@@ -13,12 +13,12 @@ function makeBold(elem) {
1313
document.getElementById("text-output").classList.toggle("bold");
1414
}
1515

16-
function makeItalic(elem) {
16+
makeItalic = (elem) => {
1717
elem.classList.toggle("active");
1818
document.getElementById("text-output").classList.toggle("italic");
1919
}
2020

21-
function makeUnderline(elem) {
21+
makeUnderline = (elem) => {
2222
elem.classList.toggle("active");
2323
let output = document.getElementById("text-output");
2424
if (output.classList.contains("underline")) {
@@ -28,16 +28,16 @@ function makeUnderline(elem) {
2828
}
2929
}
3030

31-
function alignText(elem, alignType) {
31+
alignText = (elem, alignType) => {
3232
let output = document.getElementById("text-output");
3333
output.style.textAlign = alignType;
3434

3535
/* If one align button is active, make other align buttons inactive */
3636
//All the align buttons have class name as ALIGN
3737
let buttonList = document.getElementsByClassName("align");
38-
for (let i = 0; i < buttonList.length; i++) {
38+
for (let button of buttonList) {
3939
//Remove .active class from all align buttons
40-
buttonList[i].classList.remove("active");
40+
button.classList.remove("active");
4141
}
4242

4343
//Make the seleceted align button active

0 commit comments

Comments
 (0)