Skip to content

Commit db38ce9

Browse files
committed
demo code changed
getPersonAboveAge function added printArray functiojn added init function no longer update dom, colling those function insted
1 parent 5bdccc7 commit db38ce9

File tree

4 files changed

+54
-23
lines changed

4 files changed

+54
-23
lines changed

Allfiles/Mod03/Democode/Lesson01/HtmlBasic/HtmlBasic/HtmlBasic.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@
9494
<Content Include="Content\Site.css" />
9595
<Content Include="fonts\glyphicons-halflings-regular.svg" />
9696
<Content Include="Global.asax" />
97+
<Content Include="index.html" />
9798
<Content Include="Scripts\indexScript.js" />
9899
<Content Include="Scripts\modernizr-2.6.2.js" />
99100
<Content Include="Web.config" />
100101
</ItemGroup>
101102
<ItemGroup>
102103
<Compile Include="App_Start\RouteConfig.cs" />
103-
<Compile Include="Controllers\HomeController.cs" />
104104
<Compile Include="Global.asax.cs">
105105
<DependentUpon>Global.asax</DependentUpon>
106106
</Compile>
@@ -124,6 +124,7 @@
124124
</ItemGroup>
125125
<ItemGroup>
126126
<Folder Include="App_Data\" />
127+
<Folder Include="Controllers\" />
127128
<Folder Include="Models\" />
128129
</ItemGroup>
129130
<PropertyGroup>

Allfiles/Mod03/Democode/Lesson01/HtmlBasic/HtmlBasic/Scripts/indexScript.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,33 @@
2626
age: 25,
2727
2828
}]
29+
const age = 20;
2930

30-
let personAboveAge = [];
3131

32-
let personListString = '';
33-
let personAboveListString = '';
32+
console.log('persons List')
33+
printArray(personsLst);
3434

35-
for (let person of personsLst) {
36-
personListString += `<li>${person.name} (${person.age}) <br />${person.email}</li>`;
37-
}
35+
const personAboveAge = getPersonsAboveAge(personsLst, age);
36+
console.log(`persons Above ${age} List`)
37+
printArray(personAboveAge);
38+
}
39+
40+
init();
41+
42+
function getPersonsAboveAge(array, age) {
43+
const personAboveAge = [];
3844

39-
for (let person of personsLst) {
45+
for (let person of array) {
4046

41-
if (person.age >= 20) {
47+
if (person.age >= age) {
4248
personAboveAge.push(person);
4349
}
4450
}
51+
return personAboveAge;
52+
}
4553

46-
for (let i = 0; i < personAboveAge.length; i++) {
47-
personAboveListString += `<li>${personAboveAge[i].name} (${personAboveAge[i].age}) <br />${personAboveAge[i].email}</li>`;
54+
function printArray(array) {
55+
for (let i = 0; i < array.length; i++) {
56+
console.log(`${array[i].name} (${array[i].age}) ${array[i].email}`);
4857
}
49-
50-
51-
const personOl = document.getElementById('personList');
52-
personOl.innerHTML = personListString;
53-
const personAbove = document.getElementById('personAboveList');
54-
personAbove.innerHTML = personAboveListString;
5558
}
56-
57-
init();
58-

Allfiles/Mod03/Democode/Lesson01/HtmlBasic/HtmlBasic/Views/Home/Index.cshtml renamed to Allfiles/Mod03/Democode/Lesson01/HtmlBasic/HtmlBasic/Views/Home/Index.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<h3>All persons</h3>
22
<ol id="personList"></ol>
33

4-
<h3>Persons of age 20 and above</h3>
5-
<ol id="personAboveList"></ol>
6-
74
<script src="~/Scripts/indexScript.js"></script>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>HTML Basic</title>
7+
<link href="/Content/Site.css" rel="stylesheet" type="text/css" />
8+
<link href="/Content/bootstrap.min.css" rel="stylesheet" type="text/css" />
9+
<script src="/Scripts/modernizr-2.6.2.js"></script>
10+
<script src="/Scripts/indexScript.js"></script>
11+
</head>
12+
<body>
13+
<div class="navbar navbar-inverse navbar-fixed-top">
14+
<div class="container">
15+
<div class="navbar-header">
16+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
17+
<span class="icon-bar"></span>
18+
<span class="icon-bar"></span>
19+
<span class="icon-bar"></span>
20+
</button>
21+
22+
</div>
23+
<div class="navbar-collapse collapse">
24+
<ul class="nav navbar-nav"></ul>
25+
</div>
26+
</div>
27+
</div>
28+
29+
<div class="container body-content">
30+
31+
</div>
32+
</body>
33+
</html>

0 commit comments

Comments
 (0)