These are chat archives for FreeCodeCamp/Help

15th
Mar 2019
kinopotato
@kinopotato
Mar 15 03:58
why is async called async? from what I understand, async means while one thing is processing, it will do some other thing. . .which makes it synchronous right? the two processes are in sync.
abraham anak agung
@padunk
Mar 15 06:40
@kinopotato as usual, from SO
tundeiness
@tundeiness
Mar 15 08:28
@bjorno43 Thanks! it wasn't a test issue.
kinopotato
@kinopotato
Mar 15 12:10
so .map() ang Map() are different
kinopotato
@kinopotato
Mar 15 12:22
what's new Map() for? it's kinda weird
Philip Durbin
@pdurbin
Mar 15 12:23
Which language are you talking about?
kinopotato
@kinopotato
Mar 15 12:23
javascript
Philip Durbin
@pdurbin
Mar 15 12:24
Ok. What do the MDN docs say?
kinopotato
@kinopotato
Mar 15 12:24
let obj = new Map();
seems like it came with es6
"The Map object holds key-value pairs and remembers the original insertion order of the keys. Any value (both objects and primitive values) may be used as either a key or a value."
to me this just sounds like a normal object, but I really can't understand the significance of "original insertion order" or "may be used as either a key or a value"
kinopotato
@kinopotato
Mar 15 12:29
upper case, just found a medium article about it, apparently it's an instance of an object. whatever that means
coding is weird
kinopotato
@kinopotato
Mar 15 12:53
is there a database that supports Map data structure? it seems to be more convenient than an object (maybe)
Christopher McCormack
@cmccormack
Mar 15 13:36
@kinopotato similar to how MongoDB does it? https://docs.mongodb.com/manual/core/document/#document-field-order
Andrew Tait Gehrhardt
@atgehrhardt
Mar 15 13:42

Can anyone tell me why this doesn't execute. I'm pulling my hair out here.

function isNumber(value) { if (value = typeof 1) { return true; } if (value != typeof 1) { return false; } }

