These are chat archives for FreeCodeCamp/Help

15th
Nov 2018
Jason Luboff
@JLuboff
Nov 15 2018 00:00
Ya, seems like it would but I have a feeling it gives you a different url each time you start it so that may present an issue
dyon gerwen
@fullstackinprogress_gitlab
Nov 15 2018 00:01
@JLuboff i am trying with it but still same error it work though the link is now my localhost
but only the error still exist
Jason Luboff
@JLuboff
Nov 15 2018 00:02
Not sure, I've never tried that module
dyon gerwen
@fullstackinprogress_gitlab
Nov 15 2018 00:02
do you have an alternive one you worked with ?
Jason Luboff
@JLuboff
Nov 15 2018 00:03
Nope... always run non-secure for local dev. Never had a need to make it secure
dyon gerwen
@fullstackinprogress_gitlab
Nov 15 2018 00:03
@JLuboff also for the facebook login ?
facebook needs a in devlopment mode its a shame that i have to go through all this headache
Jason Luboff
@JLuboff
Nov 15 2018 00:05
is this for passport.js? I had used facebook for one of my projects and had no problem with using localhost, but this was a while ago and I assume facebook has changed their methods
dyon gerwen
@fullstackinprogress_gitlab
Nov 15 2018 00:05
if it was something that was common it was nice knowledge to learn but now even when i not wasting my time on facebook im wasting my time with facebook
@JLuboff yeah i saw it since march 2019 with the new laws
Jason Luboff
@JLuboff
Nov 15 2018 00:06
Ah...ya I think I used it middle of last year or so
dyon gerwen
@fullstackinprogress_gitlab
Nov 15 2018 00:12
i think i need to do it with heroku then i cant get it to work
kinopotato
@kinopotato
Nov 15 2018 00:25
quick question, suppose I have an array with 4 elements AND four functions that take 1 parameter each. Can I then make a loop that will push each element to each function and have those function do something with the elements and push them into one array?
Christopher McCormack
@cmccormack
Nov 15 2018 00:26
@kinopotato quick answer, probably, should you? probably not
kinopotato
@kinopotato
Nov 15 2018 00:26
oh why not?
I thought JS was all about pushing stuff into functions and all that
Christopher McCormack
@cmccormack
Nov 15 2018 00:27
Does your array contain the functions AND elements ?
kinopotato
@kinopotato
Nov 15 2018 00:27
no,
wait lemme try to write a pseudo code
Christopher McCormack
@cmccormack
Nov 15 2018 00:27
ok so some clarity may be required :)
are the functions in their own array?
and are you running each element in the array over all four functions or just one each?
kinopotato
@kinopotato
Nov 15 2018 00:30
let arrayOfNumberToBeConverted = [1000]
let newArr = [];
loop here that will split my array and push elements into functions {
push 1 into function 1
push 0 into function 2
push 0 into function 3
push 0 into function 4
}

function one(x){
do something with one
push that something into a new array
}
function two(x){
do something with zero
push that something into a new array
}
function three(x){
do something with zero
push that something into a new array
}
function four(x){
do something with zero
push that something into a new array
}


return newArr;
Christopher McCormack
@cmccormack
Nov 15 2018 00:33
any reason it's specifically four numbers and functions?
if it was 4x4 I would say just perform the action manually on the numbers
kinopotato
@kinopotato
Nov 15 2018 00:33
yes, it's how I'm approaching the number to roman numerals and the max is 3999
so I'm splitting it into singles, tenths, hundredths, thousandths
Christopher McCormack
@cmccormack
Nov 15 2018 00:34
ah then you might want to just do that iteratively, you can use modulus in a loop
I have to run for dinner but maybe start up some code
kinopotato
@kinopotato
Nov 15 2018 00:35
alright thanks for the hint dude! I'll see how I can do that
Bjorn van de Peut
@bjorno43
Nov 15 2018 00:59
Oh.. on a side note, it's my birthday :P
kinopotato
@kinopotato
Nov 15 2018 00:59
@bjorno43 duuuude, happy birthday!
Bjorn van de Peut
@bjorno43
Nov 15 2018 00:59
Thx
Just noticed the time here, lol
kinopotato
@kinopotato
Nov 15 2018 01:00
alert(`Happy Birthday!
Best Wishes!`);
it's all I could do :|
Bjorn van de Peut
@bjorno43
Nov 15 2018 01:01
Haha it's alright m8
kinopotato
@kinopotato
Nov 15 2018 01:05

on a side note how come this works

let a = ["M", "MM", "MMM"];
let result = [];

result.push(a[0]);
result; // returns M

but this doesn't

function convertToRoman(num) {
  //create functions
  //function one deals with thousandths
  let result = [];
  function one(num){
    //create a table of keys and values
    let thousandths = ["M", "MM", "MMM"];
    result.push(thousandths[num - 1]);
    //use .map and return only the value you want and push that
  }

 return result; //returns []
}

convertToRoman(3);

