Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,825 members, 7,820,901 topics. Date: Wednesday, 08 May 2024 at 01:19 AM

Please I Need Help From A Good Javascript Programmer - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Please I Need Help From A Good Javascript Programmer (706 Views)

Lets Start A Real Web-deveopment Course Here Html+css+javascript+php+mysql / Were Can I Download Free Video Tutorials On Javascript Or Ruby / My Web Development Consultancy Thread(html, CSS, Javascript, Jquery, ASP.NET) (2) (3) (4)

(1) (Reply)

Please I Need Help From A Good Javascript Programmer by Weezyval(m): 11:31pm On Jun 29, 2015
please i need help...who can help me loop through this json object, i want to loop through the daily object using javascript but am having some difficulties.

my code
success: function(json) {
console.log(json);
$("#current_temp"wink.html(Math.round(json.currently.temperature)+"°F"wink;
$("#current_summary"wink.html(json.currently.summary);
$("#current_temp"wink.attr("data-icon",icons[json.currently.icon]+" "wink;
$("#timezone"wink.html(json.timezone);
var newDate = new Date();
newDate.setTime(json.currently.time*1000);
dateString = newDate.toUTCString();

document.getElementById("time"wink.innerHTML = newDate;
for ( var i = 0; i < daily.data.length; i++) {
var DOM = jQuery('#DOM');
var obj = data[i];
console.log(obj);
DOM.append("<li>"+obj.summary+"<li>"wink;
};

},
error: function(e) {
console.log(e.message);
}


I will be very gratefull if anyone can help me out. Thanks

the json object from the callback function

Object { latitude: 41.879003, longitude: -87.63675, timezone: "America/Chicago", offset: -5, currently: Object, minutely: Object, hourly: Object, daily: Object, alerts: Array[1], flags: Object }

the json Daily data structure(They are 8 in number) The second image is an expanded view of one of the daily object

Re: Please I Need Help From A Good Javascript Programmer by IamGodzilla: 1:36pm On Jun 30, 2015
I don't really understand how your code is, because of the way it's formatted.
But looking at the photo you attached.

to loop through an array [], you do this.

for (var i=0 i< daily.length; i++){
return daily[i]
}

And to loop through an object {}, you do this.

for(var key in object){
return object[key]
}

This is just an example of how you would loop. you probably are looping through an object using the array format.
Also where you have daily.data.length, try daily.data[i], however I would recommend you save it to a variable,

e.g var newVar = daily.data;
then you could do newVar.length

1 Like

Re: Please I Need Help From A Good Javascript Programmer by Weezyval(m): 9:49am On Jul 02, 2015
IamGodzilla:
I don't really understand how your code is, because of the way it's formatted.
But looking at the photo you attached.



to loop through an array [], you do this.


And to loop through an object {}, you do this.


This is just an example of how you would loop. you probably are looping through an object using the array format.
Also where you have daily.data.length, try daily.data[i], however I would recommend you save it to a variable,

ok' thanks a lot I appreciate

(1) (Reply)

Robots, Drones And Heart-detectors: How Disaster Technology Is Saving Lives / 7 Essential Improvements In Magento Commerce Cloud / Digital Marketing Consultant

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.