These are chat archives for FreeCodeCamp/HelpJavaScript

3rd
Nov 2017
dyon3334
@dyon3334
Nov 03 2017 00:01
@korzo thanks a lot
CamperBot
@camperbot
Nov 03 2017 00:01
dyon3334 sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
api offline
Kaz Baig
@kbaig
Nov 03 2017 00:13
@tiagocorreiaalmeida you mean from the pen? I just forked it trying to help that guy
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 00:29
Oh ok and yeah
korzo
@korzo
Nov 03 2017 00:40
Free book today: Flux Architecture https://www.packtpub.com/packt/offers/free-learning
Long Nguyen
@longnt80
Nov 03 2017 00:58
@korzo got it, thanks
CamperBot
@camperbot
Nov 03 2017 00:58
longnt80 sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 725 | @korzo |http://www.freecodecamp.com/korzo
Henry
@GitHub-Henry
Nov 03 2017 01:25
@longnt80 how did the interviews go?
Long Nguyen
@longnt80
Nov 03 2017 01:26
@GitHub-Henry not yet
will be in 1 hour
Henry
@GitHub-Henry
Nov 03 2017 01:26
@korzo thank you for the tip, :shipit: :dizzy:
CamperBot
@camperbot
Nov 03 2017 01:26
github-henry sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 726 | @korzo |http://www.freecodecamp.com/korzo
Long Nguyen
@longnt80
Nov 03 2017 01:26
I'm getting ready
Henry
@GitHub-Henry
Nov 03 2017 01:27
@longnt80 good luck, :thumbsup:
Long Nguyen
@longnt80
Nov 03 2017 01:27
@GitHub-Henry btw, the series about Object on funfunfunction is great
@GitHub-Henry thank you, hope I can find a good company to work with
CamperBot
@camperbot
Nov 03 2017 01:28
longnt80 sends brownie points to @github-henry :sparkles: :thumbsup: :sparkles:
:cookie: 452 | @github-henry |http://www.freecodecamp.com/github-henry
Henry
@GitHub-Henry
Nov 03 2017 01:28
@longnt80 i enjoy learning from him as well, glad you do also
Long Nguyen
@longnt80
Nov 03 2017 01:29
he certainly make me not feeling sleepy
Henry
@GitHub-Henry
Nov 03 2017 01:29
@longnt80 keep up those JS & front end skills and eventually you'll find the company you are looking for
Long Nguyen
@longnt80
Nov 03 2017 01:29
:+1:
Henry
@GitHub-Henry
Nov 03 2017 01:30
@longnt80 ok, now, back to interview prep
Long Nguyen
@longnt80
Nov 03 2017 01:30
yep
ah, I'm getting dressed now
Henry
@GitHub-Henry
Nov 03 2017 01:31
@longnt80 in person interview?
Long Nguyen
@longnt80
Nov 03 2017 01:31
yes
btw, I'm not from the US
Henry
@GitHub-Henry
Nov 03 2017 01:31
i thought you were from Vietnam
Long Nguyen
@longnt80
Nov 03 2017 01:31
yes
these companies are just a few miles away
so all person interviews
Henry
@GitHub-Henry
Nov 03 2017 01:32
working close to home is nice
Long Nguyen
@longnt80
Nov 03 2017 01:32
one of them even offer remoting
which is nice
Henry
@GitHub-Henry
Nov 03 2017 01:33
@longnt80 sounds nice, thanks for the chat, get ready, :shipit: :dizzy:
CamperBot
@camperbot
Nov 03 2017 01:33
github-henry sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 641 | @longnt80 |http://www.freecodecamp.com/longnt80
Long Nguyen
@longnt80
Nov 03 2017 01:34
@GitHub-Henry thank you too, I'll let you guys know the details
see you later
Henry
@GitHub-Henry
Nov 03 2017 01:34
@GitHub-Henry later & good luck
:shipit: :sparkles:
Morchid Chellali
@Morched23MJ
Nov 03 2017 02:38
How to trigger the event of active using jquery, for a give period? It's like I'm holding the click for a moment.
Claudio Restifo
@Marmiz
Nov 03 2017 03:04
@Morched23MJ you can detect mousedown and mouseleave if you want to see a user "holding" a click :)
Morchid Chellali
@Morched23MJ
Nov 03 2017 03:07
I'm asking that, because on the Simon Game you have to click some buttons, so the user can remember them. So I'm asking how to trigger the click event, for a longer period, in order to let the user actually notice it, and slow down the process.
@Marmiz
Claudio Restifo
@Marmiz
Nov 03 2017 03:14
@Morched23MJ that can simply be an animation, like videogames does
Morchid Chellali
@Morched23MJ
Nov 03 2017 03:15
Trying to figure it out, @Marmiz. Thank you for your help! :smile:
CamperBot
@camperbot
Nov 03 2017 03:15
morched23mj sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1078 | @marmiz |http://www.freecodecamp.com/marmiz
Claudio Restifo
@Marmiz
Nov 03 2017 03:16
@Morched23MJ the "easiest" animation goes from changing the opacity, to using box-shadow properties.
More complex require some timing transitions
hillsie
@Hillsie
Nov 03 2017 05:07
Thought I might post this here . A link to the book You don’t know JS free and covers JS indepth. I am currently on a JS mastery drive, going throught the minutia…again;
Emmanuel Akodia
@akodiaemma
Nov 03 2017 05:48
how can i make the header menu fixed on this page, the position: fixed attribute isnt working . this is the website http://mambosms.ug/Data/emma/mapenzi/
how can i make the header menu fixed on this page, the position: fixed attribute isnt working . this is the website http://mambosms.ug/Data/emma/mapenzi/ and i think its a java command but i cant seem to get it
Emmanuel Akodia
@akodiaemma
Nov 03 2017 05:55
is anyone willing to help me out
bilaal-s
@bilaal-s
Nov 03 2017 08:05
:wave:
do people who use JS for OOP use protype a lot
Henry
@GitHub-Henry
Nov 03 2017 08:33
:shipit: :dizzy:
Long Nguyen
@longnt80
Nov 03 2017 08:33
@GitHub-Henry just got back from interviews
Henry
@GitHub-Henry
Nov 03 2017 08:33
@longnt80 how were they
Long Nguyen
@longnt80
Nov 03 2017 08:34
it was 4 hours total doing tests back to back
Henry
@GitHub-Henry
Nov 03 2017 08:35
what were the positions, and what where the tests like?
Long Nguyen
@longnt80
Nov 03 2017 08:35
and the first company was ready to give me the offer
for the first company, it was all algorithm tests
Henry
@GitHub-Henry
Nov 03 2017 08:36
front end developer position?
all js tests
Long Nguyen
@longnt80
Nov 03 2017 08:36
for the second, it was a pair-programming session where I had to solve one algorithm and build a react component
yep front end, and all js
Henry
@GitHub-Henry
Nov 03 2017 08:37
did you solve all the algorithms
Long Nguyen
@longnt80
Nov 03 2017 08:38
no, it was timed and I only finished 2 out of 4
but the lead interviewer still gave me the position
Marianissimus
@Marianissimus
Nov 03 2017 08:39
what challenges? do you remember? @longnt80
Long Nguyen
@longnt80
Nov 03 2017 08:39
yes I have it back with me, need to translate it to English though
it's not too hard but harder than algorithms that I did in some previous interviews
Marianissimus
@Marianissimus
Nov 03 2017 08:40
you would help us so much...
anyway, harder than the fcc challanges?
Long Nguyen
@longnt80
Nov 03 2017 08:40
not harder, I just didn't have enough time
30 mins for 4 algorithms
Marianissimus
@Marianissimus
Nov 03 2017 08:40
i see. about objects, arrays?
quite a short time
Long Nguyen
@longnt80
Nov 03 2017 08:41
I'll translate them and post it here for you
Marianissimus
@Marianissimus
Nov 03 2017 08:41
thank you so much @longnt80 that's why i love this community
CamperBot
@camperbot
Nov 03 2017 08:41
marianissimus sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 644 | @longnt80 |http://www.freecodecamp.com/longnt80
Long Nguyen
@longnt80
Nov 03 2017 08:41
ok let me translate them real quick
Henry
@GitHub-Henry
Nov 03 2017 08:42
after i finish going through YDKJS i'll seriously consider doing CodeWars.com challenges
sounds like it might be good practice
Long Nguyen
@longnt80
Nov 03 2017 08:43
@GitHub-Henry btw, after finished with that 4 algorithms, they also made me fight the bot on codefights.com to see how quick I can do it
Henry
@GitHub-Henry
Nov 03 2017 08:43
wow, how'd it go with that
Long Nguyen
@longnt80
Nov 03 2017 08:44
they made me fight the easiest bot which I did in 8 mins
Henry
@GitHub-Henry
Nov 03 2017 08:44
must have felt good about that
Long Nguyen
@longnt80
Nov 03 2017 08:45
yep, it was great
Henry
@GitHub-Henry
Nov 03 2017 08:46
so how do things stand now with the companies
Long Nguyen
@longnt80
Nov 03 2017 08:47
@GitHub-Henry 1 sec, I'm translating the algorithms
Henry
@GitHub-Henry
Nov 03 2017 08:47
ok
Long Nguyen
@longnt80
Nov 03 2017 08:50
@Marianissimus @GitHub-Henry
Here's the first one:
Write a function to print out numbers from 1 to 100, with these conditions:
  • First number that can divide by 3 will be printed out as letter D. Second number can divided by 3 will be printed as DD. And the nth number can be divided by 3 will be printed out as n letters of D.
  • First number that can divide by 5 will be printed out as letter S. Second number can divided by 3 will be printed as SS. And the nth number can be divided by 3 will be printed out as n letters of S.
  • First number that can divide by 3 and 5 will be printed out as letter DS. Second number can divided by 3 and 5 will be printed as DSDA. And the nth number can be divided by 3 will be printed out as n pairs of DS.