I've tried
result = result.push(thousandths[num]
still doesn't work

oh nevermind
I'm an idiot, I didn't call the function
dyon gerwen
@fullstackinprogress_gitlab
Nov 15 2018 01:06
kinopotato
@kinopotato
Nov 15 2018 01:06
now it worked.
that video has over 180m views
why am I even studying, I should just be making YT videos for birthdays
Bjorn van de Peut
@bjorno43
Nov 15 2018 01:08
@fullstackinprogress_gitlab lol, thx :P
abraham anak agung
@padunk
Nov 15 2018 01:09
@bjorno43 :cake: happy birtday man, and good morning...
Bjorn van de Peut
@bjorno43
Nov 15 2018 01:10
@padunk Thx :)
codeloopy
@codeloopy
Nov 15 2018 01:10
@JLuboff got it tnx
image.png
ok so I’m working on the Basic Algorithm Scripting: Mutations (https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations/) and I’m trying to use regex to check the strings pattern but for some reason I’m good on all tests but one
seems like the floor , for is similar to the Hello hey one? not sure why one tests good while the later fails
This is what my code looks like:
function mutation(arr) {
  var reg = /[a-z]./gi;
  return reg.test(arr[0]) === reg.test(arr[1]);
}
Been stuck on this for a few hrs, any guide on this is greatly appreciated
codeloopy
@codeloopy
Nov 15 2018 01:16
tnx in advance
kinopotato
@kinopotato
Nov 15 2018 01:19
I did this in a very different way and your code is much cleaner so I don't really know if I can even help
codeloopy
@codeloopy
Nov 15 2018 01:20
@kinopotato how did u approach it? maybe my aproach is what’s wrong HAHA, thought about looping over it, but seemed like a perfect job for regEx but I could b wrong
kinopotato
@kinopotato
Nov 15 2018 01:20
I used regex too, but FCC's solution doesn't
codeloopy
@codeloopy
Nov 15 2018 01:20
ah ok
kinopotato
@kinopotato
Nov 15 2018 01:21
I don't even know how your code passed this
"mutation(["hello", "hey"]) should return false."
because .test returns true right? so to me it looks like this, return true if true === true, else false
but your regex matches everything
codeloopy
@codeloopy
Nov 15 2018 01:22
:/
just when I thought I kinda had regex tsk tsk tsk … maybe back to the drawing board
abraham anak agung
@padunk
Nov 15 2018 01:22
@codeloopy interesting way, but i don't think it checking every letters in arr1 is in arr0
kinopotato
@kinopotato
Nov 15 2018 01:23
I used regex
tbh I'm looking at my code now and I don't even understand it xD
codeloopy
@codeloopy
Nov 15 2018 01:23
HAHA :P
kinopotato
@kinopotato
Nov 15 2018 01:23
but yeah, you can use regex if you want, maybe you can use match instead
abraham anak agung
@padunk
Nov 15 2018 01:23
the solution will use simple for loop, idk if you can do it with regex tho
kinopotato
@kinopotato
Nov 15 2018 01:24
but then === doesn't work quite straight with arrays :|
you can do it with regex, but the loop is easier
codeloopy
@codeloopy
Nov 15 2018 01:25
without giving me any answers … best advice? I’m kinda fried
abraham anak agung
@padunk
Nov 15 2018 01:25
but afaik @codeloopy your code check if arr0 pass the regex and compare the result to if arr1 pass the regex too
kinopotato
@kinopotato
Nov 15 2018 01:26
well you only need to compare the second array to the first one, so.... you can try that approach. compare elements in 2nd one, to first one. . .
oh sorry, arr[1] to arr[0] I mean
not second array
codeloopy
@codeloopy
Nov 15 2018 01:27
@padunk tnx mate @kinopotato gotcha.
Tnx guys!
kinopotato
@kinopotato
Nov 15 2018 01:28
good luck dude
codeloopy
@codeloopy
Nov 15 2018 01:28
you guys gave an idea ima try tom
@kinopotato tnx bruh!
abraham anak agung
@padunk
Nov 15 2018 01:28
@codeloopy you could check your regex in https://regex101.com and play with it. don't forget to checked javascript, because other languange have different feat for regex
codeloopy
@codeloopy
Nov 15 2018 01:29
@padunk ah cool!
Shooooot! looks like a lifesaver
tnx again
kinopotato
@kinopotato
Nov 15 2018 01:30
yeah I was just about to say his regex is matching 2 letters basically
two letters and anything not a period
abraham anak agung
@padunk
Nov 15 2018 01:31
idk why they call it regular expression, there is nothing regular with that expression :smile:
for me, regex is hard to read
kinopotato
@kinopotato
Nov 15 2018 01:34
do you watch TheTechLead from Youtube, he can teach you regex, he can teach you everything!
abraham anak agung
@padunk
Nov 15 2018 01:36
nope. but Derek Banas can teach you everything too...
kinopotato
@kinopotato
Nov 15 2018 01:37
TheTechLead isn't that kind of content creator xD You can never tell when he's being serious, he also actually doesn't teach you much of anything but the dude is hilarious if you're into his humor.
I remember Derek Banas, I think I've watched a few videos from him
is this ternary alright or do I have to put ; in break?
  if (x == 0) ? break : result.push(hundredths[x - 1]);
abraham anak agung
@padunk
Nov 15 2018 01:40
ternary syntax is condition ? statement if true : statement if false; so you don't need ; after break
kinopotato
@kinopotato
Nov 15 2018 01:40
wew, I
abraham anak agung
@padunk
Nov 15 2018 01:40
and you don't need if keyword
kinopotato
@kinopotato
Nov 15 2018 01:40
I'm only getting used to ternary, so I'm still genuinely nervous around it
oh
alright I'll remove it,
Manish Giri
@Manish-Giri
Nov 15 2018 01:41
don't think that break will work with a ternary operator
kinopotato
@kinopotato
Nov 15 2018 01:42
oh
err, any suggestions?
Christopher McCormack
@cmccormack
Nov 15 2018 01:42
yeah using returns and breaks in ternary isn't great
don't use ternary
kinopotato
@kinopotato
Nov 15 2018 01:42
alright, traditional it is
Christopher McCormack
@cmccormack
Nov 15 2018 01:43
what loop is this in?
kinopotato
@kinopotato
Nov 15 2018 01:43
thanks for informing me, I'm already nervous with ternary as it is, haha, at least now I know why my code won't work
not sure yet
for loop I guess? easiest and makes sense
or a loop that will go with function 4 first then function 3 and so on,
abraham anak agung
@padunk
Nov 15 2018 01:43
yeah, just tried it, break won't work with ternary
simple if will do
Manish Giri
@Manish-Giri
Nov 15 2018 01:44

thanks for informing me, I'm already nervous with ternary as it is, haha, at least now I know why my code won't work

ternary operator expects "expressions" as arguments either side of the :

and break is just a statement
it doesn't return anything
Christopher McCormack
@cmccormack
Nov 15 2018 01:44

maybe this will help
Good:

return x == 0 ? 'true' : 'false'

Not so good

x==0 ? return 'true' : return 'false'
they may work but you'll get hit by linters and warning messages most likely
Manish Giri
@Manish-Giri
Nov 15 2018 01:44
or just return x === 0
Christopher McCormack
@cmccormack
Nov 15 2018 01:45
hah that was just an example to show what goes where
there
kinopotato
@kinopotato
Nov 15 2018 01:45
I'm just going traditional, might not be a good idea (maybe??) to push for ternary if it could have problems
abraham anak agung
@padunk
Nov 15 2018 01:46
@kinopotato
if (x === 0) {
  break
} else {
 result.push(hundredths[x - 1])
}
Christopher McCormack
@cmccormack
Nov 15 2018 01:46
don't think you need the else
abraham anak agung
@padunk
Nov 15 2018 01:46
yeah, idk the full code tho...
kinopotato
@kinopotato
Nov 15 2018 01:47
      if (x == 0){
      break;
    } 
      result.push(tens[x - 1]);
this??
Christopher McCormack
@cmccormack
Nov 15 2018 01:47
sure
may want to work on your tab/spacing though :)
kinopotato
@kinopotato
Nov 15 2018 01:47
result will work? the x == 0 break is a catch
I gotta work on a lot of things xD
Christopher McCormack
@cmccormack
Nov 15 2018 01:48
you're only going to confuse yourself if your code is indented randomly
good thing to practice right away
kinopotato
@kinopotato
Nov 15 2018 01:48
      if (x == 0){
      break;
      } 
        result.push(tens[x - 1]);
  }
is this better?
Christopher McCormack
@cmccormack
Nov 15 2018 01:48
often when reading others code with poor indenting I get thrown off and assume the problem is scope because I can never tell right away where stuff ends or begins
kinopotato
@kinopotato
Nov 15 2018 01:48
the last } is for closing the function
oh wait, break needs to be indented too huh
Christopher McCormack
@cmccormack
Nov 15 2018 01:49
  if (x == 0){
    break;
  } 
  result.push(tens[x - 1]);
}
kinopotato
@kinopotato
Nov 15 2018 01:50
because result is sorta equivalent to "else" in this case, hmmm
will take a while but I agree that I should start getting this right
Christopher McCormack
@cmccormack
Nov 15 2018 01:50
I would think of it more as break will end your current loop so the rest won't get evaluated
but if x isn't equal to 0 then result is the next thing up to be evaluated
very often when you use else you can probably write it differently
kinopotato
@kinopotato
Nov 15 2018 01:51
alright, that should work, I hope. now to figure out the loop
break is giving me this error "SyntaxError: Unsyntactic break (20:6)" haha
if (x == 0){
      break;
    } 
    result.push(hundredths[x - 1]);
