These are chat archives for FreeCodeCamp/HelpFrontEnd

14th
Jan 2018
Marc
@MWBauer
Jan 14 2018 00:12 UTC
Hey everyone!
anyone?
rscales02
@rscales02
Jan 14 2018 00:15 UTC
Howdy
Marc
@MWBauer
Jan 14 2018 00:22 UTC
Hiya' scales
YOu busy?
Stephen James
@sjames1958gm
Jan 14 2018 00:44 UTC
@MWBauer :wave:
Marc
@MWBauer
Jan 14 2018 00:46 UTC
Hiya' @sjames1958gm
How ya' doin'?
Stephen James
@sjames1958gm
Jan 14 2018 00:48 UTC
@MWBauer Good
Taking a Udemy React Native course
Marc
@MWBauer
Jan 14 2018 00:58 UTC
I saw they were having a big sale. Wish I had the money and time to take advantage of that. I'm feeling stupid, like I can't actually do this.
Stephen James
@sjames1958gm
Jan 14 2018 01:00 UTC
@sjames1958gm The knowledge builds over time. practicing as often as possible is important in recording common patterns in your brain.
Omar Tan
@wheelhot
Jan 14 2018 01:03 UTC

don't know @wheelhot should take care about it. here a good article about it: https://www.sitepoint.com/event-bubbling-javascript/

Sorry, just woke up. Thanks! @sorinr @HeinousTugboat and @ezioda004 , I’ll give it a look and maybe I’ll give this code so you all understand my question better

<!—the li arebuttonsin the page—>
<ul>
    <li>Unit 1</li>
    <li>Unit 2</li>
    <li>Unit 3</li>
</ul>

So how can I make JS to recognise which of the li is clicked, cause at the moment, when I use eventlistener, it’ll display all the li elements eventhough I just click on Unit 1. Do I have to create an ID/Class for each of the li? And wouldn’t this be difficult if you have 1000 links and having to create an ID for each of the li?

CamperBot
@camperbot
Jan 14 2018 01:03 UTC
wheelhot sends brownie points to @heinoustugboat and @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 316 | @heinoustugboat |http://www.freecodecamp.org/heinoustugboat
:cookie: 380 | @ezioda004 |http://www.freecodecamp.org/ezioda004
Alexander Jarman
@HeinousTugboat
Jan 14 2018 01:17 UTC
@wheelhot If you've got 1000 links, I'd add an event listener on the <ul> and discriminate what I do with the event based on Event.target.
Henry
@GitHub-Henry
Jan 14 2018 01:26 UTC
@MWBauer most folks need time to find the teacher, learn the skill, learn the patterns needed to do specific
tasks, and the repetition to build mastery, and all that takes time. Don't be discouraged if you discover that it takes more time to learn that you expect, that's true for most of us.
Omar Tan
@wheelhot
Jan 14 2018 01:28 UTC
Okay, I’ll look into EventTarget, thanks @HeinousTugboat
CamperBot
@camperbot
Jan 14 2018 01:28 UTC
wheelhot sends brownie points to @heinoustugboat :sparkles: :thumbsup: :sparkles:
api offline
Alexander Jarman
@HeinousTugboat
Jan 14 2018 01:29 UTC
Omar Tan
@wheelhot
Jan 14 2018 01:39 UTC
@HeinousTugboat Reading through it, meanwhile I tried event.target but it seems it’s not working , here’s my code
            <ul id="filterStatus">
                <li>ALL</li>
                <li class="inactive">ONLINE</li>
                <li class="inactive">OFFLINE</li>
            </ul>
var filterStatus = document.getElementById("filterStatus");
filterStatus.addEventListener('click', function () {
    var li = document.getElementsByTagName('li');
    console.log(li.target);
}, false);
On Chrome, I’ll get undefined each time I click on the li
Alexander Jarman
@HeinousTugboat
Jan 14 2018 01:41 UTC
Try this:
var filterStatus = document.getElementById("filterStatus");
filterStatus.addEventListener('click', function (ev) {
    console.log(ev.target);
}, false);
Omar Tan
@wheelhot
Jan 14 2018 01:42 UTC
Thanks! that works!
Alexander Jarman
@HeinousTugboat
Jan 14 2018 01:42 UTC
NP! And yeah, with event handlers, you pretty much want to stick with the event that's passed in through the parameters.
Omar Tan
@wheelhot
Jan 14 2018 01:42 UTC
So in this case, the event listener will keep track of any elements in the ul?
Alexander Jarman
@HeinousTugboat
Jan 14 2018 01:43 UTC
So, when an event is dispatched, the browser will create a new Event, then assign its target field to the element that caused the event.
Omar Tan
@wheelhot
Jan 14 2018 01:43 UTC
aaah, is that why I don’t have to tell the browser that I want to target the li elements?
Alexander Jarman
@HeinousTugboat
Jan 14 2018 01:44 UTC
So when you click an <li>, the browser will generate a MouseEvent with the click type, hand it off to the <html> element, and then pass it down parent-to-child until it hits the <li>. Once the <li> handles it, it'll then return it back up to its parent element.
Event.currentTarget is the element that's currently looking at the Event.
Omar Tan
@wheelhot
Jan 14 2018 01:45 UTC
okay, I’m going to screenshot this and refer it back later, hhaa
Alexander Jarman
@HeinousTugboat
Jan 14 2018 01:45 UTC
So if you attach a click handler to, say <body>, and the same handler to every <li>, you can verify whether the handler's <li> currently getting the event from one of the <li> elements or from the <body> element, but all of them will know which element was actually clicked.
Make sure and hang on to the links from earlier, too. I've actually read over the capturing v. bubbling one three or four times now. It's ridiculously useful.
And I still have to go build little Event trees with nested elements to remember how to do what with them.
Omar Tan
@wheelhot
Jan 14 2018 01:46 UTC
interesting, I guess this is the more advance aspect of Front End Dev? Event trees and what not
Alexander Jarman
@HeinousTugboat
Jan 14 2018 01:46 UTC
So, like @sorinr said, take care about how you handle it.
Omar Tan
@wheelhot
Jan 14 2018 01:46 UTC
😂
Alexander Jarman
@HeinousTugboat
Jan 14 2018 01:47 UTC
I don't know that it's more advanced, just really easy to make a mess of it.
Omar Tan
@wheelhot
Jan 14 2018 01:48 UTC

Oh yeah, when you said

NP! And yeah, with event handlers, you pretty much want to stick with the event that's passed in through the parameters.

Care to explain a lil further? As I’m quite blur on these stuffs

Alexander Jarman
@HeinousTugboat
Jan 14 2018 01:49 UTC
So, when you're actually hooking up an event, all you're doing is telling a particular Element that you want a function called every time it sees a particular event.
James Moore
@James-N-M
Jan 14 2018 01:50 UTC
    border: 1px solid black; 
    display: block; 
    margin: 0 auto;
    max-width: 100%; 
}