Henry
@GitHub-Henry
Nov 03 2017 08:51
is this one you finished
how long did it take
Marianissimus
@Marianissimus
Nov 03 2017 08:52
Oh, it's a variation of the fizzbuzz challange, but a bit harder
Long Nguyen
@longnt80
Nov 03 2017 08:52
Here's the result example: 1,2,D,4,5,DD,...
yeah I finished this one
Marianissimus
@Marianissimus
Nov 03 2017 08:52
nice
Henry
@GitHub-Henry
Nov 03 2017 08:52
good job
Long Nguyen
@longnt80
Nov 03 2017 08:52
I think I took close to 20mins to finished 2 of them
Henry
@GitHub-Henry
Nov 03 2017 08:53
do you remember the other one
Long Nguyen
@longnt80
Nov 03 2017 08:53
I was doing the third one and it was out of time
yep I have the algorithm on paper with me
let me give you the other one which I finished
Write a function which takes in an array of continuous number and a number in that array. The rotate the array by that number. Example:
array: [1,2,3,4,5,6,7]
number: 3
result: [4,5,6,7,1,2,3]
this one is easier
Henry
@GitHub-Henry
Nov 03 2017 08:57
looks like you did well
so where do things stand with the companies, do you prefer one over the other
Long Nguyen
@longnt80
Nov 03 2017 09:01
@Marianissimus @GitHub-Henry
Write a function to print out an array of number. The next number will describe the previous number. Array starting with number 1.
Example:
First number is 1
Second number: 1 number of 1
Third number: 2 numbers of 1
Here's the result array: [1, 11, 21, 1211, 111221, 312211,...]
Marianissimus
@Marianissimus
Nov 03 2017 09:01
@longnt80 ok, so it gives you the argument 3, you must give the result of 3+1 and the continuous array?
Can't wait to try them all
Long Nguyen
@longnt80
Nov 03 2017 09:02