Christopher McCormack
@cmccormack
Nov 15 2018 01:54
are you in a loop?
kinopotato
@kinopotato
Nov 15 2018 01:54
no, I just wrote a bunch of functions,
no loop
Christopher McCormack
@cmccormack
Nov 15 2018 01:55
then what do you expect break to do?
it's for loops
kinopotato
@kinopotato
Nov 15 2018 01:55
I'm not even calling a function


function convertToRoman(num) {
  //create functions
  //function one deals with thousandths
  let result = [];
  function four(x){
  //create an array that corresponds to the 1 - 9 (but not here)
    let thousandths = ["M", "MM", "MMM"];
    //create a catch for 0 but not needed here
    //push to the new array
    result.push(thousandths[x - 1]);
  }
  //function three deals with hundredths
  function three(x){
    //create an array that corresponds to the 1 - 9    
    let hundredths = ["C", "CC", "CCC","CD", "D", "DC", "DCC", "DCCC", "CM"];
    //create a catch for 0 then push to the new array
    if (x === 0){
      break;
    } 
    result.push(hundredths[x - 1]);

  }
  //function two deals with tens
  function two(x){
    //create an array that corresponds to the 1 - 9
    let tens = ["X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"];
    //create a catch for 0 then push to the new array
      if (x === 0){
        break;
      } 
      result.push(tens[x - 1]);
  }
  //function one deals with singles
  function one(x){
    //create an array that corresponds to the 1 - 9
    let singles = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"];
    //create a catch for 0 then push to the new array
      if (x === 0){
        break;
      } 
      result.push(singles[x - 1]);    
  }

 return result;
}

convertToRoman(3);
Christopher McCormack
@cmccormack
Nov 15 2018 01:55
@kinopotato please don't paste large blocks of code
Manish Giri
@Manish-Giri
Nov 15 2018 01:56
@kinopotato I think you meant to use return; instead
of break
abraham anak agung
@padunk
Nov 15 2018 01:56
@kinopotato you mean return not break
Christopher McCormack
@cmccormack
Nov 15 2018 01:56
use return for functions not break
haha
Manish Giri
@Manish-Giri
Nov 15 2018 01:56
first :fire:
abraham anak agung
@padunk
Nov 15 2018 01:56
:laughing:
kinopotato
@kinopotato
Nov 15 2018 01:56
@cmccormack sorry, will avoid it in the future
Manish Giri
@Manish-Giri
Nov 15 2018 01:56
:P
kinopotato
@kinopotato
Nov 15 2018 01:57
err, just return?
return and nothing else?
Manish Giri
@Manish-Giri
Nov 15 2018 01:57
yup
kinopotato
@kinopotato
Nov 15 2018 01:57
woah
Manish Giri
@Manish-Giri
Nov 15 2018 01:57
return just by itself terminates the executing function
kinopotato
@kinopotato
Nov 15 2018 01:57
you learn new things daily when you're stupid xD
Manish Giri
@Manish-Giri
Nov 15 2018 01:57
if you do return 5; it terminates + gives you back the value 5
Christopher McCormack
@cmccormack
Nov 15 2018 01:57
I mean... learning is the way out of stupid isn't it?
kinopotato
@kinopotato
Nov 15 2018 01:58
once I get out of stupid, I'll have a decent reply. hahaha
it's not all bad I guess, at least now I'm able to laugh it off
Kyle Holm
@thekholm80
Nov 15 2018 01:59
i never get out of stupid, i just find new stupid to get into
kinopotato
@kinopotato
Nov 15 2018 02:00
I don't know whether to find that inspiring or just accept my fate. hehehe
Christopher McCormack
@cmccormack
Nov 15 2018 02:15
@thekholm80 come on now, I recently heard you were tutoring back ends, you must be getting much smarter
Kyle Holm
@thekholm80
Nov 15 2018 02:15
@cmccormack don't have to be smart, just smarter than the back end i'm tutoring
Christopher McCormack
@cmccormack
Nov 15 2018 02:16
lol
Kyle Holm
@thekholm80
Nov 15 2018 02:17
it's like when you and your buddies are running from a bear. you don't have to outrun the bear, just your buddies
Christopher McCormack
@cmccormack
Nov 15 2018 02:17
maybe the bear just needs some... tutoring
kinopotato
@kinopotato
Nov 15 2018 02:18
backend tutoring for the bear, that's some revenant thing going on
Christopher McCormack
@cmccormack
Nov 15 2018 02:19
lol
kinopotato
@kinopotato
Nov 15 2018 03:00
if a code is longer but takes significantly less computing resources, is that alright?
Aditya
@ezioda004
Nov 15 2018 03:01
Yes, you dont use 1 liner hot shot code in production anyway.
kinopotato
@kinopotato
Nov 15 2018 03:02
1 liner hotshot code, haha. I'm guessing it's frowned upon to insist on one line code when it takes much more resources
Aditya
@ezioda004
Nov 15 2018 03:04
Its kinda trade off between readability and performance, concise code is great but you also have to think of the team you're working in because its not just you who'll be reading that code.
Christopher McCormack
@cmccormack
Nov 15 2018 03:09
one liners usually aren't that readable either
For example using maps or similar for iteration can be more readable and have less side effects than a for loop, but aren't as fast. Trade-offs everywhere
Aditya
@ezioda004
Nov 15 2018 03:15
In a typical scenario where a loop is needed, I dont mind using .map(), .forEach() but if I have to chain stuff like .filter().map(stuff => stuff.every()) then I'll either use .reduce() or just a good ol for loop.
kinopotato
@kinopotato
Nov 15 2018 03:17

I saw someone who writes a chained code like this

a.map()
  .filter()
  .reduce()
  .map()
  .concat()

something like that, to make it look cleaner

Aditya
@ezioda004
Nov 15 2018 03:18
That looks clean but if you're doing .map().filter().reduce(), I'm sure this can be refactored to just .reduce().
kinopotato
@kinopotato
Nov 15 2018 03:19
one day I will understand the mysteries of .reduce, but that day is not today. haha
Aditya
@ezioda004
Nov 15 2018 03:20
Aha, .reduce() is really powerful, once you learn it, you'll want to overuse it and write unreadable one liner code..thats what I used to do :D
Aditya
@ezioda004
Nov 15 2018 03:27
Haha why? Look into .fromCharCode() and .charCodeAt() string prototype methods.
kinopotato
@kinopotato
Nov 15 2018 03:27
I remember not using this and I had to type binary to alphabet manually, haha
Christopher McCormack
@cmccormack
Nov 15 2018 03:28
use your tools!
they wouldn't ask you to do this exercise unless they're trying to teach you something
kinopotato
@kinopotato
Nov 15 2018 03:29
I like repetitive strain syndrome
Christopher McCormack
@cmccormack
Nov 15 2018 03:29
it doesn't scale well though
type h 10,000,000,000 times by hand
kinopotato
@kinopotato
Nov 15 2018 03:30
xD yes I'm reading about fromcharcode and charcodeat now. I keep forgetting these two
Aditya
@ezioda004
Nov 15 2018 03:30
I remember the methods as hints were available in algorithms at the bottom, dont know why that was removed
Christopher McCormack
@cmccormack
Nov 15 2018 03:30
I remember them as well, were they maybe in other exercises?
Aditya
@ezioda004
Nov 15 2018 03:32
This one definitely had cause I remember reading about both methods for this challenge in particular
Carlos Ávila
@CrAvila
Nov 15 2018 03:56
Does anyone know how to fix Xubuntu's slow wireless connection?
It works fine with the ethernet cable, but without it it's so slow it won't even load a page
dyon gerwen
@fullstackinprogress_gitlab
Nov 15 2018 04:14
how can i generate this files for a heroku deployed express app
 https.createServer({
      key: fs.readFileSync('key.pem'),
      cert: fs.readFileSync('cert.pem')
    }, app).listen(55555);
