These are chat archives for FreeCodeCamp/Help

14th
Feb 2019
nsonhouse
@nsonhouse
Feb 14 03:34
Anybody ever query data from DB and write to a table?
kinopotato
@kinopotato
Feb 14 05:36
happy coding guys
kinopotato
@kinopotato
Feb 14 08:40
Hello, I was hoping to generate a table cell dynamically (td) and inside the table cell it will have <select><input><div> some texts, among others probably. Is there a way to quickly doing this? I thought innerHTML would work but it doesn't seem to work with tags
I seem to remember something that will work with tags, but I really thought that was innerHTML :|
Kranti Nebhwani
@darkphotonKN
Feb 14 09:22

Hey guys, I'm used to destructuring objects in javascript but I'm not sure about how it works with arrays, take this code for example:

.then(([rows, fieldData]) => {
      res.render('shop/index', {
        prods: rows,
        pageTitle: 'Shop',
        path: '/'
      });

What is it destructuring from the argument there inside the .then()? The rows and fieldData inside the array coming from the promise?

alpox
@alpox
Feb 14 09:36
@darkphotonKN If the function in .then is called with the array ["first", 35], rows will be "first" and fieldData will be 35
Kranti Nebhwani
@darkphotonKN
Feb 14 09:39
@alpox ah ok cuz im used to the destructuring being for objects where rows and fieldData are the exact property names inside the object, so I was wondering how that would work for an array. So for the array its simply getting the value based on POSITION, and naming that data with the name you gave
?
alpox
@alpox
Feb 14 09:39
@darkphotonKN Yes, the destructuring for arrays depends solely on the position
Kranti Nebhwani
@darkphotonKN
Feb 14 09:39
@alpox sweet i love how simple yet effective you described it, thanks dude
alpox
@alpox
Feb 14 09:40
@darkphotonKN No problem
kinopotato
@kinopotato
Feb 14 11:34
Hello, how do I add a bunch of html elements to the DOM easily? innerHTML doesn't work unless I do it to each element
alpox
@alpox
Feb 14 11:49
@kinopotato It can work if you add all elements to only one parent element
Otherwise you might want to use https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
kinopotato
@kinopotato
Feb 14 11:52
@alpox yes! took me a while to figure it out, but I manage to get innerHTML working by creating a div in the HTML portion and storing the info there. Now I just have to make that div invisible
Aditya Dehal
@aditya2000
Feb 14 17:58
Hey I need a little help with react. Thanks!
Christopher McCormack
@cmccormack
Feb 14 18:01
@aditya2000 hey best to just ask, or try the https://gitter.im/FreeCodeCamp/HelpJavaScript where several people use React