These are chat archives for FreeCodeCamp/HelpFrontEnd

14th
Dec 2017
Cristian
@GummyGod
Dec 14 2017 00:01
https://codepen.io/GummyGod/pen/dJyqKW Anyone has any ideea how i can get rid of that white space between the jumbotron and my footer at the bottom of the page?
Dan Lafferty
@DanLaff
Dec 14 2017 00:02
@linusphan Yeah, don't beat yourself up too hard about reading bad documentation. Sometimes it's just trial and error playing around with the URL Parameters to see what they do.
This is a much easier module compared to the one you are using: https://www.mediawiki.org/wiki/API:Opensearch
@GummyGod Have you tried margin-bottom: 0?
.jumbotron {
  margin-bottom: 0;
}
Cristian
@GummyGod
Dec 14 2017 00:08
@DanLaff thanks sir,i tried but i had already a custom class for the jumbotron,i redefined it and that's why it didn't worked,forgot about important,but now i've deleted it and put it in the same class,thanks again
CamperBot
@camperbot
Dec 14 2017 00:08
gummygod sends brownie points to @danlaff :sparkles: :thumbsup: :sparkles:
api offline
Linus Phan
@linusphan
Dec 14 2017 00:09
@GummyGod should I just look at codepen's solution query string?
https://en.wikipedia.org/w/api.php?origin=*&action=query&titles=how%20to%20train%20your%20dragon&prop=revisions&rvprop=content&rvsection=0&format=json&generator=allpages&gaplimit=10&gapfrom=how
I noticed that when I have multiple words, the gapfrom query only reads up to the first text
not sure if that's correct or not
Linus Phan
@linusphan
Dec 14 2017 00:50
okay I think I see the content for the wiki articles, but there is some markup on it. Do I need to parse out the data?
Kennethli36
@Kennethli36
Dec 14 2017 01:14
Hey quick noobie question, why does alert(); popup before document.write even tho i put document.write first on top? https://codepen.io/Kennayy/pen/gGJzXz
Kennethli36
@Kennethli36
Dec 14 2017 01:23
thanks @linusphan
CamperBot
@camperbot
Dec 14 2017 01:23
kennethli36 sends brownie points to @linusphan :sparkles: :thumbsup: :sparkles:
:cookie: 262 | @linusphan |http://www.freecodecamp.org/linusphan
Linus Phan
@linusphan
Dec 14 2017 01:24
@Kennethli36 did you understand it?
Kennethli36
@Kennethli36
Dec 14 2017 01:26
sort of @linusphan "modern browsers are set up such that they once they encounter a JavaScript file they will essentially pause the rendering of HTML and run though the entire JavaScript file before they resume the HTML rendering." that the main point?
this means that while the document.write does run first, you don't get to see the result of it before the rest of the file has finished executing.
Linus Phan
@linusphan
Dec 14 2017 01:31
@Kennethli36 I found that article confusing myself too. I don't really know too well either. But.... maybe it is because the code acting on the window object displays first and then document after
it might be a browser quirk, idk..
like you said, rendering of HTML is paused
that's why we put script tag at the bottom.
Good question btw, it's helped me understand a bit more too of HTML and JS
=)
Kennethli36
@Kennethli36
Dec 14 2017 01:34
Thanks for ur help :)
Linus Phan
@linusphan
Dec 14 2017 01:35
yup np
Phylicia
@pcampb22
Dec 14 2017 01:38
Hello everyone. I need your help. I have been working on the random quote challenge using sublime and when copying my information over to codepen it's not working now. I cant get a quote to generate; however, using my code outside of codepen it works. any ideas?
https://codepen.io/phyliciacampbell/pen/GOZyrQ
Trying to figure out what's the issue before even working on the twitter portion
abraham anak agung
@padunk
Dec 14 2017 01:47
@pcampb22 in codepen you can't use http try using https
Phylicia
@pcampb22
Dec 14 2017 01:49
Wow! lol something so simple. thank you so much. i didn’t know you couldn’t use https. i wonder why that is. hmmm… it works now. Thank you :-) @padunk
CamperBot
@camperbot
Dec 14 2017 01:49
pcampb22 sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 407 | @padunk |http://www.freecodecamp.org/padunk
Phylicia
@pcampb22
Dec 14 2017 01:50
i mean i didn’t know you couldn’t use http. lol @padunk typo
abraham anak agung
@padunk
Dec 14 2017 01:51
@pcampb22 np. Codepn change it because it more secure. When i made this generator i can use http.
Now i have to change it too :smile:
Phylicia
@pcampb22
Dec 14 2017 01:52
lol oh okay. that makes sense. good thing to keep in mind now moving forward. I was like what the heck happened and been googling and looking for solutions to why it wouldn’t be working for days now. lol thanks a lot. now i can finally finish and do some tweaking on the looks and turn it in and move on to the next challenge lol
@padunk
Linus Phan
@linusphan
Dec 14 2017 01:53
if anyone can help me on the wiki viewer please let me know, I've been so stuck for hours
thanks
abraham anak agung
@padunk
Dec 14 2017 01:58
@linusphan what is you stuck with?
Linus Phan
@linusphan
Dec 14 2017 02:12
@padunk I think I'm stuck on getting the right URL
When I go to view the content of an article, I see wikitext. I'm trying to get it to become regular text so I can render that onto the HTML
abraham anak agung
@padunk
Dec 14 2017 02:34
@linusphan this article is good about Wikipedia viewer https://medium.com/@vampiire/free-code-camp-wikipedia-viewer-ce50db09e35b
Linus Phan
@linusphan
Dec 14 2017 02:38
@padunk thx
CamperBot
@camperbot
Dec 14 2017 02:38
linusphan sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 408 | @padunk |http://www.freecodecamp.org/padunk
Linus Phan
@linusphan
Dec 14 2017 02:38
I can't see the site now bc the connection is blocked
but I'll take a look at it when I can I bookmarked it
abraham anak agung
@padunk
Dec 14 2017 02:39
@linusphan np. wikipedia api is painful to deal with. take your time to understand it.
Barbara Pentoney
@flyfishingbarbara
Dec 14 2017 02:51