so it gives you the argument 3

what do you mean?

I had a hard time understand what the algorithm wanted
could be the writting
Henry
@GitHub-Henry
Nov 03 2017 09:04
sounds like you were up to the mental gymnastic challenges, :+1:
so what's next
Marianissimus
@Marianissimus
Nov 03 2017 09:04
the initial arr is of numbers 1-7, right? ok, whatever number they give you, it should be used to splice the... I have some ideas. I'll try them all and then post my results here
Long Nguyen
@longnt80
Nov 03 2017 09:05
@Marianissimus yes, I thought you were talking about the other algorithm
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 09:05
what was the "type" of job? just curiosity
Henry
@GitHub-Henry
Nov 03 2017 09:05
@Marianissimus ok, but you need to do it in a timed manner, @longnt80 how much time did you have for these
Long Nguyen
@longnt80
Nov 03 2017 09:05

so what's next

one company already gave me the job
I'm waiting for the other company's response

Henry
@GitHub-Henry
Nov 03 2017 09:06
@Marianissimus to simulate the condisions
Long Nguyen
@longnt80
Nov 03 2017 09:06

how much time did you have for these

30mins total for 4

Marianissimus
@Marianissimus
Nov 03 2017 09:06
the second one seems to want you to convert a number to a string of a specific length... mhm...
Long Nguyen
@longnt80
Nov 03 2017 09:06
I'm translating the last one
Henry
@GitHub-Henry
Nov 03 2017 09:07
@Marianissimus ok you should only give yourself 30 minutes from start to finish, and your thinking about is should reduce your time to solve, so less than 30 minutes
Long Nguyen
@longnt80
Nov 03 2017 09:09
Last one:
Write a function that take in an array. Return the number of instance of each number:
Example: [1,3,1,2,4,1,4,5,2,3,2]
1: 3 instances
3: 2 instances
2: 3 instances
4: 2 instances
5: 1 instances
Marianissimus
@Marianissimus
Nov 03 2017 09:09
Yes, I got that. I'll try to do them in 30 min
what's curious is that they all are about arrays / array methods, not a single one about objects
Did they allow you to search for methods on the net? on mdn or something?
Henry
@GitHub-Henry
Nov 03 2017 09:11
@longnt80 you totally would have had this one, given enough time
Long Nguyen
@longnt80
Nov 03 2017 09:11
yeah, I think they only care about how you solve algorithms which often has to do with array?
yeah, I can search anything
I think given the timeframe, googling won't help much
Marianissimus
@Marianissimus
Nov 03 2017 09:12
oh, that's great. I won't feel like cheating.
Henry
@GitHub-Henry
Nov 03 2017 09:12
@longnt80 did they want other skills besides JS
Long Nguyen
@longnt80
Nov 03 2017 09:12
and it was in Vietnamese, I could run out of time trying to translate them to find answer on Google
Marianissimus
@Marianissimus
Nov 03 2017 09:12
yes, but this is just to find the syntax of the method, the last one seems to use indexOf, but im not sure...
Ok, guys, see you in 30 mins:)
Henry
@GitHub-Henry
Nov 03 2017 09:13
@Marianissimus :+1:
Long Nguyen
@longnt80
Nov 03 2017 09:13

did they want other skills besides JS

I already knows HTML/CSS and design so I think it was a big plus

@Marianissimus see you
:D
Henry
@GitHub-Henry
Nov 03 2017 09:13
@longnt80 was react a thing both companies wanted or just the one
Long Nguyen
@longnt80
Nov 03 2017 09:14
both of them use React
React is everywhere though
Henry
@GitHub-Henry
Nov 03 2017 09:14
React is THE in demand skill today
Long Nguyen
@longnt80
Nov 03 2017 09:15
yes
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 09:15
what's the kind of projects the company who asked for the algorithms does?
Long Nguyen
@longnt80
Nov 03 2017 09:15
but they also emphasize that they want people that can use vanilla JS
both of them
@tiagocorreiaalmeida they both do web apps
don't know how much I have to use algorithms in apps development
@tiagocorreiaalmeida they also mentioned canvas, html5 games
alpox
@alpox
Nov 03 2017 09:17
@longnt80 You always need some algorithms :D
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 09:17
another curiosity ddid any of both asked about css pprocessors?
hey @alpox !!!
alpox
@alpox
Nov 03 2017 09:17
@tiagocorreiaalmeida :wave: hio
Long Nguyen
@longnt80
Nov 03 2017 09:17
@tiagocorreiaalmeida yes, the second company asked a little about css
but the main point is JS
alpox
@alpox
Nov 03 2017 09:20
@longnt80 When they want games and technical webpages, algorithms are needed
Long Nguyen
@longnt80
Nov 03 2017 09:21
@alpox yeah, I have some experiments with canvas so it has algorithm and math in there
alpox
@alpox
Nov 03 2017 09:21
@longnt80 I kinda like that math though
Long Nguyen
@longnt80
Nov 03 2017 09:21
for apps, I think algorithms has to do with processing data
@alpox yeah, I think canvas has more to do with algorithms compared to building website and apps
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 09:25
anyone you allready got 1 "secured" so congrats :D
anyway*
alpox
@alpox
Nov 03 2017 09:26
@longnt80 Well processing data is also full of algorithms :D
Long Nguyen
@longnt80
Nov 03 2017 09:27
@tiagocorreiaalmeida thanks
CamperBot
@camperbot
Nov 03 2017 09:27
longnt80 sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 419 | @tiagocorreiaalmeida |http://www.freecodecamp.com/tiagocorreiaalmeida
Henry
@GitHub-Henry
Nov 03 2017 09:28
@longnt80 so what's next, accept an offer, do you prefer one company over the other
Henry
@GitHub-Henry
Nov 03 2017 09:35
@longnt80 gotta go, sounds like things went well, congrats, & thank you for sharing your experience :shipit: :sparkles:
CamperBot
@camperbot
Nov 03 2017 09:35
github-henry sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 645 | @longnt80 |http://www.freecodecamp.com/longnt80
Thomas Faller
@thomasfaller
Nov 03 2017 09:41