.header{
    text-align: center; 
}

.cell{
    background-color: black; 
    height: 10px;
    width: 10px; 
    display: inline-block; 
}
Alexander Jarman
@HeinousTugboat
Jan 14 2018 01:50 UTC
So Element.addEventListener('someEventType', someCallbackFunction,duringCapturePhaseOrNot)
When the callback function is actually called, the system passes to it a copy of the event it made.
James Moore
@James-N-M
Jan 14 2018 01:51 UTC
.container{
    border: 1px solid black; 
    display: block; 
    margin: 0 auto;
    max-width: 100%; 
}

.header{
    text-align: center; 
}

.cell{
    background-color: black; 
    height: 10px;
    width: 10px; 
    display: inline-block; 
}
theres a little bit of gap between the top border and a cell i create, how do i remove this gap
Alexander Jarman
@HeinousTugboat
Jan 14 2018 01:51 UTC

So with any event, you can do this:

Element.addEventListener('event', (ev) => console.log(ev));

and inspect the actual event from console.

@James-N-M Does the container have any padding?
That's what usually puts distance between a border and its children.
@wheelhot I was just saying that most useful information you're gonna want from an Event will be from that ev object that gets passed to your callback function.
Omar Tan
@wheelhot
Jan 14 2018 01:53 UTC
Aaah, is that why I had to follow put in a parameter (ev) in the function? Or else it wont do anything right?
filterStatus.addEventListener('click', function (ev) {
    console.log(ev.target);
}, false);
Thanks @HeinousTugboat , that made thigs a lot clearer now!
CamperBot
@camperbot
Jan 14 2018 01:53 UTC
wheelhot sends brownie points to @heinoustugboat :sparkles: :thumbsup: :sparkles:
api offline
Alexander Jarman
@HeinousTugboat
Jan 14 2018 01:53 UTC
Right-o! JavaScript is super super heavily callback based, so it's helpful to get real intimate with that kind of pattern.
It'd be embarassing if you could see the sheer number of times I've written a function that was literally just function() { console.log(arguments); } just so I could see WTF I was even getting handed.
James Moore
@James-N-M
Jan 14 2018 01:55 UTC
@HeinousTugboat no there isnt and its weird cause each block is being printed as if it has padding
Alexander Jarman
@HeinousTugboat
Jan 14 2018 01:55 UTC
@James-N-M You've explicitly set padding to 0?
Might be inline-block being silly, too.
If there's a second inline-block that's taller, that might push the others down. I don't remember.
Marc
@MWBauer
Jan 14 2018 02:02 UTC
@GitHub-Henry I don't have much patience, but I know you're right. I inadvertently took time away and that's making it harder on me.
Kent Saeteurn
@sansae
Jan 14 2018 02:19 UTC
@HeinousTugboat yup; if given 'abc', return ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']
Alexander Jarman
@HeinousTugboat
Jan 14 2018 02:23 UTC
So, for every element of the array, cycle through every other element of the array.
Or, rather, every letter in the string, cycle through every other letter in the string.
James Moore
@James-N-M
Jan 14 2018 02:37 UTC
hey guys
if anyone has a second and wants to clone / run this and let me know why theres padding between the cell blocks
let me know
i just want each block to be flush cause the idea is to write a loop that covers the bordered area perfectly
with blocks
Alexander Jarman
@HeinousTugboat
Jan 14 2018 02:39 UTC
Sure, two clicks.
Yeah, it's because they're inline-blocks.
If you change them to display: block, they sit snug in the corner.
So, options are: display: flex, display: grid, line-height: 10px, or float those bad boys.
The gap is specifically because the default line-height is 16px.
The gap between is because of whitespace in the markup between the two elements.
I hate inline-blocks. :laughing:
Alexander Jarman
@HeinousTugboat
Jan 14 2018 02:45 UTC
image.png
Marc
@MWBauer
Jan 14 2018 02:54 UTC
@sjames1958gm you have time to help?
Marc
@MWBauer
Jan 14 2018 02:59 UTC
nvm
James Moore
@James-N-M
Jan 14 2018 03:11 UTC
Hey Thanks @HeinousTugboat !
CamperBot
@camperbot
Jan 14 2018 03:11 UTC
james-n-m sends brownie points to @heinoustugboat :sparkles: :thumbsup: :sparkles:
:cookie: 317 | @heinoustugboat |http://www.freecodecamp.org/heinoustugboat
Alexander Jarman
@HeinousTugboat
Jan 14 2018 03:19 UTC
@James-N-M Welcome! Best of luck!
Marc
@MWBauer
Jan 14 2018 03:33 UTC
could someone explain the console.log for me?
I type in console.log(arr) and get nothing.
Alexander Jarman
@HeinousTugboat
Jan 14 2018 03:33 UTC
Is.. arr a declared variable?
Marc
@MWBauer
Jan 14 2018 03:33 UTC
yes
Alexander Jarman
@HeinousTugboat
Jan 14 2018 03:33 UTC
console.log() literally just prints out whatever you pass to it.
Marc
@MWBauer
Jan 14 2018 03:33 UTC
right
it should display the arr
Alexander Jarman
@HeinousTugboat
Jan 14 2018 03:34 UTC
Are you in the console? What happens if you just type arr and hit enter?
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 03:35 UTC
anyone here having expertise on cross browser compatibility??
Marc
@MWBauer
Jan 14 2018 03:35 UTC
eh>
?
Alexander Jarman
@HeinousTugboat
Jan 14 2018 03:36 UTC
@MWBauer Where are you a.) running console.log() and b.) looking for its output?
Marc
@MWBauer
Jan 14 2018 03:36 UTC
I'm working on FCC doing the difference between array lesson
I'm trying to see my aArr to make sure that I did what I wanted to.
So I put in my function and then on a new line type console.log(aArr);
Alexander Jarman
@HeinousTugboat
Jan 14 2018 03:37 UTC
Marc
@MWBauer
Jan 14 2018 03:38 UTC
Yes. I understand what I' supposed to do, but I just need the console to work
Alexander Jarman
@HeinousTugboat
Jan 14 2018 03:38 UTC
If it's that one, your console output should show up just underneath "ask for help in the forum".
Marc
@MWBauer
Jan 14 2018 03:38 UTC
I check in the window to the left to see what it reports.
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 03:38 UTC
??
anyone here having expertise on cross browser compatibility??
Marc
@MWBauer
Jan 14 2018 03:38 UTC
I press Run and it says testing challenge, then blank.
Alexander Jarman
@HeinousTugboat
Jan 14 2018 03:39 UTC
Huh. Yeah, it isn't showing anything for me there.
You using Chrome or Firefox?
I'll walk you through using the actual console. :-)
Marc
@MWBauer
Jan 14 2018 03:40 UTC
firefox dev
Alexander Jarman
@HeinousTugboat
Jan 14 2018 03:40 UTC
Hit ctrl+shift+K
Should pop open a window with a bunch of lines and a place at the bottom where you can type in.
Marc
@MWBauer
Jan 14 2018 03:41 UTC
No. shortcut list
Alexander Jarman
@HeinousTugboat
Jan 14 2018 03:41 UTC
Shortcut list?
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 03:42 UTC
anyone out there
for help
Ken Haduch
@khaduch
Jan 14 2018 03:42 UTC
@SSheorain - put your question here and people will respond...
Alexander Jarman
@HeinousTugboat
Jan 14 2018 03:42 UTC
@SSheorain I don't know a lot about cross browser compatbility, but I can try and help.
Marc
@MWBauer
Jan 14 2018 03:42 UTC
how about j
just kidding
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 03:43 UTC
@HeinousTugboat and @khaduch thanks
CamperBot
@camperbot
Jan 14 2018 03:43 UTC
ssheorain sends brownie points to @heinoustugboat and @khaduch :sparkles: :thumbsup: :sparkles:
:cookie: 318 | @heinoustugboat |http://www.freecodecamp.org/heinoustugboat
:star2: 3675 | @khaduch |http://www.freecodecamp.org/khaduch
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 03:43 UTC
i am working on a site and it is misbhaving in IE and safari
Alexander Jarman
@HeinousTugboat
Jan 14 2018 03:43 UTC
Oh, good luck!
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 03:44 UTC
also will going to the lower versions of windows the style sheet is useless..
i am not been able to code for specific browser
can u help me up with documentation
Marc
@MWBauer
Jan 14 2018 03:47 UTC
@HeinousTugboat what window is supposed to open?
Alexander Jarman
@HeinousTugboat
Jan 14 2018 03:48 UTC
image.png
That's what that specific Challenge looks like for me in Firefox Dev. :-)
Might be a separate window, might be a sidebar.
Depends.
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 03:49 UTC
@khaduch u there
Alexander Jarman
@HeinousTugboat
Jan 14 2018 03:51 UTC
Log debugging's the golden standard of JavaScript debugging. :-D
...and basically every language I've ever written.
Ken Haduch
@khaduch
Jan 14 2018 03:55 UTC
@SSheorain - what's going wrong? Are you using features that IE doesn't support? Have you checked https://caniuse.com ?
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 03:59 UTC
@khaduch do i have to check each and every element out there
for its compatibility..
Alexander Jarman
@HeinousTugboat
Jan 14 2018 04:01 UTC
For IE? Basically.
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 04:06 UTC
@khaduch ??
Ken Haduch
@khaduch
Jan 14 2018 04:10 UTC
@SSheorain - well, @HeinousTugboat might have a good suggestion, I'm not familiar with that site. But I would start with finding some things that are not behaving as you want them to, and checking those against the caniuse site.
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 04:12 UTC
hmm @khaduch .. and do u have the link to documentation related to code for css for different browsers.
@HeinousTugboat i am using semantic ui for my website.. is there a way to code based on browsers
Sorin Ruse
@sorinr
Jan 14 2018 04:14 UTC
@wheelhot @HeinousTugboat i shared that article on sitepoint because i have encountered a similar issue with an editable table that was changing not only the current td but also all the previous edited td's
Alexander Jarman
@HeinousTugboat
Jan 14 2018 04:15 UTC
@sorinr Huh. That's interesting. Wonder what caused that. I can't think of what would cause that within the event system.
Ken Haduch
@khaduch
Jan 14 2018 04:15 UTC
@SSheorain - https://caniuse.com/ is the one that I know about - it shows browsers vs. features in different formats.
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 04:16 UTC
@khaduch ok i look into it ..thanks for help
CamperBot
@camperbot
Jan 14 2018 04:16 UTC
ssheorain sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
api offline
Alexander Jarman
@HeinousTugboat
Jan 14 2018 04:17 UTC
Browser Support
Last 2 Versions FF, Chrome, Safari Mac
IE 11+
Android 4.4+, Chrome for Android 44+
iOS Safari 7+
Microsoft Edge 12+
Although some components will work in IE9, grids and other flexbox components are not supported by IE9 and may not appear correctly.
What specific versions of IE/Safari are you working with? And what sorts of specific things are you having issues with?
Also looks like they have their own gitter channel. You might have better luck there if you're having difficulty with cross-browser compatibility with it: https://gitter.im/Semantic-Org/Semantic-UI
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 04:18 UTC
no one is active out there
Alexander Jarman
@HeinousTugboat
Jan 14 2018 04:19 UTC
That's fair. So what are your specific troubles?
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 04:20 UTC
image.png
Ken Haduch
@khaduch
Jan 14 2018 04:20 UTC
@SSheorain - I'm also not familiar with "semantic ui", but searching a little I found this: https://github.com/Semantic-Org/Semantic-UI#browser-support - list of browser support (which might be what @HeinousTugboat just quoted above.)
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 04:20 UTC
the nav bar
Sorin Ruse
@sorinr
Jan 14 2018 04:21 UTC
@HeinousTugboat i remember it was a forked pen and the issue there was the event propagation. wanted to share that pen as an example but i think i have deleted it after a while coz i don't have it
Alexander Jarman
@HeinousTugboat
Jan 14 2018 04:21 UTC
@khaduch Yeah, that's exactly it. I've thought about playing with Semantic before. It's gorgeous.
@SSheorain If you're having trouble with Chromium, it very, very likely isn't really a cross-browser issue.
Any cross-browser issues I've run into with Chrome/Chromium/Firefox/Gecko have been very minor and usually just spacing issues. Unless you're using a browser-specific feature which, well, sorry 'bout your luck.
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 04:23 UTC
image.png
Alexander Jarman
@HeinousTugboat
Jan 14 2018 04:23 UTC
@sorinr I might go look around. Was it just a CodePen example for editable tables?
I honestly can't think about why an event from one <tr> would do anything to another one. Events don't propagate to siblings.
SAURABH SHEORAIN
@SSheorain
Jan 14 2018 04:24 UTC
i guess it is because of different grid sizes in older versions.
Sorin Ruse
@sorinr
Jan 14 2018 04:29 UTC
@HeinousTugboat i remembered. it was not on codepen but on heroku or something like this. i have pointed out the guy to this resource: http://jsfiddle.net/fv3gZ/
how do i seperate the two pages?? i cant figure it out
Sorin Ruse
@sorinr
Jan 14 2018 05:39 UTC
@bourget1 here a basic example
bourget1
@bourget1
Jan 14 2018 06:02 UTC
@sorinr awsome thanks, i think i got it figured out now.
CamperBot
@camperbot
Jan 14 2018 06:02 UTC
bourget1 sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
:star2: 1389 | @sorinr |http://www.freecodecamp.org/sorinr
Sorin Ruse
@sorinr
Jan 14 2018 06:03 UTC
@bourget1 :+1:
Norvin Burrus
@ndburrus
Jan 14 2018 07:03 UTC
hi tolu
xiaomingTang
@xiaomingTang
Jan 14 2018 07:15 UTC
who can help me
Why webpack pack whole element-ui when I use
import {
  Carousel,
  CarouselItem,
  Button
} from 'element-ui'
Pranav Bhaskar
@CoderPrans
Jan 14 2018 09:29 UTC
I am doing the advanced algorithm scripting challenge "Exact Change" and I am pretty sure my code works but somehow 96.74 - 60 = 36.739999999999995 and in the end i get 0.039999999999995 instead of 0.04 hence 3 pennies instead of 4. What do i do ?
Aditya
@ezioda004
Jan 14 2018 10:06 UTC
@CoderPrans Try 36.739999999999995.toFixed(2)
Pranav Bhaskar
@CoderPrans
Jan 14 2018 10:07 UTC
no prob, just solved it had to use in multiple of hundereds @ezioda004
@ezioda004 thanks ...
CamperBot
@camperbot
Jan 14 2018 10:07 UTC
coderprans sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 381 | @ezioda004 |http://www.freecodecamp.org/ezioda004
primuscovenant
@primuscovenant
Jan 14 2018 10:41 UTC
@heroiczero thx
CamperBot
@camperbot
Jan 14 2018 10:41 UTC
primuscovenant sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 2136 | @heroiczero |http://www.freecodecamp.org/heroiczero
ahmed-issa-mohd
@ahmed-issa-mohd
Jan 14 2018 13:42 UTC
why the height property set as auto here ? https://www.w3schools.com/css/css_image_gallery.asp
Fabien SHAN
@X140hu4
Jan 14 2018 14:00 UTC
@ahmed-issa-mohd Take the height property out, what happens?
bg-grira53
@bg-grira53
Jan 14 2018 14:34 UTC
hey guys i need some help plz !!
Matej Bošnjak
@mbosnjak01
Jan 14 2018 14:35 UTC
with?
bg-grira53
@bg-grira53
Jan 14 2018 14:36 UTC
i wanna upload some images, texts, etc and with those i wanna create a page
is it possible with js ??
Matej Bošnjak
@mbosnjak01
Jan 14 2018 14:37 UTC
well ... if you're going to make a database in JSON object then yeah
bg-grira53
@bg-grira53
Jan 14 2018 14:37 UTC
@mbosnjak01 can you explain more plz ??
Matej Bošnjak
@mbosnjak01
Jan 14 2018 14:38 UTC
@bg-grira53 did you work witj JS objects before?
with*
bg-grira53
@bg-grira53
Jan 14 2018 14:39 UTC
u mean DOM right ??
Matej Bošnjak
@mbosnjak01
Jan 14 2018 14:39 UTC
but I am not sure if you can upload pictures (or other stuff) to certain folders via JS
no
i mean Javascript Objects
bg-grira53
@bg-grira53
Jan 14 2018 14:39 UTC
then no
Matej Bošnjak
@mbosnjak01
Jan 14 2018 14:40 UTC
I wouldn't recommend using JS if you need to upload files somewhere
I don't think you can do that with JS (although I never searched that)
for that use some backend language
bg-grira53
@bg-grira53
Jan 14 2018 14:41 UTC
for example ??
Matej Bošnjak
@mbosnjak01
Jan 14 2018 14:41 UTC
i don't know many backend langs ... just PHP + SQL
php got file upload/creation/edit stuff
bg-grira53
@bg-grira53
Jan 14 2018 14:42 UTC
thanks for your time , i aprecciate it
Ayush Bahuguna
@relentless-coder
Jan 14 2018 17:04 UTC
Hey, I need some help here. I was browsing the gsap library, and I came across this example, can anyone tell the concept behind this scroll?
how are they able to show different sections as if the page is being scrolled?
Eric Weiss
@eweiss17
Jan 14 2018 17:16 UTC
looks like they used this https://greensock.com/
if you are talking about specifically the scrolling, just some js like this to get that type of effect https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
linkin-park
@linkin-park
Jan 14 2018 17:28 UTC
my code seems to be hanging what is best way to optimize the editor?
Ryan Christopher
@ryan-christopher
Jan 14 2018 19:32 UTC
Anyone notice that the example calculator is dead wrong? The model allows you to input the equation 7+8x2, but says the answer is 30. It isn't. Did anyone correct for this?
Jessica Mattick
@jmatty16
Jan 14 2018 19:40 UTC
Would anyone be willing to help me with the timing of my simon game? It plays the sequence alright but gets weird when there are two of the same colors in a row. It also doesn't wait for the end of the user's last button animation to start playing the next computer generated sequence.
Alexander Jarman
@HeinousTugboat
Jan 14 2018 19:46 UTC
@ryan-christopher It's actually correct, traditional calculators total the operation when you hit the next button. So if you enter those from left to right, it'll perform 7+8, total to 15, then *2 for 30.
@jmatty16 lets see it
Ken Haduch
@khaduch
Jan 14 2018 20:11 UTC
@jmatty16 - yes, if you can post your URL we can try to give some guidance...
Jessica Mattick
@jmatty16
Jan 14 2018 20:11 UTC
well, i see something that might be causing an issue
you have a click listener for each color (#green...) and also for the .container
so those two functions will fire when you click any color
at the same time - not saying its wrong - but probly unnecessary
the comment says
  // checks if user satisfied sequence after each button press
you should maybe separate that into a function - and call the function at the end of each #color.click
that's kind of an initial impression - i havent looked too deep into it
Jessica Mattick
@jmatty16
Jan 14 2018 20:22 UTC
Thanks! @moT01 I'll look into fixing those things. My main issue is that after the user satisfies the sequence, the computer sequence begins playing before the final user button finishes it's animation. Do you think creating the separate function to check would help with this?
CamperBot
@camperbot
Jan 14 2018 20:22 UTC
jmatty16 sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 959 | @mot01 |http://www.freecodecamp.org/mot01
Ryan Christopher
@ryan-christopher
Jan 14 2018 20:25 UTC
@HeinousTugboat Appreciate the input, Alexander. Had an extensive conversation about this one. There's correct with respect to PEMDAS, as observed by the calculator on my Mac, and correct insofar as your calculator offers you a total once the next operator button is pressed in a chain of operations.
@jmatty16 its gotta be those setTimeout's
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:26 UTC
Right. I think it depends on which context you're looking at. If you're expecting it to work one way, the other way's going to look wrong.
the way those work - is they tell the computer or whatever to do something in a certain amount of time (900ms) in your case
Koderkid1936
@Koderkid1936
Jan 14 2018 20:26 UTC

``
for(var i = "#"; i.length < 8; i++){
console.log(i);
i+=i;

}
``

any Idea why this is only printing out '#' to the console?
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:27 UTC
Gotta add one more ` to each of those.
but the rest of the code continues to run for the time that its waiting to run that
Koderkid1936
@Koderkid1936
Jan 14 2018 20:27 UTC
@HeinousTugboat thanks
CamperBot
@camperbot
Jan 14 2018 20:27 UTC
koderkid1936 sends brownie points to @heinoustugboat :sparkles: :thumbsup: :sparkles:
:cookie: 319 | @heinoustugboat |http://www.freecodecamp.org/heinoustugboat
Koderkid1936
@Koderkid1936
Jan 14 2018 20:27 UTC
for(var i = "#"; i.length < 8; i++){
    console.log(i);
    i+=i;

}
any idea why this only printss out '#' to the console?
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:27 UTC
What.. what does "#"++ even do in JavaScript? Is that a legal operation?
Koderkid1936
@Koderkid1936
Jan 14 2018 20:28 UTC
it increments # by one
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:28 UTC
That's a meaningless statement. "#" isn't a number, and can't be incremented.
Koderkid1936
@Koderkid1936
Jan 14 2018 20:28 UTC
:worried:
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:29 UTC
Is it not giving you a ReferenceError when you execute that?
Koderkid1936
@Koderkid1936
Jan 14 2018 20:29 UTC
nope just a #
nop reference error
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:29 UTC
Trying to just type "#"++ in the console gives me Uncaught ReferenceError: Invalid left-hand side expression in postfix operation
Koderkid1936
@Koderkid1936
Jan 14 2018 20:30 UTC
@HeinousTugboat so why does this work here same example but just using a while loop: (bare with me)
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:30 UTC
Huh. Yeah, no joke. It doesn't throw an error when it tries to execute that line.
That's interesting. Didn't realize JS would silently attempt and fail that execution.
Koderkid1936
@Koderkid1936
Jan 14 2018 20:31 UTC
var a = "#"
while(a.length  < 8 ){
console.log(a);
a+=a;
}
why does this work? its the same thing
missed the semi colon
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:31 UTC
Because it isn't trying to increment a string.
So, here's two examples for you.. (one sec)
Koderkid1936
@Koderkid1936
Jan 14 2018 20:31 UTC
I see, it makes sense now
Ken Haduch
@khaduch
Jan 14 2018 20:31 UTC
@Koderkid1936 - I would say that since i is a variable that contains the #, it is printing it as a character, because the initial value of i is used in the loop without any modifications.
Koderkid1936
@Koderkid1936
Jan 14 2018 20:32 UTC
a.length = 1 it refers to the actual number
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:32 UTC
for (var i = 0; i < 10; i++) {
    doSomething();
}
/////////////////////////
var i = 0;
while (i < 10) {
    doSomething();
    i++;
}
Those are essentially identical loops.
All the for loop is doing is shorthanding the 1st, 2nd and 4th line into one line.
Koderkid1936
@Koderkid1936
Jan 14 2018 20:33 UTC
@HeinousTugboat thanks for clarifying that, sometimes my brain seems to not function at all :/
CamperBot
@camperbot
Jan 14 2018 20:33 UTC
koderkid1936 sends brownie points to @heinoustugboat :sparkles: :thumbsup: :sparkles:
api offline
Koderkid1936
@Koderkid1936
Jan 14 2018 20:33 UTC
@khaduch thanks
CamperBot
@camperbot
Jan 14 2018 20:33 UTC
koderkid1936 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3676 | @khaduch |http://www.freecodecamp.org/khaduch
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:33 UTC
So if we rewrite your original loop like that, it looks like this:
var i = "#";
while( i.length < 8){
    console.log(i);
    i+=i;
    i++; // Here you're incrementing a string
}
Ken Haduch
@khaduch
Jan 14 2018 20:34 UTC
and if I try this in a console: var i = "#"; and then i++ it returns NaN... your actual mileage may vary, I supposed, depending on the JS engine that is running?
depending on how NaN is used in various scenarios
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:35 UTC
OOooh, that's the diff. I was incrementing a string directly.
Ok, so i = "#"; i++ sets isNaN(i), and NaN.length is undefined.. and undefined < Number is false, breaking the condition.
That makes perfect sense then.
Ken Haduch
@khaduch
Jan 14 2018 20:44 UTC
@HeinousTugboat - it's interesting to figure those things out (I would be happy if I could remember them better) but there are always reasons why things work the way they do. Well, almost.
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:44 UTC
Oh, there's always reasons. Just not always good or sensical reasons.
I admire the C folks, where they just declare things as "Undefined Behavior" and have at.
Koderkid1936
@Koderkid1936
Jan 14 2018 20:45 UTC
#
##
###
####
#####
######
#######
I've made this pattern using the while loop now they asked me to create this pattern:
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:46 UTC
So much banging.
Wait. Hashing.
Koderkid1936
@Koderkid1936
Jan 14 2018 20:46 UTC
#
##
###
####
#####
######
#######
######
#####
####
###
##
#
My question is, do I have to use 2 loops, like a loop inside a loop, loopception ???
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:46 UTC
:laughing: Hashbang!
I don't think you could do a loop inside a loop easily.
But you could do two sequential loops, or you could do one loop where you reverse the increment halfway through.
Depending if you prefer for or while. You could do it in 1 while or 2 fors.
Koderkid1936
@Koderkid1936
Jan 14 2018 20:47 UTC
you can do it with 1 while loop?
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:47 UTC
Or if you're using, like, that weird visual programming language, you just put a reverser or something.
@Koderkid1936 Yeah, just check each iteration if it's the length you want, and if it is, start taking off instead of adding.
Koderkid1936
@Koderkid1936
Jan 14 2018 20:48 UTC
ok
I'll do it both ways and figure it out on my own
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:49 UTC
Yup yup. If you get stuck let me know and I'll give you a nudge.
Koderkid1936
@Koderkid1936
Jan 14 2018 20:49 UTC
but do you mind pm'ing me how you went about it, so I can look at it after
@HeinousTugboat yeah I'm attempting it now
thanks
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:49 UTC
Uh, what's the name of the challenge?
Koderkid1936
@Koderkid1936
Jan 14 2018 20:49 UTC
brb
it's not a challenge or maybe it is on the internent but I got it from like a js book
Alexander Jarman
@HeinousTugboat
Jan 14 2018 20:50 UTC
Oh. Yeah, I'll write a little snippet.
Koderkid1936
@Koderkid1936
Jan 14 2018 20:50 UTC
cool
Alexander Jarman
@HeinousTugboat
Jan 14 2018 21:15 UTC

@Koderkid1936

let d,g,i=2;while(!g){console.log(Array(i).join('#'));g=i<=1&&!g;d=i==9||d;d?i--:i++}

86 characters. Not sure if I can get it any shorter.

Koderkid1936
@Koderkid1936
Jan 14 2018 21:17 UTC
(I havent started took a short break lol ) I'm just gonna copy and paste it onto a text document without looking at it
Alexander Jarman
@HeinousTugboat
Jan 14 2018 21:17 UTC
Got it down one more to 85. :-D
let d,g,i=2;while(!g){console.log(Array(i).join('#'));g=i<2&&!g;d=i==9||d;d?i--:i++}
Might be able to do like 84..
Nope. The for loop is the same length as the while.
Koderkid1936
@Koderkid1936
Jan 14 2018 21:19 UTC
@HeinousTugboat show of :/
Alexander Jarman
@HeinousTugboat
Jan 14 2018 21:19 UTC
You didn't say you wanted a comprehensible example.
Koderkid1936
@Koderkid1936
Jan 14 2018 21:19 UTC
show the for loop
I'm kidding lol
@HeinousTugboat I actually do
Alexander Jarman
@HeinousTugboat
Jan 14 2018 21:20 UTC
Just got it down to 81 characters.
for(let d,g,i=2;!g;g=i<2&&!g,d=i==9||d,d?i--:i++)console.log(Array(i).join('#'))
..and it's a for loop.
I'll de-golf it for you when you're done. :-)
Koderkid1936
@Koderkid1936
Jan 14 2018 21:20 UTC
thanks
and like I said I havent looked at them
ok
Alexander Jarman
@HeinousTugboat
Jan 14 2018 21:21 UTC
No worries. Once you've figured it out, or if you need help, let me know.
Koderkid1936
@Koderkid1936
Jan 14 2018 21:21 UTC
cool :thumbsup:
Alexander Jarman
@HeinousTugboat
Jan 14 2018 21:22 UTC
70
for(let d,i=2;i>1;d=i==9||d,d?i--:i++)console.log(Array(i).join('#'))
Oddly, now it's actually almost readable.
jjzep
@jjzep
Jan 14 2018 21:29 UTC
I'm having a difficult time getting a click event to work on a page
Alexander Jarman
@HeinousTugboat
Jan 14 2018 21:30 UTC
What's up?
jjzep
@jjzep
Jan 14 2018 21:30 UTC
Here is my code

let attack = document.querySelector('#attack');

attack.addEventListener('click', console.log('test'));

Alexander Jarman
@HeinousTugboat
Jan 14 2018 21:31 UTC
Ok, so your second argument to addEventListener.
Ken Haduch
@khaduch
Jan 14 2018 21:31 UTC
@jjzep - you can edit your post to put the three ticks on separate lines at the start and end.
Alexander Jarman
@HeinousTugboat
Jan 14 2018 21:31 UTC
You're passing it undefined, not a function for it to execute.
console.log('test') resolves to undefined and then you hand it to the event listener. So you want to give it a function to call instead.
jjzep
@jjzep
Jan 14 2018 21:34 UTC
Ahh I see
Alexander Jarman
@HeinousTugboat
Jan 14 2018 21:35 UTC
First-class functions can take awhile to get used to, but they're the heart and soul of JS and crazy useful.
jjzep
@jjzep
Jan 14 2018 21:37 UTC
oh man I'm excited, it works!
thank you
Koderkid1936
@Koderkid1936
Jan 14 2018 22:00 UTC
var a = "#";
while(a.length  < 8){
if(a.length <=8){
console.log(a);
a+=a;
}else{
a-=a;
}
}
@HeinousTugboat problem with this is it will never reach the 'else' block
its the condition in the while statement.. I think I gotta change it what you think?
or should I use 'continue' 'break' keywords?
or maybe I could iterate the whole thing 14 times and on the 7th time start taking away ? so instead I could put while(a.length < 14)
Koderkid1936
@Koderkid1936
Jan 14 2018 22:22 UTC
ok I did it this way but heres the rpoblem, the - (minus sign) doesnt take away or delete a character from a string, its not the exact opposite behaviour of concatenate + (plus sign) so now my problem is find a way to delete a character in the string (I'm sure theres a better way to do it my way but Im a beginner after all :( )
var a = "#";
while(a.length < 14){
    if(a.length <=7){
        console.log(a);
          a+="#";
    }else{
        a-="#";
    }
}
Ken Haduch
@khaduch
Jan 14 2018 22:31 UTC
@Koderkid1936 - look at the String methods like .slice or .substring to get something that will return a portion of the string.
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:32 UTC
Yep, @khaduch has the right of it. In mine I just generate a new string each time.
There's all sorts of ways to do it.
(Sorry for the delay, was prepping dinner.)
Koderkid1936
@Koderkid1936
Jan 14 2018 22:33 UTC
@khaduch yeah I was just researching that,
@HeinousTugboat no worries
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:35 UTC
And for mine, I actually check for as long as the string's length is > 0, then shorten the string on the second half.
The hardest part is definitely how to know when to flip from growing to shrinking, though. Took me a few tries to get that right. A few more tries to get it as short as I did.
Koderkid1936
@Koderkid1936
Jan 14 2018 22:37 UTC
@HeinousTugboat man I literally spent hours on this how have I not figured it out yet?
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:37 UTC
As far as I can tell, you need to have more state than a standard for loop provides.
Koderkid1936
@Koderkid1936
Jan 14 2018 22:37 UTC
maybe programming isnt for me ? lol
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:37 UTC
Sometimes you get stumped. Doesn't mean programming isn't for you.
Trust me. I've been stuck on problems for days where, once I figured it out, I was just like "Am I really this stupid? Wow."
Actually, you might be able to wrap the additional state into the counter by using negatives.
Koderkid1936
@Koderkid1936
Jan 14 2018 22:38 UTC
thanks sounds reassuring sighs
Im confused lol
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:39 UTC
It should be reassuring. You'll get it eventually.
What're you confused about?
Koderkid1936
@Koderkid1936
Jan 14 2018 22:39 UTC
"Actually, you might be able to wrap the additional state into the counter by using negatives."
brain power shutting down
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:40 UTC
:laughing: Okay, ignore that. Sorry.
Koderkid1936
@Koderkid1936
Jan 14 2018 22:40 UTC
motivation level: Critical
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:40 UTC
Break down the problem into its simplest steps.
Koderkid1936
@Koderkid1936
Jan 14 2018 22:40 UTC
ok so do you suggest I start all over again
or continue with what I have?
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:41 UTC
I think you should figure out why what you have won't work.
Koderkid1936
@Koderkid1936
Jan 14 2018 22:45 UTC
ok I will
try
wait
nvm
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:46 UTC
Talk it through with us. :-)
So, here's what you shared:
var a = "#";
while(a.length < 14){
    if(a.length <=7){
        console.log(a);
          a+="#";
    }else{
        a-="#";
    }
}
Koderkid1936
@Koderkid1936
Jan 14 2018 22:48 UTC
I mean I already sort of have figured out why it wont work, I can't use - to delete a character from the string but what if I used the splice/substring methods
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:48 UTC
The first problem here is that a.length will start to shrink when you start removing "#".
And, yeah, that's the second problem.
Koderkid1936
@Koderkid1936
Jan 14 2018 22:48 UTC
but thats the whole point
when it gets to 7 it a.length should shrink
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:49 UTC
Then you shouldn't loop until as long as it's smaller than a size it won't ever get to. ;-)
So, why not use a second variable?
Koderkid1936
@Koderkid1936
Jan 14 2018 22:49 UTC
"Then you shouldn't loop until as long as it's smaller than a size it won't ever get to. ;-)" ok reading this and trying to understand give me a sec
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:50 UTC
Alright.
Koderkid1936
@Koderkid1936
Jan 14 2018 22:50 UTC
so are you saying I should have never looped it 14 times instead 8 or 7 ?
I tried that the first time but once a.length reaches 7 the whole loop ends
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:51 UTC
No, I'm saying that with the logic you gave us, it will loop an Infinite number of times.
There's a piece missing.
Koderkid1936
@Koderkid1936
Jan 14 2018 22:51 UTC
oh
ok I see it I think
its the else statement
but else statements have no conditions by default
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:55 UTC
Right, we're assuming that a-="#" actually works.
Koderkid1936
@Koderkid1936
Jan 14 2018 22:55 UTC
should I have used 2 if statements
lol
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:55 UTC
We can sort out how to actually make it work later.
Koderkid1936
@Koderkid1936
Jan 14 2018 22:55 UTC
yes
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:56 UTC
The problem is if that works, your string's going to start getting shorter, so the length will always be <14.
Actually, it'll always be <=7.
So, you need an extra piece of information here.
There's lots of ways to do that.
But I don't know of any way for you to do what you want to do without another piece of information.
Koderkid1936
@Koderkid1936
Jan 14 2018 22:56 UTC
wait
Kim Duclos
@KimberlyDuclos
Jan 14 2018 22:57 UTC
Can anybody see why my random colors aren't working in this https://codepen.io/KimberlyDuclos/pen/XVVEKQ
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:57 UTC
@KimberlyDuclos Add a "#" before the random?
Koderkid1936
@Koderkid1936
Jan 14 2018 22:58 UTC
should the while condition have another condition
like
while(a.length < 14 && "another condition")
Kim Duclos
@KimberlyDuclos
Jan 14 2018 22:59 UTC
@HeinousTugboat so that it's var randColor = Math.floor(Math.#random() * 0xFFFFFF);
?
Alexander Jarman
@HeinousTugboat
Jan 14 2018 22:59 UTC
Er, no. Sorry.
CSS throws away color codes without the # I think.
So, like, it should be #F823DE.
You're only producing F823DE or whatever.
So randColor = '#' + Math.floor(Math.random() * 0xFFFFFF);
Also because I think it's converting back to Decimal.
Koderkid1936
@Koderkid1936
Jan 14 2018 23:00 UTC
@HeinousTugboat bare with me
Kim Duclos
@KimberlyDuclos
Jan 14 2018 23:01 UTC
@HeinousTugboat Thank you so much. I'm missing so many small things today! It worked!
CamperBot
@camperbot
Jan 14 2018 23:01 UTC
kimberlyduclos sends brownie points to @heinoustugboat :sparkles: :thumbsup: :sparkles:
:cookie: 322 | @heinoustugboat |http://www.freecodecamp.org/heinoustugboat
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:01 UTC
..did it? Huh. I didn't actually think that would. :-|
:laughing:
I was gonna suggest this: randColor = '#' + Math.floor(Math.random() * 0xFFFFFF).toString(16).padStart(6,0);
Koderkid1936
@Koderkid1936
Jan 14 2018 23:02 UTC
if I change the while condition to 7 wouldnt be infitie but my code would stop running once it reaches that point so I wouldnt be able to get to the else statement
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:02 UTC
@Koderkid1936 Take your time! I just wanna help people learn. :-)
Koderkid1936
@Koderkid1936
Jan 14 2018 23:02 UTC
thats annyoing :@
ok
Kim Duclos
@KimberlyDuclos
Jan 14 2018 23:02 UTC
@HeinousTugboat Yeah, worked but a little wonky. I think that second one you posted was what I'm looking for. I had it working well before but was re-doing things and forgot what I did.
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:02 UTC
Right. :-)
Yeah, if you want to stick with just randomizing the whole Hex, that's gonna be your best bet. The Math.floor()returns a decimal, so you need to convert it back to Hex.
Koderkid1936
@Koderkid1936
Jan 14 2018 23:03 UTC
@HeinousTugboat I think I got it...
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:03 UTC
@Koderkid1936 Ooh. Do share!
Koderkid1936
@Koderkid1936
Jan 14 2018 23:04 UTC
var a = "#";
while(a.length <= 7){
    if(a.length < 7){
        console.log(a);
          a+="#";
    }else{

        //assuming this works 
    }
}
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:04 UTC
Still doesn't end, though.
You still need that second piece of information.
Koderkid1936
@Koderkid1936
Jan 14 2018 23:04 UTC
ok
let me think
I can understand and see why it doesnt work
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:07 UTC
Good! Making progress.
Koderkid1936
@Koderkid1936
Jan 14 2018 23:13 UTC
I'm thinking to create a different variable and base the loops increment of that instead of the 'a' variable
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:15 UTC
There you go, yeah.
ehutchllew
@ehutchllew
Jan 14 2018 23:15 UTC
@Koderkid1936 are you trying to do something special with the 'a' variable or just testing to see how this while loop works?
Koderkid1936
@Koderkid1936
Jan 14 2018 23:16 UTC
@HeinousTugboat ok give me a sec to change the code (I feel like my brain is fried :/)
@ehutchllew trying to create a pattern
ehutchllew
@ehutchllew
Jan 14 2018 23:17 UTC
gotcha
G-4-R-Y
@G-4-R-Y
Jan 14 2018 23:18 UTC
Hey guys! I'm stuck on "Wherefore art thou" cuz I can't quite find how to check if an object's property is equivalent to another object's property :c
can anyone help me out with this?
VaseJS
@VaseJS
Jan 14 2018 23:19 UTC
@G-4-R-Y propertyOf method
ehutchllew
@ehutchllew
Jan 14 2018 23:20 UTC
@VaseJS @G-4-R-Y hasOwnProperty?
VaseJS
@VaseJS
Jan 14 2018 23:20 UTC
@ehutchllew i knew i was saying that wrong
G-4-R-Y
@G-4-R-Y
Jan 14 2018 23:20 UTC
@ehutchllew hasOwnProperty doesn't check the value :c
VaseJS
@VaseJS
Jan 14 2018 23:20 UTC
:D
G-4-R-Y
@G-4-R-Y
Jan 14 2018 23:20 UTC
@VaseJS ill try it out!
<3
VaseJS
@VaseJS
Jan 14 2018 23:21 UTC
@ehutchllew still got the message across :shipit:
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:21 UTC
objA.prop === objB.prop?
VaseJS
@VaseJS
Jan 14 2018 23:21 UTC
yea
G-4-R-Y
@G-4-R-Y
Jan 14 2018 23:21 UTC
@VaseJS i guess it doesn't quite exist rofl
@HeinousTugboat i can't specify the property, it has to be "general"
i have to find the property in the given object and check its value based on the second given object
Koderkid1936
@Koderkid1936
Jan 14 2018 23:22 UTC
@HeinousTugboat right....
I think I got it this time ?
var a = "#";
var counter = 0
while(counter < 12){
    if(a.length < 7){
        console.log(a);
          a+="#";
    }else{

        //assuming this works 
    }
  counter++;
}
ehutchllew
@ehutchllew
Jan 14 2018 23:23 UTC
@G-4-R-Y you can check byh using Object.entries
that will populate an array with both key and value pairs
but if you do === i'm pretty sure they will always be false, even if they have the same information.
G-4-R-Y
@G-4-R-Y
Jan 14 2018 23:24 UTC
@ehutchllew ill give it a shot! thanks in advance :D
CamperBot
@camperbot
Jan 14 2018 23:24 UTC
g-4-r-y sends brownie points to @ehutchllew :sparkles: :thumbsup: :sparkles:
:cookie: 364 | @ehutchllew |http://www.freecodecamp.org/ehutchllew
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:24 UTC
@Koderkid1936 Well, now put a console.log('else') in that else block and run it. See what happens. :-D
Koderkid1936
@Koderkid1936
Jan 14 2018 23:25 UTC
#
##
###
####
#####
######
@HeinousTugboat that's the result
so I got rid of the infinite loop
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:25 UTC
Did you put a log in that else part?
Koderkid1936
@Koderkid1936
Jan 14 2018 23:26 UTC
the else part is empty, just like shown above
only a comment
ehutchllew
@ehutchllew
Jan 14 2018 23:27 UTC
@Koderkid1936 are you trying to get 7 hashes? Or a pyramid?
Koderkid1936
@Koderkid1936
Jan 14 2018 23:28 UTC
a pyramid
var a = "#";
var counter = 0
while(counter < 12){
    if(a.length <= 7){
        console.log(a);
          a+="#";
    }else{

        //assuming this works 
    }
  counter++;
}
code so far
ehutchllew
@ehutchllew
Jan 14 2018 23:28 UTC
use a for loop
Koderkid1936
@Koderkid1936
Jan 14 2018 23:28 UTC
I'll do that next
@ehutchllew I 'm trying to do it with a while loop first
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:29 UTC
You can also do it recursively. :thumbsup:
My recursive solution's 73 characters. :-(
For loop's down to 62, though!
Koderkid1936
@Koderkid1936
Jan 14 2018 23:31 UTC
I'm not sure what recursive or recursion is but I'm a chapter away from learning that, my question is how do I go about tackling the else block, like I previously mentioned I'm guessing I have to use javascript methods that are used on strings? Splice? substr ? would that work ?
ehutchllew
@ehutchllew
Jan 14 2018 23:32 UTC
62 lines for a pyramid?
oh nvm, characters
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:33 UTC
60 now. :-D
@Koderkid1936 Yes, those should work.
Koderkid1936
@Koderkid1936
Jan 14 2018 23:35 UTC
@HeinousTugboat thanks I'll give that ago now, but before I do can I ask you 2 qestions (exlcuding this one) ?
CamperBot
@camperbot
Jan 14 2018 23:35 UTC
koderkid1936 sends brownie points to @heinoustugboat :sparkles: :thumbsup: :sparkles:
:cookie: 323 | @heinoustugboat |http://www.freecodecamp.org/heinoustugboat
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:35 UTC
@Koderkid1936 Ask as much as you want!
Koderkid1936
@Koderkid1936
Jan 14 2018 23:36 UTC
@HeinousTugboat 1. Why are you such a show off ¬_¬ 2.Why did it take me literally hours (almost 2) to figure something this simple out? am I retarded?
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:36 UTC
1.) Sorry, not actually trying to show off. Code Golf's just fun for me. :-( Sorry. 2.) You aren't! You just haven't done as much with JavaScript as I have.
Experience says nothing about how smart you are. Just says I know more. :-)

<_< And take this for the road:

for(i=7;i>-8;i--)console.log(Array(9-(i<0?-i:i)).join('#'))

;-)

Koderkid1936
@Koderkid1936
Jan 14 2018 23:37 UTC
@HeinousTugboat :laughing: I was kidding and yeah I guesss so
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:37 UTC
I can explain it later if you want me to.
60 characters. I can't think of any other ways to shorten it.
Koderkid1936
@Koderkid1936
Jan 14 2018 23:37 UTC
It's really killing me inside though, like sometimes I think I'm retared
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:37 UTC
I do daily.
..not you, though, me. I think I'm retarded daily.
Koderkid1936
@Koderkid1936
Jan 14 2018 23:38 UTC
if you think you're retarded.... then I dont think I'm retarded... I may be beyond retarded smh :/
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:39 UTC
:laughing: Spend some years doing things like randomly code golfing and challenging yourself, and you'll get to both feel retarded all the time, and make other people feel that way. ;-)
Also things like codingame, CodeWars, HackerRank.
I just enjoy doing strange challenges.
Koderkid1936
@Koderkid1936
Jan 14 2018 23:42 UTC
@HeinousTugboat note s taken. I will do the same.
@HeinousTugboat are you on here often what time zone do you live in
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:44 UTC
EST. :-) I try to be. If you ping me, I can respond within a day.
Feel free and email me, too. It's on my little hover-card thing. :-D
Koderkid1936
@Koderkid1936
Jan 14 2018 23:54 UTC
@HeinousTugboat yeah I see it, you got your first follower
aslo I'm going to open a chat dw I'll pm you if I need anything or have questions etc
@HeinousTugboat I'll be taking a lot of challenges daily now
Alexander Jarman
@HeinousTugboat
Jan 14 2018 23:59 UTC
@Koderkid1936 Sounds great!