These are chat archives for FreeCodeCamp/HelpJavaScript

5th
Jan 2019
tundeiness
@tundeiness
Jan 05 00:17
@JLuboff this is what I have come up with so far https://codepen.io/highness/pen/ebNYVX?editors=0010 it doing what I want so far but I keep getting either 2 copies of the editor or the previewer depending on which button I clicked. Now the issue is what do I need to get rid of and what line of code do I need to re-factor? Appreciate your help so far.
Kelechi Chinaka
@ke1echi
Jan 05 00:23
anyone mind helping with tweet button, trying to tweet quote..tnx
Wasiu Idowu
@Hoxtygen
Jan 05 00:25
@ke1echi this is what worked and still working for me
$(".share-quote").on("click", function(event){

        event.preventDefault();

    window.open("https://twitter.com/intent/tweet?text=" + encodeURIComponent(quote + "~~ " + author));
                });
Jason Luboff
@JLuboff
Jan 05 00:28
@tundeiness What is the expected (or wanted) behavior?
Kelechi Chinaka
@ke1echi
Jan 05 00:29
ok, thanks @Hoxtygen
Kelechi Chinaka
@ke1echi
Jan 05 00:42
it works but i still dont pass the test case @Hoxtygen
mind taking a look? @JLuboff
Jason Luboff
@JLuboff
Jan 05 00:45
@ke1echi The test tells you why its failing
Kelechi Chinaka
@ke1echi
Jan 05 00:46
i cant make sense of it
i did href="twitter.com/intent/tweet"
Jason Luboff
@JLuboff
Jan 05 00:48
The <a> element should include the "twitter.com/intent/tweet" path in its href attribute
You don't have that
Kelechi Chinaka
@ke1echi
Jan 05 00:52
an example would help @JLuboff
oh makes sense now @JLuboff thanks
Wasiu Idowu
@Hoxtygen
Jan 05 01:37
people sleeping now?
Kelechi Chinaka
@ke1echi
Jan 05 01:38
https://codepen.io/kelechichinaka/full/QdjwEY
I would appreciate your feedback
Wasiu Idowu
@Hoxtygen
Jan 05 01:40
@ke1echi nice work
@ke1echi a bit bland, why not add some colors, maybe background color
@ke1echi tweet button has its text underlined on hover
@ke1echi and you don't want to leave the tweet button like that with a white background, add some color and make the bird stand out
Kelechi Chinaka
@ke1echi
Jan 05 01:44
ok
how do i make the text Tweet become white @Hoxtygen check the pen again
i cant figure why it underlines on hover @Hoxtygen
Wasiu Idowu
@Hoxtygen
Jan 05 01:47
@ke1echi
a :hover    {
text-decoration: none
}
@ke1echi there should not be space betwee "a" and ":hove"
@ke1echi then select the "a" tag within the button and give it a color you want
Kelechi Chinaka
@ke1echi
Jan 05 01:54
thanks @Hoxtygen
mind checking again?
Wasiu Idowu
@Hoxtygen
Jan 05 01:57
@ke1echi
#tweet  a {
  text-decoration: none;
  color: yellow
}
Kelechi Chinaka
@ke1echi
Jan 05 01:59
:thumbsup:
Donnie
@Donnie-D
Jan 05 02:39

if i write

function a() {
var c = 4 +7;
c;  // why doesn't it work here ?
}
a();   // =>undefined......but why does it print undefined here

but in the following case i get an answer

function a() {
var c = 4 +7;
return c;  // why does it work here ?
}
a();   // => 11

But if outside a function

var c = 4 + 7;
c; // =>11   ........why does it work here if it didn't work inside a function?
Wasiu Idowu
@Hoxtygen
Jan 05 02:40
@Donnie-D you get undefined because you're no returning anything
Brad
@bradtaniguchi
Jan 05 02:41
^ :thumbsup:
Wasiu Idowu
@Hoxtygen
Jan 05 02:41
@Donnie-D In the global scope there's an implicit return statement. reason why it worked in the last instance
Donnie
@Donnie-D
Jan 05 02:42
implicit return statement?
Wasiu Idowu
@Hoxtygen
Jan 05 02:42