Hey guys,
I’m working on a script that has a soccer table with numbers of wins, draws and losses and I’d like to build an array of object to store that such as:
let l1Table = [{name: "Paris", W: 9, D: 2, L: 0, Pts: 29}, {…..}, etc]

pretty simple but I’d like the “Pts” value to be calculated and returned dinamically as I update the W,D or L values (makes sense?)

So I thought about storing a function inside Pts such as
let tableTest = [ { W: 3, L: 4, Pts: function() { return ……. blablabla } } ];

What would be the most efficient way to do that?
If I create an outer function and call it from inside each object (here each club would be its own object), will it be able to access the proper W value through this.W for example?

Any thoughts?

Pieter Stokkink
@forkerino
Nov 03 2017 10:20
You don't need a function on each object, it would make more sense to put it on the prototype of the objects. @thomasfaller
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 10:23
wild @forkerino appears :wave:
Stephen James
@sjames1958gm
Nov 03 2017 10:33
@thomasfaller Your function could also receive the object as a parameter and update the points. Or since it can be calculated, you don't need to store it at all.
Creating a constructor function for the objects and assigning the function to the prototype seems the js "OO" way to go.
bilaal-s
@bilaal-s
Nov 03 2017 10:38
do people who use JS for OOP use protype a lot
Stephen James
@sjames1958gm
Nov 03 2017 10:39
Yes. That is how "inheritance" (more appropriately delegation) works in js
Pethaf
@Pethaf
Nov 03 2017 10:55
You can try looking at the code that comes out of babel when you write Class ... extends
Xploit
@ASXploit
Nov 03 2017 11:02
Hello everyone😁
Stephen James
@sjames1958gm
Nov 03 2017 11:03
@ASXploit :wave:
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 11:03
hey
Xploit
@ASXploit
Nov 03 2017 11:05
Do you guys believe it's possible to write a gameboy emulator in js🤔
Nouman Masood
@NoumanMasood
Nov 03 2017 11:09
hello
i want help
image.png
blank screen is showing on click
Xploit
@ASXploit
Nov 03 2017 11:14
Where's your one-click code
On*
wza62692371
@wza62692371
Nov 03 2017 13:43

// 举例
function ourFunction() {
console.log("Heyya, World");
}

ourFunction();

// 请把你的代码写在这条注释以下

myFunction() {
console.log("Hi World");
}
myFunction();

