These are chat archives for FreeCodeCamp/HelpJavaScript

24th
Feb 2018
Tiago Correia
@tiagocorreiaalmeida
Feb 24 2018 00:11
@JLuboff I just picked a made one and changed a few stuff, almost writting 0 css for this project, so I would say the one they gave me :D eheh
Jason Luboff
@JLuboff
Feb 24 2018 00:22
@tiagocorreiaalmeida haha fair enough
I've done that before using a bunch of nbsp or whatever it is to create white space
Nate Mallison
@NJM8
Feb 24 2018 03:47
@NJM8
Hello, can someone help me setup vscode to compile and run C programs? Here is my tasks file but it isn't outputting anything
{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "label": "echo",
      "type": "shell",
      "command": "gcc -c ${file} -o main.out",
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}
Brad
@bradtaniguchi
Feb 24 2018 07:33
@NJM8 Not sure if asking in the javascript room is the best for VSCode and C, I'd probably check other sources (google, stack overflow)
Tricia
@patricia07
Feb 24 2018 09:15
var myStr = "I am a \"double quoted\" string inside \"double quotes"."; // Change this line
is there anything wrong with my code?
alpox
@alpox
Feb 24 2018 09:58
@patricia07 you missed to escape the second last quote
Tai Jones
@taiJones00
Feb 24 2018 10:20
https://codepen.io/taiJones00/pen/zddmNe I have this weird error but this did work recently. I didn't change anything but all of a sudden I get something that says Access to Font at 'https://static.codepen.io/assets/telefon/bold/af889c53-1ee3-4868-8fdc-2b310d587b50-3-b7a87e0fbd213943fae0c0ef5985635dd43fa9c24876b2725127a13ccaf4ab6a.woff' from origin 'https://codepen.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://codepen.io' is therefore not allowed access.
there's also an error that says checkBlank is not defined but it is in my javascript
Alex
@alexandrupintilei
Feb 24 2018 10:33
Hi! Can someone tell me whats wrong with off/on buttons? I think might be if condition inside btns
https://codepen.io/balexoy/pen/VQBQwx
May Kittens Devour Your Soul
@diomed
Feb 24 2018 10:42
@taiJones00 I dont see u linking to that font anywhere in your pen O_o
Tai Jones
@taiJones00
Feb 24 2018 10:48
Weird. Maybe that's a font that comes with boortrap? @diomed
Stephen James
@sjames1958gm
Feb 24 2018 13:02
@alexandrupintilei
The one user you are getting is offline, so on button will not show anything. The function for offline is not called in off button function
@alexandrupintilei Strange organization- your off button function isn't set until you click the on button
Alex
@alexandrupintilei
Feb 24 2018 13:03
@sjames1958gm i want to printout the code i output when i click on All btn + " OFF"
logo + name + " OFF "
when user is offline
} else if (data2.hasOwnProperty("stream") && data2.stream === null) {
that mean is offline
Stephen James
@sjames1958gm
Feb 24 2018 13:06
@alexandrupintilei
  1. Your off button is not assigned a click handler
  2. This code is not calling a function
    function offBtn(){
    return offlineBtn;
    }
Alex
@alexandrupintilei
Feb 24 2018 13:06
but
image.png
i used closure and hoisting
Stephen James
@sjames1958gm
Feb 24 2018 13:07
@alexandrupintilei That is not referencing the off button
Alex
@alexandrupintilei
Feb 24 2018 13:07
what i did wrong?
oh
just saw
image.png
i fix that, but stil dosent work
Stephen James
@sjames1958gm
Feb 24 2018 13:08
offBtn() function is not calling offlineBtn
Alex
@alexandrupintilei
Feb 24 2018 13:09
but thats the click event for button
btnOffline
on click -> call offBtn function
Stephen James
@sjames1958gm
Feb 24 2018 13:09
This code needs offlineBtn(); to call the function
function offBtn(){
return offlineBtn;
}
Alex
@alexandrupintilei
Feb 24 2018 13:11
@sjames1958gm
image.png
stil dosent work
i though if i just call variable assigned to that function, no need to put ()
Stephen James
@sjames1958gm
Feb 24 2018 13:12
@alexandrupintilei Yes you do you have to put the () to call the function.
Try clicking the on button then the off button
@alexandrupintilei offlineBtn this variable is not assigned to a function unless you click the on button first
Alex
@alexandrupintilei
Feb 24 2018 13:14
@sjames1958gm if i change the first if (data2.hasOwnProperty("stream") && data2.stream !== null) with if (data2.hasOwnProperty("stream") && data2.stream === null) {
the onlineBtn work
Stephen James
@sjames1958gm
Feb 24 2018 13:19
If you want the off button to work without pressing the on button first you will need to reorganize your code
Alex
@alexandrupintilei
Feb 24 2018 13:20
i understand
thx
@sjames1958gm thx
CamperBot
@camperbot
Feb 24 2018 13:20
alexandrupintilei sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9021 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Feb 24 2018 13:20
@alexandrupintilei :+1:
Alex
@alexandrupintilei
Feb 24 2018 13:21
ideea is , never nest buttons, right?
Nate Mallison
@NJM8
Feb 24 2018 13:22
@sjames1958gm Do you have any experience using VS Code for running C programs?
Stephen James
@sjames1958gm
Feb 24 2018 13:22
@alexandrupintilei It most cases don't
It could be that you inn some case need Button A then Button B
@NJM8 Other than running the code in the embedded terminal, no. I assume you are talking about something more?
Alex
@alexandrupintilei
Feb 24 2018 13:23
yea
Nate Mallison
@NJM8
Feb 24 2018 13:23
Yes I'm trying to set up the task runner and debugger. So I can put in some flags and shift-cmd-b to run it.
I've tried many configurations but no love
Stephen James
@sjames1958gm
Feb 24 2018 13:26
@NJM8 What does your tasks.json file look like?
Nate Mallison
@NJM8
Feb 24 2018 13:26
  "version": "2.0.0",
  "tasks": [
    {
      "label": "echo",
      "type": "shell",
      "command": "gcc",
      "args": [
        "-g ${file} -o main.out"
    ],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}
Stephen James
@sjames1958gm
Feb 24 2018 13:27
@NJM8 does that work to build it? And you have a launch.json as well?
Nate Mallison
@NJM8
Feb 24 2018 13:28
Here is the result:
> Executing task: gcc -g /Users/natemallison/Documents/Programming/Codewars/solutionsC/growthOfPopulation/growthOfPopulation/main.c -o main.out <

Undefined symbols for architecture x86_64:
  "_nbYear", referenced from:
      _main in main-4f2e9e.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.
I haven't set up launch.json yet, just trying to get the task runner working, it output the same without the -g flag
a google search for the linker error comes up with some problems when files are renamed, I did have some git problems when VS Code deleted main.c because I didn't specify an output file
Stephen James
@sjames1958gm
Feb 24 2018 13:30
Sounds like you are missing a library - have you tried with a minimal main?
What does the c code look like?
I have successfully run it in Xcode, I just prefer vs code
Stephen James
@sjames1958gm
Feb 24 2018 13:32
@NJM8 You need to include all the c files in the gcc command
Nate Mallison
@NJM8
Feb 24 2018 13:32
really?!
Stephen James
@sjames1958gm
Feb 24 2018 13:33
@NJM8 Yeah, it doesn't know to add that other c file to the compile and link
Nate Mallison
@NJM8
Feb 24 2018 13:33
I didn't know that. The linker doesn't just hook them up?
huh
Stephen James
@sjames1958gm
Feb 24 2018 13:33
@NJM8 no
You could create a script that does it and call that script instead of gcc from the task runner
Nate Mallison
@NJM8
Feb 24 2018 13:34
I was hoping for a way to have a generic task runner file that I could just keep in the parent directory, I don't want to create a custom one for each project.
I wonder if anyone has made an extension to address that
Stephen James
@sjames1958gm
Feb 24 2018 13:35
or `${fileDirname}/*.c
There are other task runner variables you might use for selecting files.
Nate Mallison
@NJM8
Feb 24 2018 13:42
@sjames1958gm It complied!
Stephen James
@sjames1958gm
Feb 24 2018 13:43
@NJM8 :+1:
Nate Mallison
@NJM8
Feb 24 2018 13:43
So two more questions, how to I read the output of the main.out from terminal, and can I set up the task runner to automatically display the output?
Stephen James
@sjames1958gm
Feb 24 2018 13:44
I think that is what launch.json is all about.
But you can certainly just open a terminal and run
./main.out
Nate Mallison
@NJM8
Feb 24 2018 13:45
@sjames1958gm Got it, thank you. I'll work on that
CamperBot
@camperbot
Feb 24 2018 13:45
njm8 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9022 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Feb 24 2018 13:46
@NJM8 gl
Nate Mallison
@NJM8
Feb 24 2018 13:46
Hmmm. I need to talk to FCC about getting peoples brownie points reset at 9999 so you can't retire. :smile:
Stephen James
@sjames1958gm
Feb 24 2018 13:53
@NJM8 lol
i fix it
few adjustments on html
and is ok
Stephen James
@sjames1958gm
Feb 24 2018 13:58
@alexandrupintilei :+1:
Alex
@alexandrupintilei
Feb 24 2018 13:59
now i need a list of users, right?
Stephen James
@sjames1958gm
Feb 24 2018 13:59
yes
Alex
@alexandrupintilei
Feb 24 2018 14:35
@sjames1958gm Can you give me a hint for this
image.png
Stephen James
@sjames1958gm
Feb 24 2018 14:54
@alexandrupintilei What are you attempting to do?
look at this
i try to output each user when i click All btn
Stephen James
@sjames1958gm
Feb 24 2018 14:57
@alexandrupintilei You will have to a loop around getJSON function in order to call it multiple times.
@alexandrupintilei two things about your x function - it doesn't return anything and it can only return one URL anyway
Alex
@alexandrupintilei
Feb 24 2018 14:58
it dosent change the user each time i ++ ?
Stephen James
@sjames1958gm
Feb 24 2018 15:00
@alexandrupintilei Every time you call the function it resets i = 0
A function can only return one value so it can only return one URL.
Alex
@alexandrupintilei
Feb 24 2018 15:04
@sjames1958gm except that error, here shouldnt output at last first user?
image.png
Stephen James
@sjames1958gm
Feb 24 2018 15:05
@alexandrupintilei That code looks like it would output all the users
Alex
@alexandrupintilei
Feb 24 2018 15:06
@sjames1958gm
i fix it
Stephen James
@sjames1958gm
Feb 24 2018 15:06
@alexandrupintilei Yep
Alex
@alexandrupintilei
Feb 24 2018 15:07
now i need to figure out last part and is gg xD
Stephen James
@sjames1958gm
Feb 24 2018 15:14
@alexandrupintilei :+1:
FlashHero
@FlashHero
Feb 24 2018 15:55
I thought webpack bundle.js file was supposed to only include things required in the entry file and it's dependencies but it has so much code in bundle.js and I don't even know where it came from.
Christopher McCormack
@cmccormack
Feb 24 2018 16:47
@FlashHero I wouldn't worry too much about it, you should be serving the compressed file as well as the original so the final file size shouldn't be too big. You can use plugins like UglifyJS for your production deployment as well to make it smaller
Most of your code will be the reactdom and react dependencies if you're using react, along with other libraries that can be quite big if you don't pull just small parts out individually
AbrisM
@AbrisM
Feb 24 2018 18:15
Hi all
Christopher McCormack
@cmccormack
Feb 24 2018 18:19
@AbrisM hello
AbrisM
@AbrisM
Feb 24 2018 18:27
Hi :)
Anyone familiar with CAPTCHA verification on a website?
Nicole F.
@gitasong
Feb 24 2018 19:17

I feel like I'm losing my mind. I completed the FCC Basic Algorithms two years ago, have done 1-1/2 bootcamps, am working in React Native. I'm gong back through the Basic Algorithms to refresh using more advanced syntaxes and now I can't create a simple for loop? What the heck is wrong with my code below (the function's not finished yet)?

// generate array of all numbers <= num using array.push;
// reduce them all to a single accumulator value

function factorialize(num) {
  let numArray = [];
  for (let i = 1; i <= num; i++) {
    numArray.push[i];
  }
  console.log(numArray);
  return numArray;
}

factorialize(5);

This both logs and returns an empty array, [].

Anyone around?
Moisés Man
@moigithub
Feb 24 2018 19:29
push is a method. use () not [] @gitasong
Nicole F.
@gitasong
Feb 24 2018 19:29
Oh, duh—of course. Thanks, @moigithub !
CamperBot
@camperbot
Feb 24 2018 19:29
gitasong sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3732 | @moigithub |http://www.freecodecamp.org/moigithub
Nicole F.
@gitasong
Feb 24 2018 19:29
It had to be something obvious and stupid like that. :)
Man, once you get too many frameworks in your head, basic syntax goes out the window.
It's ridiculous.
All right; thanks much! That fixes it. Now on to reduce()...
AbrisM
@AbrisM
Feb 24 2018 19:32
Hi all, For this I got the answer as 1 but I wanted to make sure that the represented the original length here: length = 5;
length
= 2;
length *= length;
length /= 100;
Nicole F.
@gitasong
Feb 24 2018 19:34
Not clear what you're doing here, @AbrisM . Are these sequential steps, or are these supposed to be evaluated separately?
AbrisM
@AbrisM
Feb 24 2018 19:56
These are sequential steps
I think the represent the original length=5, but instead of using length it uses but still has the value of 5
FlashHero
@FlashHero
Feb 24 2018 23:02
How do I use bootstrap with reactjs or nodejs in general, I can't get it to work, I've installed bootstrap and jquery through npm and added import "bootstrap/dist/js/bootstrap.js"; import "bootstrap/dist/css/bootstrap.css"; and I don't get errors but this doesn't work return <h1 class="text-center">Hello</h1>;
even with className, it doesn't work
Brad
@bradtaniguchi
Feb 24 2018 23:11
@FlashHero bootstrap is a css library/framework for frontend development. You need to use it on the front-end by adding a linktag to your bootstrap.css file. Idk how node is used in this case outside of package management (using npm)