@Donnie-D In the global scope there's an implicit return statement. reason why it worked in the last instance

I read this somewhere sometimes ago, I might be wrong

@bradtaniguchi over to you brother
Donnie
@Donnie-D
Jan 05 02:44
yes @bradtaniguchi if you could also give your input please
Brad
@bradtaniguchi
Jan 05 02:44
What @Hoxtygen is pretty much it
Donnie
@Donnie-D
Jan 05 02:45
so what did @Hoxtygen mean when he said that In the global scope there's an implicit return statement. reason why it worked in the last instance
@bradtaniguchi
Wasiu Idowu
@Hoxtygen
Jan 05 02:47
@Donnie-D What you said worked worked outside of a function but fail to work within a function is what I mean by the last instance
@Donnie-D when you send a kid to get you a drink , the kid knows he has to come back and give you the drink,, but javascript isn't like that, you have to explicitly tell the jS engine to return the drink back to you
Donnie
@Donnie-D
Jan 05 02:52
@Hoxtygen hmm :thumbsup: what you said makes sense since this is how the code works apparently. I only wanted to understand at this point now that whether you mean that if I for example, call a variable outside the function like a; then it'll run but if I have to do this in a function then I have to write return a; because thats just how it goes in functions
Wasiu Idowu
@Hoxtygen
Jan 05 02:52

@Donnie-D You do know there are two types of scope in Js right?; local scope and global scope
local scope: within a function

global scope; outside a function

while in the local scope you must explicitly write a return statement

in global scope you may not because of an implicit return statement

Donnie
@Donnie-D
Jan 05 02:53
@Hoxtygen sorry i didn't know about the implicit return statement concept before
thanks for sharing. I shall look this up
Wasiu Idowu
@Hoxtygen
Jan 05 02:55
@Donnie-D please do, and let me know if I'm wrong. I'm too lazy to check now because i've got some problems i'm dealing with right now and unwilling to divert
Donnie
@Donnie-D
Jan 05 02:55
lol
:thumbsup:
Wasiu Idowu
@Hoxtygen
Jan 05 02:56
@Donnie-D its 3:55am saturday morning, i've been up since 5:30am friday morning......
Donnie
@Donnie-D
Jan 05 02:57
you should get some rest
Wasiu Idowu
@Hoxtygen
Jan 05 02:57
@Donnie-D i dont like incubating problems, gotta solve them and move on to the next
Donnie
@Donnie-D
Jan 05 02:58
same except for i am slow :laughing:
Wasiu Idowu
@Hoxtygen
Jan 05 02:59
@Donnie-D you think you're slow ? you've not seen me working then
Donnie
@Donnie-D
Jan 05 03:01
:checkered_flag: lol
Brad
@bradtaniguchi
Jan 05 03:08
sleep is pretty important to solving problems. Lots of instances where you go to sleep on a problem and wake up with the solution
Nate Mallison
@NJM8
Jan 05 13:44
I actually only program in my sleep, my boss isn't really a fan of the constant napping at my desk though. Lol
Spyrantis Theodoros
@thodorisanta
Jan 05 16:20
is this let x = function() { ...} the same as this function x() { ....} ? or are there any differences?
Aditya
@ezioda004
Jan 05 16:39
Different, the former one doesnt get hoisted while the latter one does.
Spyrantis Theodoros
@thodorisanta
Jan 05 18:42
if my understanding is correct from what i read. The only use of prototypes is to write the "shared" functions of the object that inherit from them so that the program will run faster. Is that it? xD
Aditya
@ezioda004
Jan 05 19:10
Its an underlying inheritance model of JS. Because of that you're able to use methods like .toUpperCase on strings etc, so saying the only use of prototypes is for "shared" function would be an understatement.
Spyrantis Theodoros
@thodorisanta
Jan 05 19:34
i mean. The way we use the prototype keyword mostly. cause why would i add a function to the prototype instead of just adding it to the constructor function?
Aditya
@ezioda004
Jan 05 20:09
Yes, shared property/method is easier to maintain and reason about. Also saves memory.