error
where
i can't
Diego Mayer
@Chrono79
Nov 03 2017 13:46
@wza62692371 you forgot to write function keyword before your function's name
Also check this: https://guide.freecodecamp.org/miscellaneous/markdown-code-formatting/
Stephen James
@sjames1958gm
Nov 03 2017 13:47
@wza62692371 From the instructions: Create a function called reusableFunction
Not myFunction
Diego Mayer
@Chrono79
Nov 03 2017 13:48
@sjames1958gm That can be different in chinese FCC
Stephen James
@sjames1958gm
Nov 03 2017 13:48
@Chrono79 Oh.
Diego Mayer
@Chrono79
Nov 03 2017 13:48
I fell for it too before ;)
They should update chinese version to match the "international" version
Diego Mayer
@Chrono79
Nov 03 2017 13:58
function ourFunction() {
...
myFunction() { // see the difference?
...
@wza62692371
Lean Junio
@leanjunio
Nov 03 2017 15:13

Hey guys, can anyone tell me how I can access global objects from a promise response?

function getLocation(url, method) {
  return $.ajax({
    url: url,
    method: method,
    dataType: 'JSON'
  })
}

var data = { location: '' }
var locationURL = 'http://ip-api.com/json'

getLocation(locationURL, 'get').then(function(response) {
  data.location = response
})

console.log(data.location) // empty

thanks

Kaz Baig
@kbaig
Nov 03 2017 15:14
@leanjunio might be because you didn't do response.json()
yofri
@yofriadi
Nov 03 2017 15:15
hey guys, anyone used sequelize here?
Lean Junio
@leanjunio
Nov 03 2017 15:18
I’ll try that @kbaig thank
CamperBot
@camperbot
Nov 03 2017 15:18
leanjunio sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 403 | @kbaig |http://www.freecodecamp.com/kbaig
Diego Mayer
@Chrono79
Nov 03 2017 15:21
@leanjunio I don't think that'll work, when you do the console.log, data.location will be empty string
lawrencelee93
@lawrencelee93
Nov 03 2017 15:21
hello guys
i am working on api right now
Johnny
@JohnnyBizzel
Nov 03 2017 15:21
@leanjunio the console log will get executed before the "then".
lawrencelee93
@lawrencelee93
Nov 03 2017 15:21
and I am not sure why i am unable to get it running
Jason Luboff
@JLuboff
Nov 03 2017 15:23
@Chrono79 @JohnnyBizzel :wave:
Johnny
@JohnnyBizzel
Nov 03 2017 15:23
y o
Diego Mayer
@Chrono79
Nov 03 2017 15:24
howdy :wave:
i am using ejs
so i'm unsure how to put it into codepen
but what is happening is when i run node script.js, is says app is running, but when i put it the city into the search, this is what pops up in my terminal
{ RestCallResponseFiltersUnhandledStatusError: Server returned status code 400
at createError (C:\Users\lawre\Desktop\Git\week12\yelpproject\node_modules\error
\typed.js:31:22)
at Object.filter (C:\Users\lawre\Desktop\Git\week12\yelpproject\node_modules\@to
nybadguy\call-me-maybe\lib\response-filters\unhandled-status.js:13:11)
and blah blah blah
and i've been stuck for like a day trying to fix this
yofri
@yofriadi
Nov 03 2017 15:31

whats wrong with my sequelize code

router.post('/edit/:id', async (req, res) => {
  const data = {
    first_name: req.body.first_name,
    last_name: req.body.last_name,
    email: req.body.email
  };

  try {
    await Models.Student.update(data, {
      where: { id: req.params.id }
    });
    res.redirect('/students');
  } catch (err) {
    console.error(err);
  }
});

I'm trying to update data from id

Johnny
@JohnnyBizzel
Nov 03 2017 15:33
@lawrencelee93 why the api.get /searchresults inside the yelp.accessToken function?
@Yofri is this a quiz?
lawrencelee93
@lawrencelee93
Nov 03 2017 15:34
so you are telling me that api.get/searchresults should be below it, and not inside of it?
yofri
@yofriadi
Nov 03 2017 15:35
@JohnnyBizzel no, why quiz..
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 15:35
@Yofri if that's mongodb that looks quite strange tbh
what are you using to connect to the mongo tough?
Johnny
@JohnnyBizzel
Nov 03 2017 15:35
@Yofri It's the way you phrased the question. Like a quizmaster.
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 15:35
mongoose or mongodb native?
Johnny
@JohnnyBizzel
Nov 03 2017 15:35
@lawrencelee93 No idea. Just looks odd compared to how I did it. Like how will anyone get to that route.
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 15:36
or sql?
yofri
@yofriadi
Nov 03 2017 15:36
@tiagocorreiaalmeida no, its postgre
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 15:36
oh ok, time to stepback ;)
gl mnate
yofri
@yofriadi
Nov 03 2017 15:36
haha ok
Johnny
@JohnnyBizzel
Nov 03 2017 15:37
@Yofri Never seen await so no idea. If it is async, should res.redirect be in a callback?
yofri
@yofriadi
Nov 03 2017 15:38
@JohnnyBizzel yes it is on try scope, so it is a kind of callback
Johnny
@JohnnyBizzel
Nov 03 2017 15:38
@lawrencelee93 if it's a node app you should test it on glitch.com not codepen
@Yofri You would have to explain the code to me better. I will pass. Next question?
alright here we go
Spyrantis Theodoros
@thodorisanta
Nov 03 2017 16:15

i did a start on the simon game project and below line 60 in JS it doesnt respond. can you tell me why? its supposed to change the color of one of the buttons and after 1 second set it back to normal.

https://codepen.io/oshikurou/pen/ZaWzoa?editors=0011

yofri
@yofriadi
Nov 03 2017 16:19
let say i have a confirmation dialog like this
<a href="/students/delete/{{id}}" id="confirmation">Delete</a>
and process it in javascript
document.getElementById('confirmation').addEventListener('click', confirm);
    const confirm = () => {  
    if (confirm('delete this student?')) {
      // what to do here
    }
      else {
      // and here
    } 
    }
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 16:27
you want to do a normal confirm window?
like clicks and then shows up the confirm on top page and based on that do something?
yofri
@yofriadi
Nov 03 2017 16:27
yes
i have no idea what todo
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 16:28
on click
you send a confirm message
you store the result of the store message in a variable
its either true or false
yofri
@yofriadi
Nov 03 2017 16:29
then if true, i pass url or what?
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 16:29
sec my jsfidle just broke :D will do on jsbin and send you
Kaz Baig
@kbaig
Nov 03 2017 16:29
@thodorisanta you want to change setInterval to setTimeout and flip the color changes
Spyrantis Theodoros
@thodorisanta
Nov 03 2017 16:30
@kbaig i kinda changed it now and i think it works. my problem now is how to run some code after setInterval ends?
Kaz Baig
@kbaig
Nov 03 2017 16:31
@thodorisanta what do you mean
Like what do you want to do
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 16:36
@Yofri
document.getElementById('confirmation').addEventListener('click', function(e){
  var state = confirm("Are you sure you wanna delete it?");
  if(!state){
     e.preventDefault();
  }
});
you can change the var to let
was using jsbin it doesnt accept let for what I saw
if the user cancels you prevent the href
try it out if doesnt work let me know
yofri
@yofriadi
Nov 03 2017 16:37
@tiagocorreiaalmeida ah i see, prevent default. i will try
Tiago Correia
@tiagocorreiaalmeida
Nov 03 2017 16:37
yeah and you assign the value of the confirm to a variable
otherwise the confirm wouldnt run
wroked here
worked*
yofri
@yofriadi
Nov 03 2017 16:39
@tiagocorreiaalmeida thanks man, it worked for me
CamperBot
@camperbot
Nov 03 2017 16:39
yofri sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 422 | @tiagocorreiaalmeida |http://www.freecodecamp.com/tiagocorreiaalmeida
AbrisM
@AbrisM
Nov 03 2017 17:00
afternoon all
How do we link our SoloLearn accounts to freenode?
FreeCode*
Isaiah Trembley
@IsaiahCT
Nov 03 2017 17:37
dude
you can';t
also, I didn;t like solo learn
I mean, It is good for quizzes, but that is is, they don't really go ino depth about why
AbrisM
@AbrisM
Nov 03 2017 17:41
Hmm I saw somewhere that you can
So they don't have a combo?
Joshua Arnett
@josha5
Nov 03 2017 17:42
Can anyone help me with removing highlighting of a div through jquery?
Kaz Baig
@kbaig
Nov 03 2017 17:44
@josha5 What do you mean by highlight
Im trying to change the css property of a square to a lighter color for a second and then change its color back to default.
function highLightSquare(buttons) {
  var selectedButton = pickRandomButton(buttons);
  var highLight = setInterval(function() {
    selectedButton.css("background-color", "#ffcccc");
  }, 1000)
  clearInterval(highLight);
}
Jason Luboff
@JLuboff
Nov 03 2017 17:49
@kbaig You can use .css() to set css properties
Kaz Baig
@kbaig
Nov 03 2017 17:50
Yeah I'm dumb
and the docs are silly
I took it back hehe
Jason Luboff
@JLuboff
Nov 03 2017 17:50
The docs can definitely be a little decieving
Joshua Arnett
@josha5
Nov 03 2017 17:50
When I take the setInterval out of the highlight function it works, but I'm trying to figure out how to change the property back to its default after the square is highlighted for a second
Kaz Baig
@kbaig
Nov 03 2017 17:50
I thought css was correct but then I read the docs and was like wait maybe I'm wrong
Jason Luboff
@JLuboff
Nov 03 2017 17:52
:P
Joshua Arnett
@josha5
Nov 03 2017 17:57
nevermind figured it out lol
AbrisM
@AbrisM
Nov 03 2017 17:58
Does anyone have suggestions for a programming game that teaches Java?
There was a minecraft one but the page is gone now
Spyrantis Theodoros
@thodorisanta
Nov 03 2017 17:58

@kbaig in line 68 and below in js i want the things outside interval to run after interval ends (after 1 second)|

https://codepen.io/oshikurou/pen/ZaWzoa?editors=1011

Kaz Baig
@kbaig
Nov 03 2017 18:01
@thodorisanta so what you're saying is that you want to change the color to the bright one, and then change it back after a second?
Spyrantis Theodoros
@thodorisanta
Nov 03 2017 18:21
yeah @kbaig
Kaz Baig
@kbaig
Nov 03 2017 18:21
@thodorisanta Sounds like you need to reverse the color changes
Joshua Arnett
@josha5
Nov 03 2017 18:22
@thodorisanta use setTimeout I just had that problem
Kaz Baig
@kbaig
Nov 03 2017 18:22
Yeah I recommended that a while ago
Spyrantis Theodoros
@thodorisanta
Nov 03 2017 18:22
oh sorry didnt see it
thanks guys
Joshua Arnett
@josha5
Nov 03 2017 18:25
@thodorisanta
 var highLight = selectedButton,
      x = 1000,
      originalColor = highLight.css("background");
  highLight.css("background", "#ffcccc");
  setTimeout(function() {
    highLight.css("background", originalColor)
  }, x);
}
Margaret Greaney
@greaneym
Nov 03 2017 19:00
Hi, I have a general question about the Rogue-like React game. Is the purpose of this to be able to use React with 3rd party libs that are established game engines? Or is the purpose to learn to use react components to control the events of the game? I feel very dense about how to approach this challenge.
Kaz Baig
@kbaig
Nov 03 2017 19:01
@greaneym Latter
But nobody is stopping you from doing the former
Margaret Greaney
@greaneym
Nov 03 2017 19:03
So use react components to take the place of the arrow control keys? I don't have much experience with playing games, so I am asking pretty newbie questions.
@kbaig , thanks.
CamperBot
@camperbot
Nov 03 2017 19:04
greaneym sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 407 | @kbaig |http://www.freecodecamp.com/kbaig
Kaz Baig
@kbaig
Nov 03 2017 19:05
What do you mean by taking the place of the keys?
Maybe try playing around with the example project to start thinking about how to structure it
Margaret Greaney
@greaneym
Nov 03 2017 19:06
I would do that but the user story says don't look at the project?
Kaz Baig
@kbaig
Nov 03 2017 19:06
you're not supposed to look at the code
What's the point of an example project if you can't play around with it
Margaret Greaney
@greaneym
Nov 03 2017 19:08
@kbaig , I will play the game and see if that helps. Yes, you are right. I will try it. thanks.
CamperBot
@camperbot
Nov 03 2017 19:08
greaneym sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
api offline
Morchid Chellali
@Morched23MJ
Nov 03 2017 19:11
I'm on the Simon Game project. I wrote a function, that is supposed to light up divs, every second, a random button (here, considered divs). It doesn't matter when to click them, I'm just starting, so the problem is, that they light up all at once, and they go back to normal, and then they don't anymore. They're supposed to do that 20 times.
Here is the pen: https://codepen.io/Morched23MJ/pen/zEYxGo
I appreciate your help. Ask me if you have difficulties with understanding what I'm trying to do.
Christopher McCormack
@cmccormack
Nov 03 2017 19:13
@greaneym if it helps, I did something like this for mine:
const ARROW_KEYS = {
  'ArrowUp': new Pos(0,-1),
  'ArrowRight': new Pos(1,0),
  'ArrowDown': new Pos(0,1),
  'ArrowLeft': new Pos(-1,0)
}
...
class App extends React.Component {
...
  initializeHandlers(){
    window.addEventListener('keydown', (e)=> {
      e.preventDefault()
      this.characterMove(ARROW_KEYS[e.code])
    })

    Array.from(document.getElementsByClassName('key')).forEach((item)=>{
      item.addEventListener('click', ()=>{
        this.characterMove(ARROW_KEYS[item.id])
      })
    })
  }
Kaz Baig
@kbaig
Nov 03 2017 19:13
@Morched23MJ Are you increasing the timeout for each blip or no
Muhammad Hasham
@MohammadHasham
Nov 03 2017 19:14
how can i change color of the text entered in an input bar if it matches with the word in paragraph text? what would be the approach
can anyone help?
Christopher McCormack
@cmccormack
Nov 03 2017 19:14
@greaneym React decides how your DOM elements are attached, but you still have to handle your inputs using JS
Morchid Chellali
@Morched23MJ
Nov 03 2017 19:16
@kbaig, nope. One second for all of them.
Christopher McCormack
@cmccormack
Nov 03 2017 19:16
@MohammadHasham you would add an event listener to the input field and every time a change is made, check if the text matches. If it does, you can modify the CSS of the input to make the color green when matching.
Muhammad Hasham
@MohammadHasham
Nov 03 2017 19:17
i have tried that but the problem is how can i make sure that i change only the particular word css change in the paragraph not the whole paragraph
Morchid Chellali
@Morched23MJ
Nov 03 2017 19:17
@MohammadHasham, you could try to set an event listening: $('input').on('focus', functionHere()); ?
Muhammad Hasham
@MohammadHasham
Nov 03 2017 19:17

the text is somewhat like this:

<p> Here goes some text </p>

@Morched23MJ @cmccormack
so how can i select a particular word and change it
Morchid Chellali
@Morched23MJ
Nov 03 2017 19:18
Using regular expressions? Depends what you want to do. Can you be more explicit?
Muhammad Hasham
@MohammadHasham
Nov 03 2017 19:20
i want to select a work from a paragraph then change its bgcolor that's it
but how do i select a specific word from a paragraph change its color and then fir it in
Christopher McCormack
@cmccormack
Nov 03 2017 19:21
@MohammadHasham you're getting the word from an input box?
Muhammad Hasham
@MohammadHasham
Nov 03 2017 19:21
yes exactly.
Christopher McCormack
@cmccormack
Nov 03 2017 19:22
@MohammadHasham so every time there is a change ('input') in the input field, you can parse the paragraph text to see if it exists. You can use regex, or you can split the string into an array and check each value against your input string
Morchid Chellali
@Morched23MJ
Nov 03 2017 19:23
@kbaig, you found any error? :l
Muhammad Hasham
@MohammadHasham
Nov 03 2017 19:23
but after splitting it i can't change the property i have tried that

for example

arr[0].style.color = "red"; does not work

Christopher McCormack
@cmccormack
Nov 03 2017 19:23
@MohammadHasham then you would need to add span tags around that word in the p, and add a style changing the color.
Muhammad Hasham
@MohammadHasham
Nov 03 2017 19:24
and then i should replace it?
Christopher McCormack
@cmccormack
Nov 03 2017 19:24
or check if there is a span and just modify the color
probably several ways to do it
Morchid Chellali
@Morched23MJ
Nov 03 2017 19:24
What you mean? You could use join(' ') after the splitting and comparing your words?
Muhammad Hasham
@MohammadHasham
Nov 03 2017 19:25

@cmccormack

is this somewhat right?

function highlight(high){
        res.forEach((value)=>{
            if(value == high){
                var para = document.createElement('p');
                var html = document.createTextNode(value);
                para.append(html);
                para.style.color= "blue";
                text.innerHTML.replace(high,para);
                console.log(high);

            }
        });
    }
Jason Luboff
@JLuboff
Nov 03 2017 19:25
@cmccormack :wave:
Christopher McCormack
@cmccormack
Nov 03 2017 19:25
@JLuboff yo
Jason Luboff
@JLuboff
Nov 03 2017 19:26
Whats up?
Christopher McCormack
@cmccormack
Nov 03 2017 19:26
@MohammadHasham you probably want to use a span if it's inline
@MohammadHasham but also consider if you do that more than once you'll keep adding span tags
@JLuboff nm, finishing up my mongodb university hw :)
Jason Luboff
@JLuboff
Nov 03 2017 19:27
@cmccormack :+1: Enjoying the course?
Muhammad Hasham
@MohammadHasham
Nov 03 2017 19:27
@cmccormack so basically doing this in any scenario is not ideal.Am i right?
Christopher McCormack
@cmccormack
Nov 03 2017 19:28
@MohammadHasham probably a good idea to maintain the original text somewhere then append your modified html in its place
Kaz Baig
@kbaig
Nov 03 2017 19:28
@Morched23MJ They will of course all happen at the same time
Christopher McCormack
@cmccormack
Nov 03 2017 19:28
@JLuboff yeah it's ok - I kind of wish the last two weeks homework were a little more involved
Muhammad Hasham
@MohammadHasham
Nov 03 2017 19:28
hmm.. @cmccormack Thanks for your time
CamperBot
@camperbot
Nov 03 2017 19:28
mohammadhasham sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1254 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Nov 03 2017 19:28
@MohammadHasham np
Kaz Baig
@kbaig
Nov 03 2017 19:28
You need to have a diff timeout, or an interval for each blip
Muhammad Hasham
@MohammadHasham
Nov 03 2017 19:28
i'll look into it.
Jason Luboff
@JLuboff
Nov 03 2017 19:29
@cmccormack Ya, the homework can also be a bit confusing/worded oddly imo
Morchid Chellali
@Morched23MJ
Nov 03 2017 19:29
@kbaig, how to re-set the one second each time then?
Kaz Baig
@kbaig
Nov 03 2017 19:29
use either setInterval or use an incremed variable and then multiply it to your interval parameter in setInterval
Christopher McCormack
@cmccormack
Nov 03 2017 19:30
@JLuboff oh I made this yesterday for fun :) https://twitter-image-api.glitch.me/%23FridayFeeling it's a crappy api for viewing images from twitter for hashtags or search queries. I'll clean it up later
/ path doesn't work haha
Morchid Chellali
@Morched23MJ
Nov 03 2017 19:30
@kbaig, same thing happening with setInterval. :l
Christopher McCormack
@cmccormack
Nov 03 2017 19:30
@JLuboff I feel like it gives you tons of information but then the homework is fairly simple.
Jason Luboff
@JLuboff
Nov 03 2017 19:31
@cmccormack Cool, but.. the images don't work?
Morchid Chellali
@Morched23MJ
Nov 03 2017 19:31
@kbaig, I do not understand why they all light up, since I'm targeting only one of them with the ID..? :l
Christopher McCormack
@cmccormack
Nov 03 2017 19:31
@JLuboff they don't? Works for me
Jason Luboff
@JLuboff
Nov 03 2017 19:31
blob
@cmccormack Console shows images are blocked becuase tracking protection is enabled?
Christopher McCormack
@cmccormack
Nov 03 2017 19:32
do you have tracking protection enabled?
are you using IE?
or Edge?
Jason Luboff
@JLuboff
Nov 03 2017 19:32
FF
And I dunno...never checked lol
Christopher McCormack
@cmccormack
Nov 03 2017 19:32
Those are straight from twitter so that's weird haha
Leave it to you to find my faults immediatly
Jason Luboff
@JLuboff
Nov 03 2017 19:33
;)
Christopher McCormack
@cmccormack
Nov 03 2017 19:33
can you try Chrome?
Jason Luboff
@JLuboff
Nov 03 2017 19:34
Chrome is good
Edge is good too
Christopher McCormack
@cmccormack
Nov 03 2017 19:35
Thanks for checking
I gotta run ttyl
Jason Luboff
@JLuboff
Nov 03 2017 19:35
See ya
Kaz Baig
@kbaig
Nov 03 2017 19:38
"Edge is good"
whaaa
Jason Luboff
@JLuboff
Nov 03 2017 19:38
In the context of his app, ya
Kaz Baig
@kbaig
Nov 03 2017 19:38
EDGE IS NEVER GOOD EEEE
Jason Luboff
@JLuboff
Nov 03 2017 19:39
In the context of using it, I don't think its that bad. I still use FF as my main, but use edge for searches and what not (microsoft rewards :+1: )
Kaz Baig
@kbaig
Nov 03 2017 19:39
What is MS rewards
Jason Luboff
@JLuboff
Nov 03 2017 19:40
You get points for searches in Bing and for using Edge (along with some daily stuff you can do). You then can cash in the points for things. I use it to get XBox Live for free
AbrisM
@AbrisM
Nov 03 2017 19:40
What does sum+= value means?
for Java
is += adding?
Kaz Baig
@kbaig
Nov 03 2017 19:40
yes
it's short for sum = sum + value
I don't know about Java but
it's that in most languages
if not all
Ashwin
@ashwins93
Nov 03 2017 19:42
yeah its the same in Java
Kaz Baig
@kbaig
Nov 03 2017 19:42
et voila
AbrisM
@AbrisM
Nov 03 2017 19:54
Thanks
Adam Faraj
@adamfaraj
Nov 03 2017 21:32
anyone here good with React?
alpox
@alpox
Nov 03 2017 21:40
@adamfaraj maybe enough. Depending on what your question is
Adam Faraj
@adamfaraj
Nov 03 2017 21:48
@alpox i think i got it. reading over the documentation. trying to understand some stuff
alpox
@alpox
Nov 03 2017 21:52
@adamfaraj alright :) dont hesitate to ask if you have further questions
Spyrantis Theodoros
@thodorisanta
Nov 03 2017 22:01
how can i add a cursor: pointer to an elements css and how can i delete it later?
alpox
@alpox
Nov 03 2017 22:45
@thodorisanta create a css rule on a class which you add to the element and later remove
Spyrantis Theodoros
@thodorisanta
Nov 03 2017 22:53
@alpox im trying to do it with raw JS and it doesnt work for some reason. isnt this supposed to add a class?
var green  = document.getElementById(green);
   green.className += " clickable";
