Breaks with properties

by m4xout

HTML

<p id="demo"></p>

JavaScript

var swellDirection = "SE";
var windDirection = "W"


var breaks = [{
name:'Sandon Point', 
swell: ['S','SE'], 
wind: ['NW', 'W', 'SW']
},

{
name:'Bellambi', 
swell: ['E', 'SE'], 
wind: ['S', 'W', 'SW']
}

];

// Display some data from the object:
/*
document.getElementById("demo").innerHTML = breaks[1].name;

console.log(breaks);
console.log(breaks[1].name);
console.log(breaks[1].swell);

*/



// List breaks names


// Set the swell direction
//swellDirection = prompt("What is the swell direction?" );

var swellDirection = "E";
console.log('The swell direction has been set to ' + swellDirection);

/*
if ((breaks[1].swell) === "NE" || "E") {
console.log("swell matches");
} else {
console.log("not ok");
}

*/


for (var i in breaks) {
    if (breaks.hasOwnProperty(i)) {
       // console.log(i + " -> " + breaks[i].name);
       // console.log(i + " -> " + breaks[i].swell);
        for (var j in breaks[i].swell) {
            if (breaks[i].swell[j].hasOwnProperty(j)) {
                //console.log('yeh yeh');
               // console.log(breaks[i].swell[j])
               // console.log('i is equal to - ' + i )
              //  console.log('j is equal to - ' + j)
                if (swellDirection == breaks[i].swell[j]) {
                    console.log('We have a match with ' + breaks[i].name);
                   // console.log(breaks[i].swell[j])
                } else {
                   // console.log('We do not have a match with ' + breaks[i].name);
                   // console.log(breaks[i].swell[j])
                }
            } else {
              console.log('no no');
            }
        }
    }
}









// Set the wind direction
//windDirection = prompt("What is the wind direction?" );

// Show input results
//alert('The swell direction is ' + swellDirection + ' and the wind direction is ' + windDirection) ;

// Show breaks that match up with these conditions


// if(swellDirection == 'SE') {
// Show all breaks that work with SE swell
//}