add the ip length test

This commit is contained in:
rloukil 2018-12-28 14:23:03 +01:00
parent c2ec4d1ca1
commit 72da607981

26
app.js
View file

@ -6,39 +6,41 @@ var date = []
var ipv4_v6 = []
function Ip4OrIp6(ipAddress){
console.log(ipAddress)
console.log(regex.test(ipAddress));
if(ipAddress.length == 39){
ipv4_v6.push(1);
}else{
ipv4_v6.push(-1);
}
}
// Refactor getStudents and getScores to return Promise for their response bodies
function getData(){
return fetch(`address.json`, {
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
}
}).then((response) => response.json())
};
getData().then((data)=>{
data.forEach(element => {
date.push(element.date)
date.push(element.date);
Ip4OrIp6(element.ip);
});
console.log(date);
data.forEach(element => {
Ip4OrIp6(element.ip)
})
console.log(ipv4_v6)
console.log(date);
console.log(ipv4_v6);
var ctx = document.getElementById("myChart").getContext('2d');
var chart = new Chart(ctx, {
type: 'line',
type: 'bar',
data: {
labels:date ,
datasets: [{
label: "Statistics for IPV4 and IPV6",
data: [1 , -1 , 1 , 1 , -1 , 1,1 , -1 , 1 , 1 , -1 ],
data:ipv4_v6,
}
]
},