hi can someone help me with this challenge....it is not passing. function confirmEnding(str, target) {

return str.substring(str.length-1)==target;

}

confirmEnding("He has to give me a new name", "name");

its the 'confirm ending' challenge...
abraham anak agung
@padunk
Dec 14 2017 02:53
@flyfishingbarbara str.substring(str.length-1) will return e
Barbara Pentoney
@flyfishingbarbara
Dec 14 2017 02:55
@padunk any hint I can research to include not just the last character but the word..??
abraham anak agung
@padunk
Dec 14 2017 02:56
@flyfishingbarbara read the docs about substring, substr or slice. Here is the docs about substring
It will be quicker to use .endsWith but i don't think you can use it in this challenge
Barbara Pentoney
@flyfishingbarbara
Dec 14 2017 03:02
@padunk thanks, yah, they don't want you to use endswith....ok so I looked at doc... so would I just do ie -4 instead of the -1 to 'collect' all 4 letters of the word 'name'...??
CamperBot
@camperbot
Dec 14 2017 03:02
flyfishingbarbara sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 409 | @padunk |http://www.freecodecamp.org/padunk
abraham anak agung
@padunk
Dec 14 2017 03:03
@flyfishingbarbara yes, but consider if the target is not name then you need to change the number 4 to whatever the target length is
Barbara Pentoney
@flyfishingbarbara
Dec 14 2017 03:04
@padunk I know, saw that...cuz now "bastian","n" doesn't work.... arghhh
abraham anak agung
@padunk
Dec 14 2017 03:06
@flyfishingbarbara my last comment have a hint for you. target length
Barbara Pentoney
@flyfishingbarbara
Dec 14 2017 03:08
@padunk ok thanks i'll take a look at 'target length' and see if I can figure it out....thanks for help
CamperBot
@camperbot
Dec 14 2017 03:08
flyfishingbarbara sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
api offline
Oxide Debbarma
@oxide94Git
Dec 14 2017 03:08
hello buddies, what are the possible main values at "https://fcc-weather-api.glitch.me/" , for example: "Fog", "Mist" etc.
kerafyrm02
@kerafyrm02
Dec 14 2017 03:19
Anyone stuck?
VaseJS
@VaseJS
Dec 14 2017 03:53
@kerafyrm02 I'm always stuck :P
Minoy
@minoy
Dec 14 2017 04:32
Hello!
I have a general Git/collaborative development question - When multiple developers are working on different pages of a web app, is it advisable to maintain separate CSS and JS files? What is the preferred way of handling this? Do developers maintain separate JS and CSS files and then in the end all are integrated into a single JS and CSS file?
jokerrapeu
@jokerrapeu
Dec 14 2017 04:33
@kerafyrm02 same i will stuck too
VaseJS
@VaseJS
Dec 14 2017 04:37
@minoy that's not an easy question to answer as more details would be needed. but first, you should always have seperate files for your js and css. Actually, you should keep multilple css and js files for each component you're dealing with.
kerafyrm02
@kerafyrm02
Dec 14 2017 04:37
what are you stuck on
VaseJS
@VaseJS
Dec 14 2017 04:38
ex...
kerafyrm02
@kerafyrm02
Dec 14 2017 04:38
@minoy typically i just name the js file after whatever im working on..then use a compressor to combine all the files together just before sending over the server
VaseJS
@VaseJS
Dec 14 2017 04:39
Screen Shot 2017-12-13 at 10.38.48 PM.png
Minoy
@minoy
Dec 14 2017 04:39
@kerafyrm02 can the same be done for css files as well?
kerafyrm02
@kerafyrm02
Dec 14 2017 04:39
yup
VaseJS
@VaseJS
Dec 14 2017 04:39
@minoy hope that answers your question
kerafyrm02
@kerafyrm02
Dec 14 2017 04:40
just concat all the files together and strip out comments (usually most compressors do that already)
remove all white space
VaseJS
@VaseJS
Dec 14 2017 04:40
there are tools to combine and compress your files when you are done. but based on your question, that's not important right now
kerafyrm02
@kerafyrm02
Dec 14 2017 04:40
if you're woking on a slider ... call it slider.js
Minoy
@minoy
Dec 14 2017 04:41
@VaseJS Thanks! Yes I understand that I should keep separate css and js files
CamperBot
@camperbot
Dec 14 2017 04:41
minoy sends brownie points to @vasejs :sparkles: :thumbsup: :sparkles:
:cookie: 362 | @vasejs |http://www.freecodecamp.org/vasejs
Minoy
@minoy
Dec 14 2017 04:41
@kerafyrm02 Thanks!
CamperBot
@camperbot
Dec 14 2017 04:41
minoy sends brownie points to @kerafyrm02 :sparkles: :thumbsup: :sparkles:
:cookie: 264 | @kerafyrm02 |http://www.freecodecamp.org/kerafyrm02
VaseJS
@VaseJS
Dec 14 2017 04:41
love my cookies!
kerafyrm02
@kerafyrm02
Dec 14 2017 04:41
but just be sure that you dont connect that many individually without combining them
Minoy
@minoy
Dec 14 2017 04:41
@VaseJS @kerafyrm02 Could you name some such compression tools? We will need them soon.
VaseJS
@VaseJS
Dec 14 2017 04:41
you don't have to connect them as there are methods for using them like that
just google css compression and you'll get tools. but your command line can do it natively
Minoy
@minoy
Dec 14 2017 04:42
ok
VaseJS
@VaseJS
Dec 14 2017 04:42
assuming you know the cli (command line interface)
kerafyrm02
@kerafyrm02
Dec 14 2017 04:45
i use a php class to compress mine
jokerrapeu
@jokerrapeu
Dec 14 2017 04:46
@kerafyrm02 rofl php class to compress mine
kerafyrm02
@kerafyrm02
Dec 14 2017 04:47
why is that funny
jokerrapeu
@jokerrapeu
Dec 14 2017 04:48
hahahah yeah thats funny, i think all programmer can stuck with the code
kerafyrm02
@kerafyrm02
Dec 14 2017 04:49
Not exactly sure what you're trying to say.
BuntyBru
@BuntyBru
Dec 14 2017 07:19
Hey guys looking for a small help here
i want the hour clock to be a bit small
.hour class
Yannick Wiley
@ywiley94
Dec 14 2017 07:36
Hey was wondering if anyone had suggestions or pointers on how i should start to build my javascript simon says game. or does anyone want to work on it together?
linkin-park
@linkin-park
Dec 14 2017 08:02
hi
linkin-park
@linkin-park
Dec 14 2017 08:08
a little help
anyone here?
Markus Kiili
@Masd925
Dec 14 2017 08:09
@linkin-park Hi. Just post the question here. Usually someone answers.
linkin-park
@linkin-park
Dec 14 2017 08:09
@Masd925 okay , well not sure this is the right place
most active place though :)
i'm looking for funding on my project
where to look on this ?
please suggest
Markus Kiili
@Masd925
Dec 14 2017 08:20
@linkin-park Bank, rich wife/spouse, crowd funding, find an investor or partners willing to invest. Government might also have some programs that invest or loan to small companies. Hard to say anything without knowing more about the project.
Richard
@rylew0925
Dec 14 2017 08:46
Would someone please explain what the first line of this code does?


