Filter for Year
using if statement,
Not Equal to
<html><head>
<title> Filter for Year using if statement, Not Equal To </title>
<meta charset="UTF-8">
<script src="record.js"></script>
</head>
<body>
<script>
function renderHtml()
{
var jsonOutputDiv = document.getElementById("theJsonOutput");
var output = '';
for(var i = 0; i < myRecord.length; i++)
{
if(myRecord[i].year != 2017)
{
output += myRecord[i].name + " ";
output += myRecord[i].height + '<br>';
//alert(JSON.stringify(myRecord[i]));
}
}
jsonOutputDiv.innerHTML = output;
}
</script>
<button id="insertIt" onclick="renderHtml()">Insert to page</button>
<div id="theJsonOutput"></div>
</body>
</html>
<title> Filter for Year using if statement, Not Equal To </title>
<meta charset="UTF-8">
<script src="record.js"></script>
</head>
<body>
<script>
function renderHtml()
{
var jsonOutputDiv = document.getElementById("theJsonOutput");
var output = '';
for(var i = 0; i < myRecord.length; i++)
{
if(myRecord[i].year != 2017)
{
output += myRecord[i].name + " ";
output += myRecord[i].height + '<br>';
//alert(JSON.stringify(myRecord[i]));
}
}
jsonOutputDiv.innerHTML = output;
}
</script>
<button id="insertIt" onclick="renderHtml()">Insert to page</button>
<div id="theJsonOutput"></div>
</body>
</html>
//save as record.js
var myRecord = [
{
name: "Key",
height: "5 feet 9 3/4 inches",
weight: 140,
eyeColor: "Brown",
nationality: "French, Irish",
year: 2016
},
{
name: "Donald",
height: "6 feet 4 inches",
weight: 160,
eyeColor: "Blue",
nationality: "Ukrainian, French",
year: 2015
}
];
var myRecord = [
{
name: "Key",
height: "5 feet 9 3/4 inches",
weight: 140,
eyeColor: "Brown",
nationality: "French, Irish",
year: 2016
},
{
name: "Donald",
height: "6 feet 4 inches",
weight: 160,
eyeColor: "Blue",
nationality: "Ukrainian, French",
year: 2015
}
];