-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathes5-warmup.html
More file actions
36 lines (34 loc) · 1.08 KB
/
es5-warmup.html
File metadata and controls
36 lines (34 loc) · 1.08 KB
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
34
35
36
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<main>
<div>bob</div>
<div>STEVE</div>
<div>sAlLY</div>
</main>
<script>
"use strict";
var name1 = {lName: "smith"}; // avoid using "name" as variable name, as its a build-in property/method
console.log(name1.lName);
document.querySelectorAll('div').forEach((div) => {
let newFirstName = captalizeFirstLetter(div.textContent);
let newLastName = captalizeFirstLetter(name1.lName);
div.innerText = newFirstName + ' ' + newLastName;
})
function captalizeFirstLetter(str) {
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); // str.substring(1).toLowerCase()
}
// let name = {lName: "smith"};
// console.log(name.lName);
// document.querySelectorAll('div').forEach((div) => {
// let newFirstName = captalizeFirstLetter(div.textContent);
// let newLastName = captalizeFirstLetter(name.lName);
// div.innerText = newFirstName + ' ' + newLastName;
// })
</script>
</body>
</html>