var re = /(\w+)\s(\w+)/;
var str = 'John Smith';
var newstr = str.replace(re, '$2, $1');
console.log(newstr);  // Smith, John
peggylai
@peggylai
Dec 14 2017 08:48
it's a regular expression
Zaw Mai
@zawmai
Dec 14 2017 08:49
@rylew0925 it's called a regular expression. It's a pattern (you can specify) to match words or phrases in a string.
peggylai
@peggylai
Dec 14 2017 08:49
such as email address or file name @rylew0925
Richard
@rylew0925
Dec 14 2017 08:50
So what exactly does "var re = /(\w+)\s(\w+)/;" read as?
Zaw Mai
@zawmai
Dec 14 2017 08:50
/your regex goes here/
the parentheses capture matches into groups
"\w" is a special term to match alphanumeric characters (so 0-9, a-z, A-z)
peggylai
@peggylai
Dec 14 2017 08:53
@rylew0925 you can reference here there are more detailed explanation https://www.ntu.edu.sg/home/ehchua/programming/howto/Regexe.html
Zaw Mai
@zawmai
Dec 14 2017 08:54
"+" is called a quantifier. In this case, the plus sign says regex must match 1 or more of alpha numeric characters.
linkin-park
@linkin-park
Dec 14 2017 08:54
thats soo abstract answer
Zaw Mai
@zawmai
Dec 14 2017 08:54
@linkin-park yeah.
https://pythex.org/
play with regex using the above link.
there's also a cheatsheet
so you can identify what all symbols mean in regex
@rylew0925 I suggest tweaking the above regex
so like start with "/(\w+)' then add the other terms and how matches change.
Richard
@rylew0925
Dec 14 2017 08:57
thanks you'all!
Zaw Mai
@zawmai
Dec 14 2017 08:59
@rylew0925 here's an exercise:
Try matching only the words within the anchor tags from the following string "<a>only match what iss between these tags</a>"
Nica
@nicanope
Dec 14 2017 11:27
Hi! I'm really really new so excuse if this q is super basic, but I'm trying to use figure and figcaption on codepen and it is not taking it... does it never or am I doing something wrong?
primuscovenant
@primuscovenant
Dec 14 2017 11:56
@heroiczero tx
CamperBot
@camperbot
Dec 14 2017 11:56
primuscovenant sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 2105 | @heroiczero |http://www.freecodecamp.org/heroiczero
gaitchs gangmei
@gaitchs
Dec 14 2017 12:03
my website banner image is not streching according to mobile screen
suppose to be responsive website
Marianissimus
@Marianissimus
Dec 14 2017 12:08
@gaitchs send codepen, link or something...
this website
gaitchs gangmei
@gaitchs
Dec 14 2017 13:18
.flexslider {
text-align: center;
text-transform: uppercase;
color: #fff;
margin: 0;
padding: 0;
border: 0;
overflow-x: hidden;
background: transparent;
background-image: url('../images/header.png');
background-repeat: no-repeat;
background-size: cover;
}
this is the CSS
creator0323
@Amasian
Dec 14 2017 13:20
If someone realize specific functions using J-query, do they always can make same functions with pure Javascript? Recently I asked a few question on how to make specific things when build website, They kept saying that I need to learn J-query. I know it is easy to use and make code short, but it is just a library. Is it recommended to learn J-query when I can not fully understand Javascript and not realize specific effects with it?
Markus Kiili
@Masd925
Dec 14 2017 13:21
@Amasian jQuery is a JS library, so it is just a bunch of JS objects and functions.
@Amasian jQuery solves some cross-browser issues and makes ajax requests and dom manipulation a bit easier.
I think that it is good to first do things with pure JS and then learn jQuery if you like.
creator0323
@Amasian
Dec 14 2017 13:38
@Masd925 Thank you for your advice :)
CamperBot
@camperbot
Dec 14 2017 13:38
amasian sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4612 | @masd925 |http://www.freecodecamp.org/masd925
steamedapples
@steamedapples
Dec 14 2017 13:45
ack, is this the right place to ask for help about personal projects?
DecisiveIndecisive
@DecisiveIndecisive
Dec 14 2017 13:46
@steamedapples Sure is
steamedapples
@steamedapples
Dec 14 2017 13:52
alright uh
https://codepen.io/steamedapples/pen/MrwWQE?editors=1010
i'm trying to make a clicker game for fun
coins are supposed to increase after a set period of time when you hit 50cm, but autoCoin() isn't running?
DecisiveIndecisive
@DecisiveIndecisive
Dec 14 2017 13:59
The problem is your if statement isn't running
Put your if statement inside of updateHeight, and then it will check it everytime updateHeight is called
steamedapples
@steamedapples
Dec 14 2017 14:02
now it runs one instance of autoCoin() every time i click
i could probably use a true/false to get around this, but is there a better way?
Stephen James
@sjames1958gm
Dec 14 2017 14:08
@steamedapples you could use == 50 then it will only happen when you exactly hit 50
DecisiveIndecisive
@DecisiveIndecisive
Dec 14 2017 14:09
@sjames1958gm I thought of the same thing, but if the user happens to click multiple times during 50 (which will happen if they're clicking continuously very fast from the beginning) then it will trigger multiple times
@steamedapples Nothing comes to mind immediately but at least it's being called now :P I'm sure you'll figure it out
Stephen James
@sjames1958gm
Dec 14 2017 14:10
@DecisiveIndecisive The height is increased synchronously so it can't be 50 more than once.
DecisiveIndecisive
@DecisiveIndecisive
Dec 14 2017 14:11
Oh shit, good point
I should have tried it before writing it off haha
VaseJS
@VaseJS
Dec 14 2017 14:13
@Amasian people are not good a learning more than happy to be learning at times so they go with what is popular lack foresight when not thinking for themselves. I refuse to use jquery and am a better programmer for it. I suggest you do the same. don't jump on the bandwaggon
steamedapples
@steamedapples
Dec 14 2017 14:15
@DecisiveIndecisive @sjames1958gm
nice, it's working now. thanks a lot!
CamperBot
@camperbot
Dec 14 2017 14:15
steamedapples sends brownie points to @decisiveindecisive and @sjames1958gm :sparkles: :thumbsup: :sparkles:
api offline
:star2: 8777 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Dec 14 2017 14:15
@steamedapples :+1:
creator0323
@Amasian
Dec 14 2017 14:21
@VaseJS Thank you so much for your advice :)
CamperBot
@camperbot
Dec 14 2017 14:21
amasian sends brownie points to @vasejs :sparkles: :thumbsup: :sparkles:
:cookie: 363 | @vasejs |http://www.freecodecamp.org/vasejs
VaseJS
@VaseJS
Dec 14 2017 14:23
@Amasian no problem. coding is all about the next new thing but everytime you learn a 'library' you don't understand what's happening in the background, that library is holding you back, not helping you
there is nothing wrong with them but only after you understand what and why they do what they do. its not about speed all the time. that's a trap
AbrisM
@AbrisM
Dec 14 2017 14:25
We weren't allowed to use jquery
Perhaps next class we will be able to. jquery has some interesting animations. Webkits on the other hand is completely server-like related
creator0323
@Amasian
Dec 14 2017 14:25
@VaseJS Yes Actually that's what I concern most I do not even understand of code flow so I think I need to focus more on realizing functions using pure JS
@AbrisM Do you learn it from the school?
VaseJS
@VaseJS
Dec 14 2017 14:28
@Amasian refuse to use jquery until you understand what its doing...but by then, you likely won't need it depending on the project. jquery is good for cross browser support IF you need to support older browsers.
creator0323
@Amasian
Dec 14 2017 14:29
@VaseJS Absolutely! I will focus on it! thank you so much
CamperBot
@camperbot
Dec 14 2017 14:29
amasian sends brownie points to @vasejs :sparkles: :thumbsup: :sparkles:
api offline
VaseJS
@VaseJS
Dec 14 2017 14:29
here are some things that will help you as people will keep trying to say 'use jquery'
look up harry roberts and read his entire blog and start using his meta framework IT
he is one of the best in the world at css
creator0323
@Amasian
Dec 14 2017 14:30
I will visit there right away
Donte Hightower
@dhightower4
Dec 14 2017 14:36
Hey guys, been working on a couple of front-end projects, but I don't really have an eye for creating good looking designs. Any tips on where I could learn things like that for free to no cost?
Sly Fox
@Gurukorgi
Dec 14 2017 15:04
please guys can any of you help with any application or website that i can us to track my stolen phone with the imei number
*please guys can any of you help with any application or website that i can use to track my stolen phone with the imei number
VaseJS
@VaseJS
Dec 14 2017 15:09
@Gurukorgi are you looking to build one or use one
prey is a good one
Sly Fox
@Gurukorgi
Dec 14 2017 15:09
here is my email : miraclonic1@gmail
VaseJS
@VaseJS
Dec 14 2017 15:09
if using an apple, its built in
Sly Fox
@Gurukorgi
Dec 14 2017 15:09
no my phone was stolen i want to track
i want to use it to get the location of my phone
Donte Hightower
@dhightower4
Dec 14 2017 15:11
if you had an apple phone, there is "find my iphone"
Sly Fox
@Gurukorgi
Dec 14 2017 15:12
no its an android
infinix hot 4 to be precise
Donte Hightower
@dhightower4
Dec 14 2017 15:13
hmm i don't know of any automatic registration for android phones. find my device may be active since you have a gmail, if you signed in to it on your phone.
otherwise, I'm out of suggestions :/
Sly Fox
@Gurukorgi
Dec 14 2017 15:13
all i need is the to get the location
Sly Fox
@Gurukorgi
Dec 14 2017 15:14
the exact location
mohit singh
@mritunjaygoutam12
Dec 14 2017 15:20
Pleases ,
Why my background-color extended more to right
dinesh
@1532j0004kg
Dec 14 2017 15:21
share the code!
we will check!
mohit singh
@mritunjaygoutam12
Dec 14 2017 15:22
ok, i am doing
dinesh
@1532j0004kg
Dec 14 2017 15:22
ok
Sly Fox
@Gurukorgi
Dec 14 2017 15:23
it did not work
dinesh
@1532j0004kg
Dec 14 2017 15:24
i think the app findmyphone is good to find.
if ur mailid was loggedin !
mohit singh
@mritunjaygoutam12
Dec 14 2017 15:31
@1532j0004kg see this screeshot link
dinesh
@1532j0004kg
Dec 14 2017 15:33
work with grids may be it will usefull!!!
mohit singh
@mritunjaygoutam12
Dec 14 2017 15:34
ok , i am trying.
dinesh
@1532j0004kg
Dec 14 2017 15:34
well!
David Morais
@psybork
Dec 14 2017 15:34
@mritunjaygoutam12 would be easier to just share your code...
DecisiveIndecisive
@DecisiveIndecisive
Dec 14 2017 16:51
Does anyone have any experience creating tooltip triangles to attach to various sections of a div?
VaseJS
@VaseJS
Dec 14 2017 17:17
@DecisiveIndecisive yea, what do you need
DecisiveIndecisive
@DecisiveIndecisive
Dec 14 2017 17:25
Well, at this point I've decided to forfeit my own tooltip with a bottom right triangle and try to use what I've found in w3schools for tooltip, but the classes are confusing to me -.-
Sorry, I know that wasn't a question haha, I'm going to continue trying to figure it out on my own for now
Teo
@Teo03
Dec 14 2017 18:13
Can someone help me here with the simon game. I need to make the game wait 1 second after random click, then continue with the other clicks because the tiles are always clicked at the same time and the user can not tell the difference what was clicked first.
https://codepen.io/Teo03/pen/mpbdPE
BrianWilliams28
@BrianWilliams28
Dec 14 2017 18:16
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
how would i access the 2nd and 3rd properties of a multi-level object like this? like add / delete items. all the examples on FCC lessons show a 1 dimensional object such as the below.
var ourDog = {
  "name": "Camper",
  "legs": 4,
  "tails": 1,
  "friends": ["everything!"]
};
Aditya
@ezioda004
Dec 14 2017 18:24
@BrianWilliams28 You can access them just like you accessed 2D arrays, by chaining. Example say you wanna access "Robert Palmer" from "1245", you can type collection["1245"].artist;. Note that I used [ ] notation for accessing "1245" because is a number so you have to use bracket notation for that.
David Morais
@psybork
Dec 14 2017 18:36
@Teo03 , use setTimeout()
Teo
@Teo03
Dec 14 2017 18:37
@cyborkonline I tried but I don't know where to place it
Kudzu
@czhower
Dec 14 2017 18:38
Wherever you want to initiate the timeout.
David Morais
@psybork
Dec 14 2017 18:38
what @czhower said :P, place it after the random click function is called.
Teo
@Teo03
Dec 14 2017 18:42
``` 
function newSeq() {
var addRandom = Math.floor(Math.random() * 4) + 1;
compSeq.push(addRandom);
compBlink();
setTimeout(function(){
console.log("making new click...");
}, 2000);
console.log("compSeq: " + compSeq);
}
```
Like this?
Kudzu
@czhower
Dec 14 2017 18:43
Arrow syntax is a bit cleaner and preferred but otehrwise looks fine.
() => { console.log....
2000 is a bit long. If you just need to force a UI update by leaving the event, then you can specify 0 and it will call it immediately after but update UI first. Many DOM repaints are delayed till an event exits.
Teo
@Teo03
Dec 14 2017 18:45
@czhower but still doesen't work
Kudzu
@czhower
Dec 14 2017 18:50
set some breakpoints, trace and watches.
Teo
@Teo03
Dec 14 2017 18:51
@czhower I tried but I can't figure it out
BrianWilliams28
@BrianWilliams28
Dec 14 2017 19:36
@ezioda004 thank you, so I can use the dot notation for strings and bracket notation for numbers correct?
CamperBot
@camperbot
Dec 14 2017 19:36
:cookie: 318 | @ezioda004 |http://www.freecodecamp.org/ezioda004
brianwilliams28 sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
Kris Baillargeon
@krisb1220
Dec 14 2017 19:55
Yes @BrianWilliams28
But be careful with numbers, it's looking for a property not an index
Onome Sotu
@onomesotu
Dec 14 2017 20:15
Helloo
Does anyone know how to handle a CORS request in vanilla js?
This is mine, but i still get ACCESS control errors
const normalSearchButton = document.getElementsByClassName('buttons__search');

normalSearchButton[0].addEventListener('click', makeCORSRequest, false);

function createCORSRequest(method, url) {
    var request = new XMLHttpRequest();
    if ('withCredentials' in request){
        request.open(method, url, true);
    } else if (typeof XDomainRequest != 'undefined'){
        request = new XDomainRequest();
        request.open(method, url);
    } else {
        request = null;
    }
    return request;
}

function makeCORSRequest(e) {
    e.preventDefault();
    const inputText = document.getElementById('search').value;
    const wikipediaAPI = 'https://en.wikipedia.org/w/api.php?action=opensearch&search=' + inputText + '&limit=2&namespace=0&format=json';
    const request = createCORSRequest('GET', wikipediaAPI);
    if(!request) {
        console.log('CORS not supported');
        return;
    }

    request.onload = function(e){
        if(this.readyState === 4){
            if(this.status >= 200 && this.status <= 400){
                console.log(this.responseText);
            } else {
                console.error(this.statusText);
            }
        }
    };

    request.onerror = function(e){
        console.log(request.statusText);
    };

    request.send(null);
}
Stephen James
@sjames1958gm
Dec 14 2017 20:18
@onomesotu For that API just add origin=* to the URL as a query parameter
Onome Sotu
@onomesotu
Dec 14 2017 20:20
Like so?: const wikipediaAPI = 'https://en.wikipedia.org/w/api.php?action=opensearch&search=' + inputText + '&limit=2&namespace=0&origin=*&format=json';
Stephen James
@sjames1958gm
Dec 14 2017 20:20
YEs
Onome Sotu
@onomesotu
Dec 14 2017 20:20
what does that do? or what is the purpose?
Stephen James
@sjames1958gm
Dec 14 2017 20:21
If you use that then the API will send the correct headers that allow the browser to accept cross domain responses
It is specific to the Wikipedia API
Onome Sotu
@onomesotu
Dec 14 2017 20:22
oh.. i see
So I didn't really need a CORS request?
Could i have done it with a basic XMLHTTPRequest?
Stephen James
@sjames1958gm
Dec 14 2017 20:23
Yes, for this API. You could even use the fetch browser API
Onome Sotu
@onomesotu
Dec 14 2017 20:27
Ok thanks. It is clear now...
Ruben Abraham
@BuBBRBbr1
Dec 14 2017 20:27
Hey guys,I have a question. When I am on codepen, the only language that is recognized and loads is the HTML language. Why is this?
Onome Sotu
@onomesotu
Dec 14 2017 20:27
@BuBBRBbr1 CSS and JS also loads
Ruben Abraham
@BuBBRBbr1
Dec 14 2017 20:28
Not for me.
Onome Sotu
@onomesotu
Dec 14 2017 20:28
@BuBBRBbr1 Can you send a link to an example?
Ruben Abraham
@BuBBRBbr1
Dec 14 2017 20:29
image.png
The CSS commands are not inputed at all on this tribute page.
Onome Sotu
@onomesotu
Dec 14 2017 20:30
@sjames1958gm In jquery, we can pass data to the ajax call with the data key, do we have something like this for vanillaJS?
Stephen James
@sjames1958gm
Dec 14 2017 20:30
@BuBBRBbr1 You should only have css in the css section I see html.
The same for js section - no <script> tag
Ruben Abraham
@BuBBRBbr1
Dec 14 2017 20:31
OH
Stephen James
@sjames1958gm
Dec 14 2017 20:33
@onomesotu I assume so, but I am not real familiar with xmlHttpRequest
Onome Sotu
@onomesotu
Dec 14 2017 20:34
ok.. i'll search on SO
Onome Sotu
@onomesotu
Dec 14 2017 20:38
@sjames1958gm Thank you
CamperBot
@camperbot
Dec 14 2017 20:38
onomesotu sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8779 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Christopher Susi
@chrisandsuch
Dec 14 2017 20:38
Hey everyone, could someone give me some feedback on this project? Having some issues with responsiveness. https://codepen.io/chrisandsuch/pen/YYXQoK
Stephen James
@sjames1958gm
Dec 14 2017 20:38
@onomesotu :+1:
Onome Sotu
@onomesotu
Dec 14 2017 20:41
@chrisandsuch maybe you want to change the mouse to a pointer for the all, online and offline button
And when all users are showing, the page doesn't scroll
BrianWilliams28
@BrianWilliams28
Dec 14 2017 20:50
how do i add an array element into an object property?
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
i want to add a "tracks": [ ] under 5439
Onome Sotu
@onomesotu
Dec 14 2017 20:51
@sjames1958gm in the wikipedia sandbox, and on the web browser, I get a simple array object as response, but on the console, i get am entire web page using the same API url.. can you help?
@BrianWilliams28 do you want to loop through the object or you just want to add it directly?
BrianWilliams28
@BrianWilliams28
Dec 14 2017 20:52
@onomesotu i want to add it directly
Stephen James
@sjames1958gm
Dec 14 2017 20:52
@onomesotu console.log the URL and the paste into your address bar of the browser - the entire web page means some kind of error
BrianWilliams28
@BrianWilliams28
Dec 14 2017 20:52
@BrianWilliams28 i want to add the empty array and then a value to it
Stephen James
@sjames1958gm
Dec 14 2017 20:52
@BrianWilliams28
collection[id].tracks = [];
BrianWilliams28
@BrianWilliams28
Dec 14 2017 20:53
@sjames1958gm thank you
CamperBot
@camperbot
Dec 14 2017 20:53
brianwilliams28 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8780 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Dec 14 2017 20:53
@BrianWilliams28 :+1:
Onome Sotu
@onomesotu
Dec 14 2017 20:53
collection['5439'].tracks
restrepomich
@restrepomich
Dec 14 2017 20:54
Hey guys, could I get a second pair of eyes on my code, please? I'm having trouble having the counter stop on scroll and it keeps looping
Aditya
@ezioda004
Dec 14 2017 20:54
@BrianWilliams28 Dot notation for strings that doesn't have space b/w them. Example you can't use dot notation for a key called "first name". You need to use bracket notation for that. Also, dot notation only works with property names that are valid identifiers. An identifier must start with a letter, $, _ or unicode escape sequence. For all other property names, you must use bracket notation.
Onome Sotu
@onomesotu
Dec 14 2017 20:55
@sjames1958gm yeah, I have done that.. i get a decent json when i paste the url in the browser, but a full web page on the console
BrianWilliams28
@BrianWilliams28
Dec 14 2017 20:55
@ezioda004 thanks for the tips
CamperBot
@camperbot
Dec 14 2017 20:55
brianwilliams28 sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 319 | @ezioda004 |http://www.freecodecamp.org/ezioda004
restrepomich
@restrepomich
Dec 14 2017 20:55
Everytime I scroll, the timer resets. I just need the timer to fire once it appears on the viewport and not loop if I continue to scroll
Isaiah Trembley
@IsaiahCT
Dec 14 2017 21:09
hm...
so, with my timer formy portfolio, I am trying to get it down to a certain date(which I have)
the problem is that my timer won't show up in my browser, but works in codepen
NM
I didn't add the path
lmaooo
Tom
@moT01
Dec 14 2017 21:43
@restrepomich put a boolean in there
var timerStarted = false;
$(window).scroll(function(){
  if(!timerStarted) {
  function elementScrolled(elem)
  {
    var docViewTop = $(window).scrollTop();
    var docViewBottom = docViewTop + $(window).height();
    var elemTop = $(elem).offset().top;
    return ((elemTop <= docViewBottom) && (elemTop >= docViewTop));
  }

  if(elementScrolled('.counter')) {
  timerStarted = true;
i think something like that would work
i didnt look at the code too much - so i dont know what it all does - but maybe something along those lines
restrepomich
@restrepomich
Dec 14 2017 21:48
@moT01 Oh my goodness, that worked!
Thank you so much @moT01 ! I'm trying to dissect what you did
CamperBot
@camperbot
Dec 14 2017 21:49
restrepomich sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 930 | @mot01 |http://www.freecodecamp.org/mot01
AbrisM
@AbrisM
Dec 14 2017 22:51
@Amasian Majority of my programming I do learn from a school, yes
The jquery part I am learning on my own. They don't like jquery or libraries, it seems
Stephen James
@sjames1958gm
Dec 14 2017 23:10
@onomesotu Sorry I had to get a new battery for my car, I hope you got it working
alpox
@alpox
Dec 14 2017 23:20
@sjames1958gm i hope so too for you :)