glitz20
@glitz20
Nov 15 2018 04:35
hey guys how can I get data from an array in react?
[{…}]
0:
answer: "<p>By improving the logo</p>"
id: "5bdd578c51365322a0a68ced"
username: "abhi"
__v: 0
_id: "5be93e29b5c0fa25a404a5b0"
__proto__: Object
length: 1
__proto__: Array(0)
so this is my response.data
and I just want to get the answer from it
 componentDidMount() {
        axios.get('/responses/' + this.props.match.params.id)
            .then(response => {
                var a = response.data
                console.log(a)

              console.log(this.state.text)
            })
            .catch(function (error) {
                console.log(error);
            })
    }
simply doing response.data.answer is not working
abraham anak agung
@padunk
Nov 15 2018 04:42
@glitz20 store it in your state
Ghost
@ghost~5b53da7dd73408ce4fa1d2e5
Nov 15 2018 04:43
what's the difference between suite() and describe() in mocha js?
glitz20
@glitz20
Nov 15 2018 04:43
@padunk I did
this.setState({text:response.data.answer})
abraham anak agung
@padunk
Nov 15 2018 04:44
@glitz20 if it is an array maybe it should be response. data[0].answer
glitz20
@glitz20
Nov 15 2018 04:44
but it is not working, it is taking the whole array, not just the answer
abraham anak agung
@padunk
Nov 15 2018 04:44
array is index bases
Anand Potukuchi
@anandpotukchi
Nov 15 2018 05:32

I'M BACK