okay i had to put green on brackets "" :P
alpox
@alpox
Nov 03 2017 23:01
@thodorisanta So it works now? :-)
@thodorisanta Btw. the better way to go is green.classList.add("clickable");
Spyrantis Theodoros
@thodorisanta
Nov 03 2017 23:02
@alpox yeah thats how i did it :) changed it later
alpox
@alpox
Nov 03 2017 23:02
And then green.classList.remove("clickable") if you want the effect gone
@thodorisanta :thumbsup:
Spyrantis Theodoros
@thodorisanta
Nov 03 2017 23:02
@alpox thanks
CamperBot
@camperbot
Nov 03 2017 23:02
thodorisanta sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1430 | @alpox |http://www.freecodecamp.com/alpox
alpox
@alpox
Nov 03 2017 23:02
@thodorisanta np :-)
Spyrantis Theodoros
@thodorisanta
Nov 03 2017 23:29
how can i make a "on class click" function that has a variable inside that takes the id of the element that was clicked? but with plain JS
Tam Nguyen
@bankplank
Nov 03 2017 23:53
Hey guys
Is there a dryer way to write this code. It is 4 different spans that will be clicked.
breakSub.addEventListener("click", function(){
    breakTime -= 1;
    breakLength.textContent = breakTime;
})

breakAdd.addEventListener("click", function(){
    breakTime += 1;
    breakLength.textContent = breakTime;
})

sessionSub.addEventListener("click", function(){
    sessionTime -= 1;
    sessionLength.textContent = breakTime;
})

sessionAdd.addEventListener("click", function(){
    sessionTime += 1;
    sessionLength.textContent = breakTime;
})