xxxxxxxxxx
36
//Make her listen to the question
//Make her respond with the headlines only close to you
var url = 'https://api.nytimes.com/svc/topstories/v2/world.json?api-key=a65aff26acee41528286255c6b07c42b';
var tuSuerte;
var img;
var article1;
function setup() {
article1=select ("#article1");
//document.getElementById("article1").innerHTML = "HELLO2";
//document.getElementById("article2").innerHTML = "HELLO4";
img = loadImage ('eyes.gif');
image(img, 0, 350);
loadJSON (url, gotData);
//Why is the button there?!
var button = createButton('ASK AWAY');
button.attribute ("allign", "left");
button.mousePressed(yourAnswer);
}
function yourAnswer (){
// Add more possible answers
createP ("I HAVE NO IDEA BUT " + tuSuerte);
}
function gotData (heads){
var randomHeads = int (random(0, heads.results.length));
println (randomHeads);
tuSuerte = heads.results[randomHeads].title;
//erase the previous result and place the new one
}
function draw() {
clear();
}