Kaylee
@kaymonlee
Nov 15 2018 05:34
okay this is a completely silly question but when I'm writing code and it auto completes the closing bracket for me, how do I just skip to the end of the closed bracket? is there a keyboard shortcut for that or something?
Carlos Ávila
@CrAvila
Nov 15 2018 05:35
I would really like to know that as well...
Kaylee
@kaymonlee
Nov 15 2018 05:36
I hope I explained that clearly haha it's annoying
I think all you need to do is hit the end key??
abraham anak agung
@padunk
Nov 15 2018 05:41
or right arrow key
Kaylee
@kaymonlee
Nov 15 2018 05:42
there`s a lot more tapping with the right arrow key though
Aditya
@ezioda004
Nov 15 2018 05:42
ctrl + right arrow
Claudio Restifo
@Marmiz
Nov 15 2018 06:13
% in vim
Ai rui 艾瑞
@aisolae
Nov 15 2018 06:39
i have a more silly question
``
function myFunction(){
  var arr = [23, 24, 25, 26, 27];
  var text = document.getElementById("text");
  text.innerHTML= arr;
}
what’s wrong with this
seems all code i write on codepen never works
Aditya
@ezioda004
Nov 15 2018 06:41
@aisolae .innerHTML is suppose to be a string, you're assigning it an array.
Ai rui 艾瑞
@aisolae
Nov 15 2018 06:42
.tostring();
?
Aditya
@ezioda004
Nov 15 2018 06:42
[23, 24, 25, 26, 27].toString(); //"23,24,25,26,27"
Unless you want that, you could instead do .join() or similar method.
Ai rui 艾瑞
@aisolae
Nov 15 2018 06:44
so i can’t pass numbers to a html without using tostring
Aditya
@ezioda004
Nov 15 2018 06:45
You can coerce number to string, but yeah .innerHTML takes an HTML string, if you're only looking to change the text then perhaps use .textContent.
kinopotato
@kinopotato
Nov 15 2018 06:49
can you use arrays with String.fromCharCode?
hmm arrays with indexes seems to work
Ai rui 艾瑞
@aisolae
Nov 15 2018 06:51
Yeah, arrays with index seems to work
Aditya
@ezioda004
Nov 15 2018 06:51
You pass the ASCII value to String.fromCharCode() not sure how you'd wanna use it with arrays.
Ai rui 艾瑞
@aisolae
Nov 15 2018 06:51
 <body onload="loadFruits()">
     <p id="fruits"></p>

</body>
var fruits = ["Banana", "Orange", "Apple", "Mango"];

function loadFruits(){
   document.getElementById("fruits").innerHTML = fruits;
}
kinopotato
@kinopotato
Nov 15 2018 06:52
I'm thinking of using a loop, time to code and see what will happen
Ai rui 艾瑞
@aisolae
Nov 15 2018 06:52
this seems to work
without using string();
i did a task yesterday, it didn’t work too. it seems i have a common mistake i make but it’s js
tiny errors could affect the whole thing
Aditya
@ezioda004
Nov 15 2018 06:53
@aisolae I'm pretty sure it'll automatically use the .toString() method.
Its an "implicit coercion".
glitz20
@glitz20
Nov 15 2018 06:57
anybody who knows how to find pageview in react?
Ai rui 艾瑞
@aisolae
Nov 15 2018 07:06
Alright @
Thanks
Don’t know why my codes aren’t working, it’s so discouraging
Ai rui 艾瑞
@aisolae
Nov 15 2018 07:38
  <div onload="load()"><p id="text"></p></div>

    <script>
      function load(){
        var text = document.getElementById('text');
        var fruits = ['banana', 'apple', 'watermelon', 'egg', 'fish'];
        fruits.toString();
        texti, (innerHTML = fruits);
      }
    </script>
what am i doing wrong ?
abraham anak agung
@padunk
Nov 15 2018 07:44
@aisolae what is this code ? texti, (innerHTML = fruits);
Ai rui 艾瑞
@aisolae
Nov 15 2018 07:44
shit
please i found my mistakes
thanks
Altin Rrahmani
@DevKosov
Nov 15 2018 07:45
$('a[href^="#case-studies"]').on("click", function(event) {
    var target = $(this.getAttribute("href"));

    if (target.length) {
        event.preventDefault();
        $("html, body")
            .stop()
            .animate(
            {
                scrollTop: target.offset().top +1 
            },1000 //ease transition?
        );
    }
});
hi everyone i have been trying to add ease animation to my function but i can't do it if anyone is willing to help me i'd apreciate it :)
kinopotato
@kinopotato
Nov 15 2018 08:03

Hello, can someone please write this in ternary?

result = result.map(e => {
   if (e < 65 || e > 90){
     return e;
   }
   else if (e >= 78){
     return e - 13;
   } else {
     return e + 13;
   }
 })

I don't get the syntax for else if with ternary

Aditya
@ezioda004
Nov 15 2018 08:04
@kinopotato
result = result.map(e => e < 65 || e > 90 ? e : e >= 78 ? e - 13 : e + 13);
kinopotato
@kinopotato
Nov 15 2018 08:04
I'm reading that right now and I'm trying to make it work
only one ()>>
?
Aditya
@ezioda004
Nov 15 2018 08:05
?
kinopotato
@kinopotato
Nov 15 2018 08:05
so that's why I keep getting syntax errors
only one parenthesis I mean
Aditya
@ezioda004
Nov 15 2018 08:06
Parentheses is just grouping operator (statement use it differently), you could use it anywhere or nowhere.
Except the times when operator precedence is a thing, then ( ) is mandatory.
Here its not needed.
kinopotato
@kinopotato
Nov 15 2018 08:07
I thought I'd have to use them per condition
function example(…) {
return condition1 ? value1
: condition2 ? value2
: condition3 ? value3
: value4;
}
Aditya
@ezioda004
Nov 15 2018 08:08
You can do like that:
 (e < 65 || e > 90) ? e : (e >= 78) ? ...
Its optional tho
abraham anak agung
@padunk
Nov 15 2018 08:08
@DevKosov i think getAttribute in jQuery is .attr()
Aditya
@ezioda004
Nov 15 2018 08:09
Relational operators (>, <) are more precedent than logical || so its not needed.
kinopotato
@kinopotato
Nov 15 2018 08:12
how do you even remember all this, I'm starting to think you really are gandalf
Ai rui 艾瑞
@aisolae
Nov 15 2018 08:12
Onload doesn’t work on divs but on body,
If you have been doing and helping others for long
Before then, get ready to face #
frustration
kinopotato
@kinopotato
Nov 15 2018 08:14
haha, I can barely understand my own code, I never thought I was stupid, but the evidence is pointing in an undesirable direction. hahahaha
Aditya
@ezioda004
Nov 15 2018 08:16
Quick reference is the key, since I've learned this before- I know exactly where to look
kinopotato
@kinopotato
Nov 15 2018 08:19
I agree it's getting better. Learning to understand the concepts and it's easier now to remember or think of solutions
but I don't think I'll be at your level within a year of coding. man you really did take this stuff in
Aditya
@ezioda004
Nov 15 2018 08:22
You're doing great so far! Having your code reviewed and learning from past mistakes is the key
kinopotato
@kinopotato
Nov 15 2018 08:23
How about making mistakes more to have more mistakes to learn from, hwe hwe hwe. I just figured this shit out.
in all honesty, the projects are actually fun
I thought I'd have to lose all my hair but it's been nice

look at this advanced code solution from FCC

function rot13(str) { // LBH QVQ VG!
  return str.replace(/[A-Z]/g, L => String.fromCharCode((L.charCodeAt(0) % 26) + 65));
}

good god

Aditya
@ezioda004
Nov 15 2018 08:29
Clever
kinopotato
@kinopotato
Nov 15 2018 08:30
now I feel dirty when I use a for loopp
Aditya
@ezioda004
Nov 15 2018 08:31
Regex is a loop
kinopotato
@kinopotato
Nov 15 2018 08:31
alright, a loop that is not regex, haha
kinopotato
@kinopotato
Nov 15 2018 10:01
any recommendation for JS regex book?
Aditya
@ezioda004
Nov 15 2018 10:06
Have you done the fcc challenges?
Regex is similar across all languages as its a language in its own, so you dont have to specifically learn JS regex.
kinopotato
@kinopotato
Nov 15 2018 10:07
Yes, I'm about to finish the JS miraculously enough
hmm, then why do I have to press the JS when using regex101?
Aditya
@ezioda004
Nov 15 2018 10:08
Similar*, some stuff is supported in other languages, that arent supported in JS and vice versa
kinopotato
@kinopotato
Nov 15 2018 10:10
hmm, I use that but a book explains and demonstrates stuff. Or maybe I should just do codewars until I'm competent. wdyt?
eyyyy I'm on my last FCC JS challenge. I didn't notice
Aditya
@ezioda004
Nov 15 2018 10:12
I dont know any regex books, I've learned from fcc and by doing codewars problems - I'd say fcc challenges are enough to understand how regex works, rest is all about practice and making use of regex in your workflow.
kinopotato
@kinopotato
Nov 15 2018 10:13
I puke every time I need to do lookback or lookahead
If I get my JS cert, I'mma start schooling you! muwahahahaha, well no, but one can dream
Aditya
@ezioda004
Nov 15 2018 10:15
I never remember lookback and lookahead syntax
Was it like (?=), (?!)?
kinopotato
@kinopotato
Nov 15 2018 10:16
it has a question mark yes, that's all I remember
Aditya
@ezioda004
Nov 15 2018 10:16
Negative behinds are also similar
abraham anak agung
@padunk
Nov 15 2018 10:16
@kinopotato http://eloquentjavascript.net/09_regexp.html this one is not bad.
Aditya
@ezioda004
Nov 15 2018 10:16
(?<=) or something like that
kinopotato
@kinopotato
Nov 15 2018 10:17
they say that eloquent JS is not for beginners though
then again I'm on my last FCC js challenge
Aditya
@ezioda004
Nov 15 2018 10:17
I think I read like a chapter or two from eloquent JS, not my cup of :tea:
Oh there we go (?<=) and (?<!)
Niraj Nandish
@Nirajn2311
Nov 15 2018 10:19
Those are the one thing i always mix up
Negative and positive lookahead
which is which
Aditya
@ezioda004
Nov 15 2018 10:20
Regex is evil
May Kittens Devour Your Soul
@diomed
Nov 15 2018 11:15
regex is love , regex is life
Ene Catalin
@EneCatalin
Nov 15 2018 11:17
:cat: actually knows regex of all things
May Kittens Devour Your Soul
@diomed
Nov 15 2018 11:18
:cat: used regex. :cat: now has 2 problems
kinopotato
@kinopotato
Nov 15 2018 11:19

something weird is happening :|

 let totalCid = newCid.filter(e => console.log(e[1])); // returns 1.01
2.05
3.1
4.25
90
55
20
60
100
return totalCid; // []

weirder

let totalCid = newCid.filter(e => e[1]);
  return totalCid; // => [ [ 'PENNY', 1.01 ],
  [ 'NICKEL', 2.05 ],
  [ 'DIME', 3.1 ],
  [ 'QUARTER', 4.25 ],
  [ 'ONE', 90 ],
  [ 'FIVE', 55 ],
  [ 'TEN', 20 ],
  [ 'TWENTY', 60 ],
  [ 'ONE HUNDRED', 100 ] ]

it even has the arrow

Aditya
@ezioda004
Nov 15 2018 11:20
Whats newCid?
kinopotato
@kinopotato
Nov 15 2018 11:21
newCid = [ [ 'PENNY', 1.01 ],
  [ 'NICKEL', 2.05 ],
  [ 'DIME', 3.1 ],
  [ 'QUARTER', 4.25 ],
  [ 'ONE', 90 ],
  [ 'FIVE', 55 ],
  [ 'TEN', 20 ],
  [ 'TWENTY', 60 ],
  [ 'ONE HUNDRED', 100 ] ]
Aditya
@ezioda004
Nov 15 2018 11:23
Ok - so its not filtering anything, cause no value is falsy
kinopotato
@kinopotato
Nov 15 2018 11:24
isn't it supposed to just return e[1]?
or if I got it wrong with e[1] then it should return e[0]
Aditya
@ezioda004
Nov 15 2018 11:24
No, .filter() either keeps the element or removes the element
kinopotato
@kinopotato
Nov 15 2018 11:25
so it's removing everything?
Aditya
@ezioda004
Nov 15 2018 11:25
How is it removing everything? The newCid is same as totalCid
kinopotato
@kinopotato
Nov 15 2018 11:28
sorry, forgot it was a console. log
how about this?
  let totalCid = newCid.filter(e => {
    console.log(typeof e[1] === "number");
    typeof e[1] === "number"});
  return totalCid; // returns empty
hmm I'm being stupid again
Aditya
@ezioda004
Nov 15 2018 11:31
This one returns empty because you dont have an explicit return statement inside the callback function, so it implicitly returns undefined which is a falsy value hence you get an empty array.
kinopotato
@kinopotato
Nov 15 2018 11:34

so

  let totalCid = newCid.filter(e => e[1]);
  return totalCid;

does nothing because I'm not making e do anything?

Aditya
@ezioda004
Nov 15 2018 11:36
It does nothing because the function returns a number..which is a truthy value and hence it keeps/doesnt filter the element.
What are you trying to do?
kinopotato
@kinopotato
Nov 15 2018 11:36
get just the numbers, it worked with .map()
hehehe,
something is wrong with me, hahaha
Bjorn van de Peut
@bjorno43
Nov 15 2018 11:37
Actually, it does nothing because return is outside of the function. It's returning towards nothing so even IF it had a value to return, you still wouldn't see it
Aditya
@ezioda004
Nov 15 2018 11:37
Because .map() is the right method here :)
I'm guessing that return statement is for another function:
someFunc(){
  let totalCid = .filter();
  return totalCid;
}
Niraj Nandish
@Nirajn2311
Nov 15 2018 11:38
When you realise you used the right function, but you changed it and wondered why it was not working cause you were using the wrong function
kinopotato
@kinopotato
Nov 15 2018 11:39
this is the correct syntax for summing the numbers right?
.reduce((a,b) => a+b)
Aditya
@ezioda004
Nov 15 2018 11:39
Yes
kinopotato
@kinopotato
Nov 15 2018 11:39
I feel like beginners are supposed to hit a wall from time to time, but I think I'm hitting all of the walls xD
Aditya
@ezioda004
Nov 15 2018 11:39
Presuming numbers arent string
Like "1"
kinopotato
@kinopotato
Nov 15 2018 11:40
this is returning a weird figure, it's returning 335.40999999999997 instead of 335.41
I wonder whom did I made angry in my past life
Bjorn van de Peut
@bjorno43
Nov 15 2018 11:40
Trust me.. pretty much all of us hit all those walls while we were still beginners, haha
Aditya
@ezioda004
Nov 15 2018 11:40
Ah you've finally made it! This is milestone in your journey
@kinopotato Time to learn about 0.1 + 0.2 === 0.3 //false
kinopotato
@kinopotato
Nov 15 2018 11:41
what?
now I gotta deal with this shit xD so I can't use reduce basically??
Aditya
@ezioda004
Nov 15 2018 11:42
Well you'll have to avoid floating point airthmatic
Because computers are dumb
kinopotato
@kinopotato
Nov 15 2018 11:42
but my calculator is doing it fine O.O wth
also it's kind of required I guess? it's the last challenge in FCC
Aditya
@ezioda004
Nov 15 2018 11:43
I dont think your calculator follows IEEE 754 floating point representation :P
kinopotato
@kinopotato
Nov 15 2018 11:43
now I'm afraid that if I round it, it will screw things up
kinopotato
@kinopotato
Nov 15 2018 11:43
why did they make arithmetic complicated in JS? xD
like, it's a decimal that I want to add, just add it.
Aditya
@ezioda004
Nov 15 2018 11:44
Its not JS! It all languages that does this, including C, C++, Java, Python etc
kinopotato
@kinopotato
Nov 15 2018 11:44
I swear to god an astronaut died because supercomputers can't do arithmetic
ohhh this has to do with binary
still weird since I thought everyday calculators also follow binary
Kelechi Chinaka
@ke1echi
Nov 15 2018 11:47
hows it going? @ezioda004
Aditya
@ezioda004
Nov 15 2018 11:47
Ofcourse they do, but they use different kind of representation
@ke1echi Not bad - doing some numpy, ML. What about you?
kinopotato
@kinopotato
Nov 15 2018 11:48
any hint at what to do next? Math.round rounds to the nearest whole
Kelechi Chinaka
@ke1echi
Nov 15 2018 11:49
about to get started with speller... its mind-boggling :smile: @ezioda004
Aditya
@ezioda004
Nov 15 2018 11:51
@kinopotato Simple, dont do arithmetic in decimal
Math.round(num*100)/100)
@ke1echi Oh nice, goodluck!
kinopotato
@kinopotato
Nov 15 2018 11:52
the decimals are a given, sadly :| they represent money too so I can't change them
Aditya
@ezioda004
Nov 15 2018 11:53
The thing is you're losing precision while calculating in decimals
kinopotato
@kinopotato
Nov 15 2018 11:53
it's what FCC wants xD maybe they did this on purpose
checkCashRegister(19.5, 20, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]);
Aditya
@ezioda004
Nov 15 2018 11:54
0.1 + 0.2; // 0.30000000000000004
Math.round(0.1*100+0.2*100)/100; // 0.3
kinopotato
@kinopotato
Nov 15 2018 11:54
I hope this doesn't mess with the other requirements
Aditya
@ezioda004
Nov 15 2018 11:55
It doesnt - I've solved this algorithm before :P
kinopotato
@kinopotato
Nov 15 2018 11:56
oohhh, I'm planning on learning JS dom manipulation next. any advice??
assuming I pass this test, hahaha
Kelechi Chinaka
@ke1echi
Nov 15 2018 11:59
you finished speller? @ezioda004
Aditya
@ezioda004
Nov 15 2018 12:00
@kinopotato You could do the fcc's jQuery section (its small) and then reference MDN for the same DOM properties/methods, its relatively simple.
@ke1echi No, never got the the time to start that
Kelechi Chinaka
@ke1echi
Nov 15 2018 12:01
i hope i survive this one. lol @ezioda004
kinopotato
@kinopotato
Nov 15 2018 12:01
worth learning jquery even though it's not as used anymore?
or necessary would be the right word I guess
Aditya
@ezioda004
Nov 15 2018 12:03
@ke1echi You will!
@kinopotato Its not even that hard to learn - jQuery and vanilla DOM methods are more or less same..its just jQuery gives a better introduction to DOM
kinopotato
@kinopotato
Nov 15 2018 12:05
that sounds great, easy would be nice since I still have to learn some backend at least
May Kittens Devour Your Soul
@diomed
Nov 15 2018 12:17
as a man is about to be executed, the firing squad leader offers him a cigarette.
The man replies, "No thanks, I'm trying to quit."
kinopotato
@kinopotato
Nov 15 2018 12:21
truly hard boiled
May Kittens Devour Your Soul
@diomed
Nov 15 2018 12:21
Hard Boiled Wonderland?
kinopotato
@kinopotato
Nov 15 2018 12:22
I don't even know what you are trying to reference. haha
May Kittens Devour Your Soul
@diomed
Nov 15 2018 12:34
Jersey Hudson
@jerseyhh
Nov 15 2018 13:15
I need some help in Basic HTML and HTML5: Add a Submit Button to a Form.. I am unable to move on to the next lesson ... all of my code is correct and it just wont comply
<form action="/submit-cat-photo">
<input type="text" placeholder="cat photo URL">
<button type="submit">Submit</button>
</form>
kinopotato
@kinopotato
Nov 15 2018 13:15
you mind linking the challenge?
if this is what your asking for then yes
kinopotato
@kinopotato
Nov 15 2018 13:17
are you using chrome?
Jersey Hudson
@jerseyhh
Nov 15 2018 13:17
yes
kinopotato
@kinopotato
Nov 15 2018 13:17
it's passing with me
I literally just copy pasted your code
Jersey Hudson
@jerseyhh
Nov 15 2018 13:18
thats really odd ... maybe ill try clearing cache
kinopotato
@kinopotato
Nov 15 2018 13:18
what is the requirement that isn't passing?
Jersey Hudson
@jerseyhh
Nov 15 2018 13:19
Your submit button should only have the text "Submit".
Niraj Nandish
@Nirajn2311
Nov 15 2018 13:20
Did you put a space or dot along with the text "Submit"
kinopotato
@kinopotato
Nov 15 2018 13:21
@jerseyhh you could try to reset your code then paste into the form your code that you pasted here
if that doesn't work then try doing the next challenge, if something weird is still happening then maybe you should clear cache,
Niraj Nandish
@Nirajn2311
Nov 15 2018 13:22
@jerseyhh which browser are you using?
kinopotato
@kinopotato
Nov 15 2018 13:22
he is using chrome
Jersey Hudson
@jerseyhh
Nov 15 2018 13:23
Its still doing the same thing
I just copied and pasted .. and it persists
kinopotato
@kinopotato
Nov 15 2018 13:23
try doing the next challenge
or try incognito
Niraj Nandish
@Nirajn2311
Nov 15 2018 13:24
What is showing up in browser console
Jersey Hudson
@jerseyhh
Nov 15 2018 13:24
I wonder if it will work on another computer and or browser...
but ill try going to the next lesson
kinopotato
@kinopotato
Nov 15 2018 13:26
incognito is effectively the same as a browser whose cache was cleared right?
Jersey Hudson
@jerseyhh
Nov 15 2018 13:26
even the code from the next lesson that i copied and pasted into my text editor would not allow it to pass
so it is confirmed that my code is correct ... but the lesson will not allow me to pass
really weird
Aditya
@ezioda004
Nov 15 2018 13:28
@kinopotato Cache/cookie yes
@jerseyhh Do you have a different browser?
Jersey Hudson
@jerseyhh
Nov 15 2018 13:29
just chrome
Niraj Nandish
@Nirajn2311
Nov 15 2018 13:29

@jerseyhh

What is showing up in browser console

Aditya
@ezioda004
Nov 15 2018 13:29
Out of 4 tests, which test isnt passing?
Jersey Hudson
@jerseyhh
Nov 15 2018 13:29
The third one is not passing
Your submit button should only have the text "Submit".
Passed
here is my code
<form action="/submit-cat-photo">
<input type="text" placeholder="cat photo URL">
<button type="submit">Submit</button>
</form>
Aditya
@ezioda004
Nov 15 2018 13:31
Can you try resetting the challenge code?
Jersey Hudson
@jerseyhh
Nov 15 2018 13:31
yes at least 20 times
ive watched the video .. refreshed the browser... moved the code around
i think im going to either clear cache... and also try it on another browser ...
in a different computer just so then we can see if the problem is linked to either the browser or the actual lesson
Aditya
@ezioda004
Nov 15 2018 13:33
The lesson is fine - the test check for <space>submit<space> so it could be you have a weird unicode character there somewhere
Menkiy
@Menkiy
Nov 15 2018 13:39
hello
Niraj Nandish
@Nirajn2311
Nov 15 2018 14:08
@ezioda004 you there?
Aditya
@ezioda004
Nov 15 2018 14:10
@Nirajn2311 Yes
Niraj Nandish
@Nirajn2311
Nov 15 2018 14:12
@ezioda004 Check pm
kinopotato
@kinopotato
Nov 15 2018 14:54
is there anything wrong with my while loop? It's not entering into the while
 for (let x in moneyTable){
   console.log([x]);
   console.log(moneyTable[x]);
   while(flag){
     console.log("potato"); //doesn't run
     flag = true;
   }

  }
Aditya
@ezioda004
Nov 15 2018 14:58
Whats flag initially?
kinopotato
@kinopotato
Nov 15 2018 14:59
false
Aditya
@ezioda004
Nov 15 2018 14:59
...
kinopotato
@kinopotato
Nov 15 2018 14:59
shouldn't it do console.log at least once?
then go into the line of flag = true to break the while loop?
Aditya
@ezioda004
Nov 15 2018 15:00
No, you're thinking of do while loop.
While loop doesnt run once if the initial condition is false.
kinopotato
@kinopotato
Nov 15 2018 15:00
but how did it change the condition if it didn't run?
oh
you mean that kind of false
Aditya
@ezioda004
Nov 15 2018 15:01
You said flag is false so the while loop will never execute
kinopotato
@kinopotato
Nov 15 2018 15:01
welp, it ran now. sorry about that, I thought you can just put anything there and the computer will wait until it is changed
yeah, misconception about while, I thought it would do accept anything until it changes
apparently it doesn't like false
Aditya
@ezioda004
Nov 15 2018 15:03
do {
  ...
} while (condition);
This will atleast execute once.
Darren
@DarrenfJ
Nov 15 2018 15:30
morning fCC
Kyle Holm
@thekholm80
Nov 15 2018 15:32
@DarrenfJ :wave:
Kiran Prajapati
@Kiranprajapati2719
Nov 15 2018 15:41
Any suggestions for projects in redux?
Niraj Nandish
@Nirajn2311
Nov 15 2018 16:03
@DarrenfJ :wave: , you live in Toronto, Canada??
Barbara Pentoney
@flyfishingbarbara
Nov 15 2018 18:01
hi peeps-once i have completed the 5 projects for responsive web design and all the challenges, how long will it take to receive cert in my email...??
Aditya
@ezioda004
Nov 15 2018 18:25
@flyfishingbarbara Dont think you'll get an email, you'll have to claim it by going to your fcc's profile.
mstellaluna
@mstellaluna
Nov 15 2018 18:36
@flyfishingbarbara you do not receive an email. You will need to go into your FCC profile and view your public profile and your certifcates are available from there
Barbara Pentoney
@flyfishingbarbara
Nov 15 2018 18:39
@ezioda004 @mstellaluna thnx guys...yep it was there after a few clicks...geez and ive been checking inbox...haha... not sure if that is clear how/when you "redeem' the cert...when i clicked the last submit button for the last project i dont' remember seeing any further instructions... thnx again!!
mstellaluna
@mstellaluna
Nov 15 2018 18:40
np
ReesesLover123
@ReesesLover123
Nov 15 2018 18:53
https://github.com/ReesesLover123/shell123/blob/master/game2withhelp.html
When anyone has time, would you mind looking over this small document for gaping errors?
ajthemaniac
@ajthemaniac
Nov 15 2018 19:22
how can i import and use a whole html page inside react and route it
??
Christopher McCormack
@cmccormack
Nov 15 2018 19:47
@ajthemaniac what do you mean import an html page? React builds the HTML for a page
Usually in an HTML page you source a React bundle JavaScript file that binds itself to a root element in your html file (e.g. <div id="root"></div> and the JS (React) will build the DOM elements based on how you designed your React Components
ajthemaniac
@ajthemaniac
Nov 15 2018 19:55
@cmccormack I have a html file...... I need to import it and render inside my react class... Is this possible
Christopher McCormack
@cmccormack
Nov 15 2018 19:56
Can you not just copy it into your React app and adjust a few things like class to className?
ajthemaniac
@ajthemaniac
Nov 15 2018 19:58
Its a big file with lots of css and html
@cmccormack can i use dangerouslySetInnerHTML for this???
Christopher McCormack
@cmccormack
Nov 15 2018 20:05
sure
strip off the outer tags though
ajthemaniac
@ajthemaniac
Nov 15 2018 20:08
Outer tags ???
Christopher McCormack
@cmccormack
Nov 15 2018 20:09
well you're importing an html file, it's going to have the html, head and body tags at a minimum right?
ajthemaniac
@ajthemaniac
Nov 15 2018 20:11
@cmccormack oh ... I thought that I just need to import my full HTML file and put it inside dangerouslySetInnerHTML....
Christopher McCormack
@cmccormack
Nov 15 2018 20:11
I personally think that's not a good idea at all
probably better off adding React to your html file
ajthemaniac
@ajthemaniac
Nov 15 2018 20:14
My HTML file is full of css scripts links and tags it’s a huge file and I don’t want to make it as it is in react ... so I am looking for a min workload ... trick
@cmccormack thanks mate... all the way from India ... it’s been a pleasure ... thank you for your response.... peace out 🤘
Christopher McCormack
@cmccormack
Nov 15 2018 20:16
A good start is to remove your CSS and JS from you html file
glitz20
@glitz20
Nov 15 2018 20:31
Hey guys, I need to make different forms for different pages in react. What would be a good way to do so?
Is there any efficient way or should I manually create page and form each time?
Christopher McCormack
@cmccormack
Nov 15 2018 20:33
@glitz20 if you have a form style you can componetize a lot of it. I like to make Form, FormRow, FormInput type components that always behave the same way. then you can nest them as children within your App component
glitz20
@glitz20
Nov 15 2018 20:37
@cmccormack I also want to get the data from the form and show it using graphs and charts. What would a better way to manage database for the survey results and use it for charts?
Christopher McCormack
@cmccormack
Nov 15 2018 20:38
can you refine your question? Sounds like you're asking three different things
glitz20
@glitz20
Nov 15 2018 20:38
@cmccormack also do you have link to any example of form style componetization?
Christopher McCormack
@cmccormack
Nov 15 2018 20:39
glitz20
@glitz20
Nov 15 2018 20:40
@cmccormack So, here is what I am trying to do.
1) Create a form/survey and show it in a particular page
2) Get the data from survey and save in database
3) Use the data to show graphs,charts
Christopher McCormack
@cmccormack
Nov 15 2018 20:41
I have some form stuff here but it's a little more tightly coupled https://github.com/cmccormack/voting-app/tree/master/src/views/layout
glitz20
@glitz20
Nov 15 2018 20:41
So, my question is how should I manage the database.
Would it be loop of Arrays?
Christopher McCormack
@cmccormack
Nov 15 2018 20:41
@glitz20 sounds like a normal use of a form, what's the question specifically?
Do you have any database experience?
glitz20
@glitz20
Nov 15 2018 20:45
yeah I am using mongodb
Eric Weiss
@eweiss17
Nov 15 2018 20:45
You doing the MERN stack?
Christopher McCormack
@cmccormack
Nov 15 2018 20:48
@glitz20 so I would override the submit action using an event listener, gather the data I need into a body object, pass that along using a fetch with a POST action to an endpoint that can receive that data and do something with the data and the database. If you depend on the updated database for the graphic you can return the new object or some object as part of your endpoint response and use that response to update state in your React app to display what you need
May Kittens Devour Your Soul
@diomed
Nov 15 2018 20:55
@cmccormack hey Chris! got any suggestions on how to make this work?
Christopher McCormack
@cmccormack
Nov 15 2018 21:02
what is format?
@diomed
index.html:1 Access to font at 'https://github.com/Seaony/Operator-Mono/blob/master/src/OperatorMono-Light.otf' from origin 'https://s.codepen.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
May Kittens Devour Your Soul
@diomed
Nov 15 2018 21:06
ugh. that again.
but codepen is https and github is https, so wtf now?
is there any way I could link to that github repo without experiencing that error?
see before there was this rawgit thing and that was possible but now rawgit closed and I can't use it anymore for that purposes
Christopher McCormack
@cmccormack
Nov 15 2018 21:08
it's a cross origin thing, the destination server has to allow cross origin requests
May Kittens Devour Your Soul
@diomed
Nov 15 2018 21:24
unsure how to fix that and is it even fixable?
Christopher McCormack
@cmccormack
Nov 15 2018 21:24
not broken, it's a server config
May Kittens Devour Your Soul
@diomed
Nov 15 2018 21:38
I mean, if it doesnt work because of this, what are my options here?
Christopher McCormack
@cmccormack
Nov 15 2018 21:38
use a different font or different endpoint to get it
I don't know much about adding fonts like that though, I usually just use something from google fonts and import it using the link tag in the head
May Kittens Devour Your Soul
@diomed
Nov 15 2018 21:40
looks like I have no options then
coz I wanna use that font, and it has to be from github
Christopher McCormack
@cmccormack
Nov 15 2018 21:43
let me try something
Christopher McCormack
@cmccormack
Nov 15 2018 22:20
@diomed tried to find a way using the API but not having luck hitting the endpoint
kinopotato
@kinopotato
Nov 15 2018 23:01
Hello, can someone help me with my while loop? (this is an infinite loop)
  let moneyTable ={
     "One-hundred Dollars" : 100,
     "Twenty Dollars"      : 20,
     "Ten Dollars"         : 10,
     "Five Dollars"        : 5,
     "Five Dollars"        : 5,
     "Dollar"              : 1,
     "Quarter"             : 0.25,
     "Dime"                : 0.1,
     "Nickel"              : 0.05,
     "Penny"               : 0.01, 
  }
  for (let i in moneyTable){
    while(change != preChange){ //change initialized to 0 preChange is 0.50 
      let temp = 0; //I was hoping to make temp go back to zero once it becomes positive
      temp = preChange - moneyTable[i]; 
      console.log(temp)
      if (temp > 0){ //if temp becomes positive, add its value to change
        change = change + temp; //I want it to go back, right now change is .25, I want it at .5 like preChange
      }
    }
  }
dyon gerwen
@fullstackinprogress_gitlab
Nov 15 2018 23:15
what parameters i can put in the scope for the passportfacebook login
Christopher McCormack
@cmccormack
Nov 15 2018 23:17
@kinopotato here's a tip - any time you have a while loop, put a safety mechanism in:
let counter = 100
while(conditional) {
  ...
  counter -= 1
  if (counter === 0) break;
}
then you can at least read your log statements
then remove the counter once you're sure it will pass all test cases
kinopotato
@kinopotato
Nov 15 2018 23:20
@cmccormack that's pretty nifty, alright I'll do that :D
Karma Drukpa
@coderkarma
Nov 15 2018 23:47
@cmccormack
why this doesn't work.
class MyComponent extends React.Component{
  constructor(props){
    super(props);
  }

  render(){
    return(
      <h1> My First React Component! </h1>
    );
  }
}

ReactDOM.render(
  "MyComponent",
   document.getElementById('challenge-node')
);
Christopher McCormack
@cmccormack
Nov 15 2018 23:53
@coderkarma <MyComponent />
Karma Drukpa
@coderkarma
Nov 15 2018 23:55
thanks, so here we are rendering the component Mycomponent right.