Christopher McCormack
@cmccormack
Mar 15 13:50
@atgehrhardt did you mean value ==? Also why are you comparing value to the type of an integer each time? It will always result in the string "number"
paulsda
@paulsda
Mar 15 13:54
hey guys, can anybody help me out with a minor CSS issue im having? I need to align some buttons to the right of the page. These buttons need to link off to the live demos or to code samples on github so I had to change them from regular <button> elements to form <submit> elements. Text-align:right worked fine when they were just <buttons> but now that they’re forms, text-align doesnt work anymore
Here’s a codepen of what I’m working on: https://codepen.io/paulsaada/pen/gEXmMJ
Christopher McCormack
@cmccormack
Mar 15 13:57
@paulsda most likely your CSS is no longer targeting the same specifiers, did you adjust them to add the form element in between?
@paulsda which buttons are you referring to?
paulsda
@paulsda
Mar 15 13:58
I’m positive I’m targeting the correct element with my CSS because I’ve made other style changes to these buttons
Christopher McCormack
@cmccormack
Mar 15 13:58
like the right aligned sections like Saada Studios Creative Agency ?
paulsda
@paulsda
Mar 15 13:58
The one’s in my portfolio that say “Live demo” and “code camples"
yeah those
Andrew Tait Gehrhardt
@atgehrhardt
Mar 15 13:59
@cmccormack honestly i'm not sure. I'm still learning and trying to create a function that checks if the value is a number or not.
Christopher McCormack
@cmccormack
Mar 15 13:59
ah then you probably want typeof value === "number"
Andrew Tait Gehrhardt
@atgehrhardt
Mar 15 14:01
@cmccormack Omg that worked thank you! I didn't realize it was literally printing the string 'number' this makes total sense now. I guess I should check things with console.log(). Thank you so much man.
Christopher McCormack
@cmccormack
Mar 15 14:02
@paulsda those are flex elements - add justify-content: flex-end; to just the ones you want on the right, should fix it
@atgehrhardt yes always log!
no better way to troubleshoot than to see what is stored in your variables when you're having an issue!
@paulsda also using a form action is kind of strange, why not just wrap your buttons in an a anchor tag?
paulsda
@paulsda
Mar 15 14:04
@cmccormack thanks so much Christopher, that fixed it lol. I just started learning flexbox the other day and I’m just now implementing it in my websites so i have some gaps in my knowledge currently
Christopher McCormack
@cmccormack
Mar 15 14:05
no problem
paulsda
@paulsda
Mar 15 14:06
Hmm, I was googling options for making buttons interactive and i found a question on stackoverflow and one of the most popular answers was a form submit solution
but i will try the <a> tags bc that makes more sense, thanks man
Christopher McCormack
@cmccormack
Mar 15 14:07
I'd like to see that article, because it's very common to use anchors. Perhaps we are missing context in that solution
@paulsda np :thumbsup:
Kaz Baig
@kbaig
Mar 15 14:07
Random q - if you want to make a button a link, would you style an a tag as a button, or would you wrap an a tag around a button
The latter would be for semantic reasons
I gotta start paying attention to the dates that some of these questions on stackoverflow are posted lol. this question was from 2011 so i assume the form submit solution is probably a super outdated method
Kaz Baig
@kbaig
Mar 15 14:10
I def wouldn't do that lol
Christopher McCormack
@cmccormack
Mar 15 14:10
huh I guess I never really thought of buttons as belonging to forms but I guess it kind of makes sense
@kbaig it's a good question, would need to know how accessible each choice was
paulsda
@paulsda
Mar 15 14:16
Another question, is there any way to use vanilla JS to complete a form action? I’m creating a contact form from scratch for the first time and I know nothing about PHP
Christopher McCormack
@cmccormack
Mar 15 14:17
this is pretty interesting
@paulsda sure, you can have a node server running
paulsda
@paulsda
Mar 15 14:19
interesting, thank you
i dont know node but i’ll definitely ask around in my network for help lol
Christopher McCormack
@cmccormack
Mar 15 14:20
it's JavaScript for the backend, a lot easier to write IMO than PHP
that said, there are tons of PHP templates for contact forms out there
I can send you mine if you want, just let me know
paulsda
@paulsda
Mar 15 14:23
so how does it work exactly? i deploy my html, css, and php files to my host and then what? do i need to pay for a server in order for the php file to reliably send the emails to my personal email address?
the only websites ive ever deployed are hosted on other platforms, never one that i built from scratch
Christopher McCormack
@cmccormack
Mar 15 14:24
You would need some mail software or code to handle sending the email
paulsda
@paulsda
Mar 15 14:25
Wait, im not understanding. isnt that what the php is for
Christopher McCormack
@cmccormack
Mar 15 14:26
I could be wrong, been forever since I set that up
paulsda
@paulsda
Mar 15 14:30
will i need to actually learn node to be able to implement this properly? Or do you think most junior devs could stumble thru nodemailer's documentation and figure out how to set it up to get it to working condition?
cause I’m not entirely done learning JS
Christopher McCormack
@cmccormack
Mar 15 14:31
probably easier to drop a php file on an apache server if you already have access
get the contact form working then move on with your studies
paulsda
@paulsda
Mar 15 14:34
got it, thanks for answering all my noob questions man
your insight is appreciated
🙏
Christopher McCormack
@cmccormack
Mar 15 14:36
np
kinopotato
@kinopotato
Mar 15 16:26

any idea why this is returning [object HTMLDocument]?

//function to create li element
const parser = new DOMParser();
const newLi = (userInput) => {
  console.log(typeof userInput)
  let finalInput = `${userInput} wowo`
  let li = parser.parseFromString(finalInput, "text/html");
  return input.value = li;
}

submit.addEventListener("click", () => newLi(input.value) );

supposed to create new LI elements but now just testing it because I can't get it to work.
right now it's supposed to change anything in the input box to add wowo, but I'm getting the html document

Christopher McCormack
@cmccormack
Mar 15 16:36
you're returning an assignment, the result of the assignment expression is the value you assigned, li, so you are returning li
kinopotato
@kinopotato
Mar 15 16:38
but there's no <li> on that function
it's supposed to have <li>, but I can't get that to work so I'm just doing text,
Christopher McCormack
@cmccormack
Mar 15 16:41
I don't know what you mean
I'm just looking at your code
you literally have a variable called li
kinopotato
@kinopotato
Mar 15 16:41
oh, sorry, I thought you meant <li>
Christopher McCormack
@cmccormack
Mar 15 16:41
nope
TheCodingAlien
@TheCodingAlien
Mar 15 16:51
hi im struggling with my server.js file
when it's 'listening'
none of my source code comes up
image.png
it should be a questionnaire that appears
with all my questions
e.g.
image.png
could i send someone the source code please? it would help me so much
Christopher McCormack
@cmccormack
Mar 15 16:53
can you put it in a glitch.com app? Is this version controlled with git?
If you have it on github you can import it into heroku/glitch so we can test and play with it