I have an object named myInfo
var myInfo = { skills: ['PHP', 'Java', 'JavaScript', 'HTML', 'CSS', 'jQuery'], languages: ['English', 'German'] } And I want to loop over the strings inside the skills array which is inside the myInfo object. I've tried this but doesn't seem to work
var mySkills = ''; for (i=0, i < myInfo.skills.length, i++) { mySkills += 'li' + myInfo.skills + 'li'; } document.write(mySkills); Any help will be appreciated. Maybe I went wrong somewhere in the code.
;in between the options instead of,. Second, you're not using the i, so isntead ofmyInfo.skillsshould bemyInfo.skills[i]. Thirdly, if you want to use strings to create newlido `<'li>' + myInfo.skills + '</li>'var mySkills = myInfo.skills.map(skill => 'li' + skill + 'li')will produce: ["liPHPli","liJavali"...]. Since this was marked as duplicate, I couldn't post an answer. Also, note that "Arrow Functions," the(skill) => 'li' + skill + 'li'part (short forfunction(skill){ return 'li'+skill+'li' }) won't work in IE (of course), but will work in Edge, for what it's worth.