These are chat archives for FreeCodeCamp/HelpJavaScript

26th
Jan 2018
jusgoose
@gusd773
Jan 26 2018 02:42 UTC

"caesars-cipher"

not sure why it hates me :(

/*

function rot13(str) { // LBH QVQ VG!
var newStr= "";
for (var i=0; i<str.length+1; i++){

var oriGin = str.charCodeAt(i);
if (65<=oriGin<=90){
 oriGin = oriGin - 13;
 newStr = newStr.concat(String.fromCharCode(oriGin));

}

else {newStr = newStr.concat(String.fromCharCode(oriGin));}

}
return newStr;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

*/

Claudio Restifo
@Marmiz
Jan 26 2018 03:06 UTC

@gusd773 you are not account the cyclical nature of the cypher:

I I want to transform the letter A (65 in ascii), I should "go back" in the alphabets from 13 positions, but since A is the first letter I should start decreasing from Z, Y, X ....resulting in A --> N.

Instead you are simply reducing the ASCII of 13, so A (65 - 13 = 52) that is 4 :)

makes sense?

jusgoose
@gusd773
Jan 26 2018 03:15 UTC
@Marmiz gotcha, so I'm adding another if statement
Claudio Restifo
@Marmiz
Jan 26 2018 03:16 UTC
@gusd773 that's a possible solution :)
jusgoose
@gusd773
Jan 26 2018 03:21 UTC

@Marmiz

'
function rot13(str) { // LBH QVQ VG!
var newStr= "";

for (var i=0; i<str.length+1; i++){

var oriGin = str.charCodeAt(i);
if (78<=oriGin<=90){
 oriGin = oriGin - 13;
 newStr = newStr.concat(String.fromCharCode(oriGin));

}
if (65<=oriGin<=77){
 oriGin = oriGin+13;
 newStr = newStr.concat(String.fromCharCode(oriGin));

}

else {newStr = newStr.concat(String.fromCharCode(oriGin));}

}
return newStr;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
'
I thought this would work but I guess not

Claudio Restifo
@Marmiz
Jan 26 2018 03:22 UTC
jusgoose
@gusd773
Jan 26 2018 03:24 UTC
will do @Marmiz
deaninous
@deaninous
Jan 26 2018 03:26 UTC
Try
jusgoose
@gusd773
Jan 26 2018 03:37 UTC
@deaninous i'm trying
jusgoose
@gusd773
Jan 26 2018 03:54 UTC

I tried returning the middle "if" statement and it returns the right unicode but for some reason does not want to work the way the first if statement is working plz somebody help :(

/*
function rot13(str) { // LBH QVQ VG!
var newStr= "";

for (var i=0; i<str.length+1; i++){

var oriGin = str.charCodeAt(i);
if (78<=oriGin<=90){
 oriGin = oriGin - 13;
 newStr = newStr.concat(String.fromCharCode(oriGin));

}
if (65<=oriGin<=78){
 oriGin = oriGin+13;

 newStr = newStr.concat(String.fromCharCode(oriGin));

}

else {newStr = newStr.concat(String.fromCharCode(oriGin));}

}
return newStr;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
*/

Claudio Restifo
@Marmiz
Jan 26 2018 03:55 UTC
@gusd773 well, it's worth looking into this condition:
(78<=oriGin<=90)
jusgoose
@gusd773
Jan 26 2018 04:00 UTC
@Marmiz that doesn't help i copied n pasted it lol thinking it would do what it did for the latter half of my domain
Claudio Restifo
@Marmiz
Jan 26 2018 04:03 UTC

@gusd773 I just want to guide you in understanding your function... I won't give you any straight up correction :)

My question is: do you think this is correct?
(78<=oriGin<=90)

Have you actually tried it?
like for example, if I write this:

1 <= 5 <= 3

What do you expect? true or false?

jusgoose
@gusd773
Jan 26 2018 04:04 UTC
@Marmiz haha I'm not one for that either thank you
CamperBot
@camperbot
Jan 26 2018 04:04 UTC
gusd773 sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1132 | @marmiz |http://www.freecodecamp.org/marmiz
jusgoose
@gusd773
Jan 26 2018 04:05 UTC
@Marmiz false
Claudio Restifo
@Marmiz
Jan 26 2018 04:06 UTC
@gusd773 and what actually happen if you try it?
Aditya
@ezioda004
Jan 26 2018 04:06 UTC
So you'd expect, but js and math doesnt go together
jusgoose
@gusd773
Jan 26 2018 04:07 UTC
math major here sorry
I love puzzles** so yea here I am
Claudio Restifo
@Marmiz
Jan 26 2018 04:08 UTC
@gusd773 I understand your thought process, but have you actually try it?
The fact that makes sense to you, does not necessarly means make sense for the machine
go into your browser console and type: 1< 5 <3 and see the output the machine give to you
jusgoose
@gusd773
Jan 26 2018 04:09 UTC
true my world is now upside down
@Marmiz has killed my dev innocence
Claudio Restifo
@Marmiz
Jan 26 2018 04:13 UTC
@gusd773 or stimulated you into a more critical thinking... you choose which one you prefer ;)
Claudio Restifo
@Marmiz
Jan 26 2018 05:10 UTC
@gusd773 how's the function coming along?
Fabien SHAN
@X140hu4
Jan 26 2018 06:42 UTC
Hello, I am doing the javascript calculator project atm. I have an handleclick on the buttons of my calculator. It fires a function that has a switch statement to catch what button has been pushed and the related code to run. For 3 operations (-, x, /) I am using an HTML code (&#247; for division) but when checking for the value case val = "&#247;" it does not return true.
Anyone has an idea of how to handle this?
Pieter Stokkink
@forkerino
Jan 26 2018 06:45 UTC
You can console.log the val in the default clause and copy paste it to the case
Maybe that works
Fabien SHAN
@X140hu4
Jan 26 2018 06:46 UTC
Yeah I thought of that and it does but what if I have to use the html code?
Pieter Stokkink
@forkerino
Jan 26 2018 06:46 UTC
Maybe switch on charcode?
Not sure about html codes
Or use id's in your html and use those
Fabien SHAN
@X140hu4
Jan 26 2018 06:48 UTC
Well, going to do the copy paste workaround for the moment
what do you mean?
Pieter Stokkink
@forkerino
Jan 26 2018 06:48 UTC
When you give an id of 'divide' to the button, you can switch on that
On my phone, so not gonna type out an example. ☺
But it should be on the 'event.target' somewhere
Fabien SHAN
@X140hu4
Jan 26 2018 06:54 UTC
thanks
thanks for the input @forkerino
CamperBot
@camperbot
Jan 26 2018 06:54 UTC
x140hu4 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2975 | @forkerino |http://www.freecodecamp.org/forkerino
Pieter Stokkink
@forkerino
Jan 26 2018 06:55 UTC
You're welcome!
sabahatullah
@sabahatullah
Jan 26 2018 09:22 UTC

morning guys, is that a good idea to use "const"?
product_id, product_subcategory are dynamic in the following
const newObject = Object.assign(defaultObj, {
entity: {
id: product_id,
categoryId: product_subcategory
}
});

return newObject;

Markus Kiili
@Masd925
Jan 26 2018 09:37 UTC
@sabahatullah Here it doesn't matter whether you use let (or var) or const. const only protects against re-assignment to the variable. Most people who write ES6, use only const and let, and forget about var.
Maybe you should use const when you are not going to reassign.
sabahatullah
@sabahatullah
Jan 26 2018 10:01 UTC
@Masd925 please correct me. if I put this code on the website and product id is different on on each page it won't give out any error. I am actually confused as I read it is used for constant only. re assigning gives error
and also if they are multiple product ids on the same page then
Markus Kiili
@Masd925
Jan 26 2018 10:02 UTC
@sabahatullah Because there is a return at the end, that code must be within a function. Each time the function is called, a new constant is created and then returned. No problem there.
The function would do the same if it was let or var.
Simon Cordova
@gbsimon87
Jan 26 2018 10:30 UTC
Hey all!
Was wondering if anyone knew how to add a class to all children of an element using vanilla JS?
Marianissimus
@Marianissimus
Jan 26 2018 10:31 UTC
@gbsimon87 could work with a loop and classList.add method?
Simon Cordova
@gbsimon87
Jan 26 2018 10:32 UTC
@Marianissimus I've only got two elements to add the classes to
Marianissimus
@Marianissimus
Jan 26 2018 10:32 UTC
ok, select them and use classList.add("classname");
Blauelf
@Blauelf
Jan 26 2018 10:36 UTC

So something like

for (let child of myNode.children) {
    child.classList.add("myChildClass");
}

or ES5 equivalent

var children = myNode.children;
for (var i = 0; i < children.length; i++) {
    children[i].classList.add("myChildClass");
}

?

Simon Cordova
@gbsimon87
Jan 26 2018 10:37 UTC
@Blauelf thank you
Which of this is more modern?
CamperBot
@camperbot
Jan 26 2018 10:37 UTC
gbsimon87 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4677 | @blauelf |http://www.freecodecamp.org/blauelf
Simon Cordova
@gbsimon87
Jan 26 2018 10:38 UTC
I'd suppose using a for in loop has better readability, I think I will try that
Blauelf
@Blauelf
Jan 26 2018 10:39 UTC
That's for of, not for in. ES6 loop type over values, while for in loops over the keys (which are not of interest here).
Simon Cordova
@gbsimon87
Jan 26 2018 10:39 UTC
Thank you, I was just researching the diff for a for of
Marianissimus
@Marianissimus
Jan 26 2018 10:39 UTC
is children array? I don't think so
Markus Kiili
@Masd925
Jan 26 2018 10:39 UTC
@gbsimon87 classList and appending to className differ on browser compatibility.
Simon Cordova
@gbsimon87
Jan 26 2018 10:40 UTC
I'm only concerned for mobiles atm and it appears classList works well
Marianissimus
@Marianissimus
Jan 26 2018 10:40 UTC
children.constructor === Array //false. so a for loop is needed;
Simon Cordova
@gbsimon87
Jan 26 2018 10:40 UTC
var slideImg = container.querySelectorAll(".upYourCallTop > img");
    var slideBottomChildren = container.querySelectorAll(".upYourCallBottom");

    function showSlide(index) {
      console.log("UNIPRO:showSlide", index)
      slides[currentIndex].classList.remove('upYourCallActive')

      slideImg[index].classList.remove("upYourCallFadeIn")
      // childNodes[index].classList.remove("upYourCallFadeIn");

      currentIndex = index
      slides[currentIndex].classList.add('upYourCallActive')

      slideImg[index].classList.add("upYourCallFadeIn")

      // for (var i = 0; i < childNodes.length; i++) {
        // childNodes[index].classList.add("upYourCallFadeIn");
      // }

      for (let child of slideBottomChildren.children) {
        child.classList.add("upYourCallFadeIn");
        console.log(child);
      }
    }
That's what I've got so far
Blauelf
@Blauelf
Jan 26 2018 10:41 UTC
@Marianissimus It's an array-like, not an array, as far as I know, so you cannot just write myNode.children.forEach(...). You could however use Array.prototype.forEach.call(myNode.children, ...)
Marianissimus
@Marianissimus
Jan 26 2018 10:41 UTC
ok, thanks
Markus Kiili
@Masd925
Jan 26 2018 10:42 UTC
Yes, NodeList has forEach, but HTMLCollection doesn't.
Blauelf
@Blauelf
Jan 26 2018 10:42 UTC
NodeList? What's that?
Oh, looked it up. Nice.
Not an array but can iterate through it
Weird?!?
Markus Kiili
@Masd925
Jan 26 2018 10:43 UTC
@Blauelf For example querySelectorAll returns a NodeList.
@gbsimon87 It is easy to use any array methods on array-like object the way @Blauelf showed.
Simon Cordova
@gbsimon87
Jan 26 2018 10:44 UTC
This is honestly one of those times where jQuery does makes things easier, I'm just really trying to go the vanilla route
Thanks everybody for the help I do appreciate it
Blauelf
@Blauelf
Jan 26 2018 10:48 UTC
@Masd925 Again, I feel like browser APIs have changed with the addition of CSS. Having learnt HTML and JavaScript for the first time over 20 years ago. Before CSS was even a thing. Tables and frames for layout (and people with text browsers complaining about tables and frames being used for layout).
And me writing server-side code in ColdFusion, with all those SQL injections possible because I just concatenated strings for the SQL query...
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 10:54 UTC
hello everyone
im a bit confused
ele.cover ? ele.cover.url : ele.screenshots ? ele.screenshots[0].url : ""
we can do this right?
Markus Kiili
@Masd925
Jan 26 2018 10:56 UTC
@tiagocorreiaalmeida You can but you should not.
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 10:56 UTC
what problems does it creates?
Markus Kiili
@Masd925
Jan 26 2018 10:56 UTC
@tiagocorreiaalmeida Hard to read and understand.
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 10:56 UTC
uh ok but I think in my case makes sense
let me show
).then((response) => {
        if (!response.data && offset > 0) return res.error(409, "all-games-listed");
        if (!response.data) return res.error(409, "not-found");
        let data = response.data.map((ele) => ({
            id: ele.id,
            name: ele.name,
            url: ele.url,
            summary: ele.summary,
            cover: ele.cover ? ele.cover.url : ele.screenshots ? ele.screenshots[0].url : "",
            rating: ele.total_rating ? ele.total_rating : "Not defined"
        }));
        //filter the user wishlist missing
        res.send(data);
    })
Blauelf
@Blauelf
Jan 26 2018 10:57 UTC

@tiagocorreiaalmeida Sure one can. It's not exactly readable.

Also, in your case, does a truthy ele.screenshots imply there exists an ele.screenshots[0]?

Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 10:57 UTC
yeah it does cause the object doesnt contains the proprety if there's no values at all
Markus Kiili
@Masd925
Jan 26 2018 10:58 UTC
@tiagocorreiaalmeida You should at least put parens around the third ternary operand.
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 10:59 UTC
ok thanks @Masd925 how would you do it tough?
CamperBot
@camperbot
Jan 26 2018 10:59 UTC
tiagocorreiaalmeida sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4671 | @masd925 |http://www.freecodecamp.org/masd925
Blauelf
@Blauelf
Jan 26 2018 11:04 UTC

I would probably just change the indentation, like

            summary: ele.summary,
            cover: (
                  ele.cover ? ele.cover.url
                : ele.screenshots ? ele.screenshots[0].url
                : ""
            ),
            rating: ele.total_rating ? ele.total_rating : "Not defined"

(parentheses because I might confuse it with the colons of the object literal)

Markus Kiili
@Masd925
Jan 26 2018 11:07 UTC
@tiagocorreiaalmeida I generally like tests to be explicit, so I don't have to go looking all around the code for explanation about what the test is doing. So if(str!=="") instead of if(str) and if(obj!==null) or if(obj!==undefined) instead of if(obj).
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 11:08 UTC
ok thanks both for pointing better ways of doing it
Blauelf
@Blauelf
Jan 26 2018 11:13 UTC
@Masd925 Good idea. The comparison makes clear this thing is a boolean. What about ill-named functions returning booleans (not prepended by some "is"), would you add === true?
Markus Kiili
@Masd925
Jan 26 2018 11:19 UTC
@Blauelf Don't know. But proper naming would be the best way.
shigaoping
@shigaoping
Jan 26 2018 11:20 UTC

// 请把你的代码写在这条注释以下
for(var i=0;i<contacts.length;i++){
if(firstName==contacts[i].firstName){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}
else return "No such property" ;
}
else return "No such contact";
}

// 请把你的代码写在这条注释以上
}where is the priblem?

Blauelf
@Blauelf
Jan 26 2018 11:21 UTC
@shigaoping What if the first person isn't the one you search for? You instantly return "No such contact", without even looking at the second contact. On a name mismatch, keep iterating, and return "No such contact" only after the loop.
shigaoping
@shigaoping
Jan 26 2018 11:31 UTC
The loop has a mistake.
@Blauelf thanks
CamperBot
@camperbot
Jan 26 2018 11:34 UTC
shigaoping sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4678 | @blauelf |http://www.freecodecamp.org/blauelf
ESLMiguel
@ESLMiguel
Jan 26 2018 13:44 UTC

Looking at this code:

var a = 1;
var b = 2;
(function(){
   var b = 3;
   a += b;
})();
alert(a+b);

1) Why does var a evaluate as 3 when alert is called?
2) What function or syntactical reason is the () in line 6?

Markus Kiili
@Masd925
Jan 26 2018 13:50 UTC
@ESLMiguel When alert is called, a is 4 and b is 2.
() executes the function created by the expression immediately.
ESLMiguel
@ESLMiguel
Jan 26 2018 14:07 UTC
I didnt not know that () did that. interesting. why is b = 2 at the time alert is called and not = 3?
is it because the code is var b = 3 and not b = 3?
Markus Kiili
@Masd925
Jan 26 2018 14:13 UTC
@ESLMiguel JS has function scope so:
var a = 1;     // Makes a global variable a
var b = 2;     // Makes a global variable b 
(function(){   // Makes a function that is executed immediately by the () below
   var b = 3;  // Makes a function scope (local) variable b
   a += b;     // Uses the global variable a and local variable b
})();
alert(a+b);    // Uses global variables a and b
ESLMiguel
@ESLMiguel
Jan 26 2018 14:41 UTC
@Masd925 Thanks for the clear explanation!
CamperBot
@camperbot
Jan 26 2018 14:41 UTC
eslmiguel sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4673 | @masd925 |http://www.freecodecamp.org/masd925
is there a difference in these in performance?
document.getElementById('slideshow').addEventListener('click', function() {
  document.getElementById('slide').setAttribute('src', '../public/img/slide2.jpg');
});


var slide = document.getElementById('slide');
document.getElementById('slideshow').addEventListener('click', function() {
  slide.setAttribute('src', '../public/img/slide2.jpg');
});
Sweet Coding :)
@SweetCodingInc
Jan 26 2018 14:56 UTC
@moT01 Yes.. 2nd one is more performant
dom operations are expensive and with first approach you access the dom every time you click the said element
in 2nd, you cache the reference to #slide once and then use the reference upon each click
@SweetCodingInc thanks, i kinda assumed something like that - just wanted a second opinion
CamperBot
@camperbot
Jan 26 2018 15:00 UTC
mot01 sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 211 | @sweetcodinginc |http://www.freecodecamp.org/sweetcodinginc
Sweet Coding :)
@SweetCodingInc
Jan 26 2018 15:17 UTC
@moT01 :+1:
Jason Luboff
@JLuboff
Jan 26 2018 16:11 UTC
:wave:
Kaz Baig
@kbaig
Jan 26 2018 16:14 UTC
@JLuboff :wave: :clap:
Jason Luboff
@JLuboff
Jan 26 2018 16:14 UTC
What up
Kaz Baig
@kbaig
Jan 26 2018 16:14 UTC
@JLuboff I'm done with that project! (almost, just need to deploy it after it gets approved)
Jason Luboff
@JLuboff
Jan 26 2018 16:15 UTC
@kbaig Awesome, good job! I mean..you are a week late..but.. :P
Kaz Baig
@kbaig
Jan 26 2018 16:20 UTC
...
Still working a little but not much on the front end
Jason Luboff
@JLuboff
Jan 26 2018 16:37 UTC
@kbaig Looks good. What framework did you use for the frontend?
Or is that normal Wolfram frontend look?
Kaz Baig
@kbaig
Jan 26 2018 16:38 UTC
@JLuboff I don't really control the look, just the layout. You can pick from like three different themes
Jason Luboff
@JLuboff
Jan 26 2018 16:39 UTC
Ah. It's very bootstrap'ish but not default bootstrap...more like a bootstrap theme
Kaz Baig
@kbaig
Jan 26 2018 16:40 UTC
Sounds about right from our devs lol
Jason Luboff
@JLuboff
Jan 26 2018 16:40 UTC
:joy:
Kaz Baig
@kbaig
Jan 26 2018 16:42 UTC
Ay who submitted something with 51 as entries
Jason Luboff
@JLuboff
Jan 26 2018 16:42 UTC
Not me.. I didn't submit anything, just looked at it. Wasn't sure if it was live and didn't want to get you in trouble haha
Kaz Baig
@kbaig
Jan 26 2018 16:42 UTC
LOL no it's on my account
not on the production one
Jason Luboff
@JLuboff
Jan 26 2018 16:44 UTC
:+1:
Ugh...I think I might spring for the monthly github charge so I can have private repos..
Nazar
@IsaakNazar
Jan 26 2018 16:52 UTC
hi guys, I'm learning a tutorial and there is a code
document.querySelector('audio[data-key="${e.keyCode}"]')
what that dollar sign means? I have no idea
jusgoose
@gusd773
Jan 26 2018 16:52 UTC
@Marmiz i fell asleep I seriously have never felt more lost in any challenge, usually after a hint or two I can figure it out as I am a man of fundamentals but if you could maybe link me to something I could read that would help
Kaz Baig
@kbaig
Jan 26 2018 16:53 UTC
@IsaakNazar Are you sure they using quotation marks " and not backticks `
Nazar
@IsaakNazar
Jan 26 2018 16:53 UTC
@kbaig yes, I am
@kbaig yes its actually backticks :)
Jason Luboff
@JLuboff
Jan 26 2018 16:53 UTC
Then its a template string
Kaz Baig
@kbaig
Jan 26 2018 16:53 UTC
It's a template string
Jason Luboff
@JLuboff
Jan 26 2018 16:53 UTC
Boom!
Nazar
@IsaakNazar
Jan 26 2018 16:54 UTC
ok @kbaig @JLuboff BOOM Thx :)
CamperBot
@camperbot
Jan 26 2018 16:54 UTC
isaaknazar sends brownie points to @kbaig and @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2308 | @jluboff |http://www.freecodecamp.org/jluboff
:cookie: 558 | @kbaig |http://www.freecodecamp.org/kbaig
Jason Luboff
@JLuboff
Jan 26 2018 16:56 UTC
@kbaig One time someone was working with vanilla JS... but they had $ throughout the code..and I was confused.. since it looked like they were using it like you would in jQuery but the rest of the code wasn't jQuery.. eventually I think someone pointed out that they had $as a variable for document.getElementByID or whatever it was. Interesting use I thought
Blauelf
@Blauelf
Jan 26 2018 16:57 UTC
Could be combined with variable _ :D
Kaz Baig
@kbaig
Jan 26 2018 16:57 UTC
Yeah some people like to set $ as document.querySelector
Blauelf
@Blauelf
Jan 26 2018 16:58 UTC
(_ is used by libraries underscore and lodash)
Jason Luboff
@JLuboff
Jan 26 2018 16:58 UTC
True
Blauelf
@Blauelf
Jan 26 2018 17:03 UTC
WTF? is a valid identifier? I thought $ and _ were the worst.
Jason Luboff
@JLuboff
Jan 26 2018 17:04 UTC
...How do you even create that character? lol
Blauelf
@Blauelf
Jan 26 2018 17:04 UTC
BTW, that's Japanese/Chinese for "ten".
let ε = -1; (mathematicians might get the joke)
Jason Luboff
@JLuboff
Jan 26 2018 17:07 UTC
Calling @Masd925
Blauelf
@Blauelf
Jan 26 2018 17:08 UTC
Or use the totally different character 𝟄 (also an epsilon)?
@JLuboff In maths, things often start with "let epsilon be greater than zero, then there exists a delta so that ...". In that sense, negative epsilon is creating a whole new kind of maths.
Jason Luboff
@JLuboff
Jan 26 2018 17:11 UTC
@Blauelf You know...I used to think I was good at math...then I got to Calculus and I was in for a rude awakening :D
Jason Luboff
@JLuboff
Jan 26 2018 17:14 UTC
@Blauelf Is that you in the orange shirt? ;)
Blauelf
@Blauelf
Jan 26 2018 17:17 UTC
There are more nerds out there.
Blauelf
@Blauelf
Jan 26 2018 17:24 UTC
ಠ_ಠ is a valid identifier. https://mothereff.in/js-variables
Jason Luboff
@JLuboff
Jan 26 2018 17:25 UTC
I would hate to have to type that everytime lol
Blauelf
@Blauelf
Jan 26 2018 17:29 UTC
When I started with Java, around 1998, I used special characters all the time. Then I realized that my code broke whenever I changed from Windows to Linux or the other way around, due to different encoding. Replacing all the special characters with their unicode sequence to fix that made it unreadable.
aRtoo
@artoodeeto
Jan 26 2018 17:41 UTC
hey fam is there a site the i could get a link for a mp3
Blauelf
@Blauelf
Jan 26 2018 17:51 UTC
?
Markus Kiili
@Masd925
Jan 26 2018 17:59 UTC
@JLuboff You called :imp:
Jason Luboff
@JLuboff
Jan 26 2018 17:59 UTC
@Masd925 Ya... @Blauelf was making a math joke..figured you'd get it
Markus Kiili
@Masd925
Jan 26 2018 18:00 UTC
I have done math, but seemingly not enough...
Jason Luboff
@JLuboff
Jan 26 2018 18:02 UTC
hmmm
Blauelf
@Blauelf
Jan 26 2018 18:03 UTC
I mean something like ϵ>0,δ>0\forall \epsilon > 0, \exists \delta > 0 \ldots, as used for example in Wikipedia: (ε, δ)-definition of limit
aRtoo
@artoodeeto
Jan 26 2018 18:10 UTC
@DanLaff thanks bro!
CamperBot
@camperbot
Jan 26 2018 18:10 UTC
artoodeeto sends brownie points to @danlaff :sparkles: :thumbsup: :sparkles:
api offline
Dan Lafferty
@DanLaff
Jan 26 2018 18:10 UTC
You're welcome
Blauelf
@Blauelf
Jan 26 2018 18:12 UTC
@DanLaff I'm impressed that you were able to interpret that request in any way. Are you trained in telepathy? :D
Kelechi Chinaka
@ke1echi
Jan 26 2018 18:12 UTC
@Blauelf i spent a lot of time tryin to get cs50 offline ide, had lots of error and the files are too big, i think i wud stick to the online version..what do u think?
Blauelf
@Blauelf
Jan 26 2018 18:14 UTC
Online IDE is an option for me, and offline IDE is some work, so I go with the online one.
Dan Lafferty
@DanLaff
Jan 26 2018 18:15 UTC
@Blauelf I work with ESL students, but I'm guessing in a webdev forum when someone wants a link to a mp3, they want a sound or some music on their site
Kelechi Chinaka
@ke1echi
Jan 26 2018 18:15 UTC
:+1: thanks @Blauelf
CamperBot
@camperbot
Jan 26 2018 18:15 UTC
kelechy sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4679 | @blauelf |http://www.freecodecamp.org/blauelf
aRtoo
@artoodeeto
Jan 26 2018 18:25 UTC
hey fam how to toggle button without toggle class?
Jason Luboff
@JLuboff
Jan 26 2018 18:26 UTC
@artoodeeto add/remove the associated toggle class?
aRtoo
@artoodeeto
Jan 26 2018 18:26 UTC
@JLuboff i have this btn bro
strict.addEventListener('click', function(){
        stricto = true;
        strict.style.background = '#57ED78';
        if(stricto){
            stricto = false;
            console.log(stricto);
            strict.style.background = 'red';
        }
    });
@JLuboff i dont want to make a class that will change a background green.
i just want to add a BG color if it has been clicked
Jason Luboff
@JLuboff
Jan 26 2018 18:28 UTC
does strict allow for backgorund color?
Kelechi Chinaka
@ke1echi
Jan 26 2018 18:29 UTC
i just needed somebody to tell am still sane if i used the online version..i have spent days meant for coding trying to understand docker errors while trying to install the offline tool @Blauelf
aRtoo
@artoodeeto
Jan 26 2018 18:29 UTC
@artoodeeto if you mean it will change if i click it yea it will
Jason Luboff
@JLuboff
Jan 26 2018 18:31 UTC
Ok..maybe I don't understand the issue then
Blauelf
@Blauelf
Jan 26 2018 18:31 UTC

@artoodeeto Wouldn't this be more like

    strict.addEventListener('click', function(){
        var stricto = true;
        return function() {
            stricto = !stricto;
            if(stricto) {
                strict.style.background = '#57ED78';
            } else {
                strict.style.background = 'red';
            }
        };
    }());

? (assuming you want a variable stricto that's unique to the button)

aRtoo
@artoodeeto
Jan 26 2018 18:33 UTC
@Blauelf let me try bor
@Blauelf not working bro. yea stricto is only for strict btn
Dan Lafferty
@DanLaff
Jan 26 2018 18:36 UTC
strict.addEventListener("click", function() {
  if(strict.style.background == "red") {
    strict.style.background = "#57ED78"
  } else {
    strict.style.background = "red"
  }
});
Maybe that's simpler?
Blauelf
@Blauelf
Jan 26 2018 18:37 UTC
I tried my code, and it does what I think it should do (toggle background colour).
Ronique Ricketts
@RoniqueRicketts
Jan 26 2018 20:17 UTC
Hi guys I haven't been here much this year.
Jason Luboff
@JLuboff
Jan 26 2018 20:21 UTC
:wave:
Ronique Ricketts
@RoniqueRicketts
Jan 26 2018 20:23 UTC
So i am still stuck with setting up passoprt and session for my application.
Jason Luboff
@JLuboff
Jan 26 2018 20:24 UTC
Whats not working
Ronique Ricketts
@RoniqueRicketts
Jan 26 2018 20:25 UTC
@JLuboff still lost on session and passport. Do I set session in my mysql database connection file or on the actual route?
Jason Luboff
@JLuboff
Jan 26 2018 20:31 UTC
@RoniqueRicketts Passport sets it..
Thats the purpose of the serialize and deserialize functions
@RoniqueRicketts Are you trying to use local strategy or one of the oauth strategies?
Ronique Ricketts
@RoniqueRicketts
Jan 26 2018 20:35 UTC
local strategy I want to use
Jason Luboff
@JLuboff
Jan 26 2018 20:37 UTC
@RoniqueRicketts Take a look at my game trading app https://github.com/JLuboff/GameTrader specifically in the app.js file and the routes->routes.js file to get an idea (in the routes file I think all my routes having to do with passport are /login/*
Ronique Ricketts
@RoniqueRicketts
Jan 26 2018 20:41 UTC
@JLuboff ok will check it
@JLubof does it work the same if I am using mysql db?
Jason Luboff
@JLuboff
Jan 26 2018 20:47 UTC
@RoniqueRicketts I don't see why it wouldn't besides your queries being different
Ronique Ricketts
@RoniqueRicketts
Jan 26 2018 20:47 UTC
I've never configured it before so I have a lot of questions man :)
Jason Luboff
@JLuboff
Jan 26 2018 20:48 UTC
No worries
Ronique Ricketts
@RoniqueRicketts
Jan 26 2018 20:51 UTC
gonna try it and see if I can config mine
@JLuboff look at my folder structure https://github.com/RoniqueRicketts/my-school-app/tree/master/school-app will I add the passport to the app.js file or on routes
Jason Luboff
@JLuboff
Jan 26 2018 21:10 UTC
@RoniqueRicketts Assuming your app.js is your entry point, then in there
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 21:59 UTC
hey!
Jason Luboff
@JLuboff
Jan 26 2018 21:59 UTC
Yo
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 22:00 UTC
all good?
Jason Luboff
@JLuboff
Jan 26 2018 22:00 UTC
Ya I'd say so..you
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 22:01 UTC
all ok :D , need your help if you dont mind, getting a bit crazy with this api ended up looking on your old fcc project the gmae trader, im getting poor quality images for the games not sure if doing something worng
Jason Luboff
@JLuboff
Jan 26 2018 22:02 UTC
If I remember right...I had to pull images from a different endpoint? Let me check my code
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 22:03 UTC
ok would be great if you could, thanks :D
image.png
next lvl quality :D this are like 50px thumbnails I guess
Jason Luboff
@JLuboff
Jan 26 2018 22:03 UTC
Ahhhhh now I remember what I had to do
"https://images.igdb.com/igdb/image/upload/t_cover_big/${el .cover .cloudinary_id}.jpg"
So i didn't need a different endpoint for the request
but in displaying the image, I had to use that url above and stick my variable in there
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 22:05 UTC
so you pick the images from a different place ok, what are the "cloudinary_id" variable?
Jason Luboff
@JLuboff
Jan 26 2018 22:06 UTC
Are you getting all fields from your request or just specific ones? I got specific ones
/games/?search=${game.replace( /\s/g, '%20' )}&fields=id,name,summary,total_rating,developers.name,publishers.name,game_modes.name,cover,release_dates.platform,release_dates.human&expand=developers,publishers,game_modes&filter[release_dates.platform][eq]=48&filter[release_dates.platform][eq]=49&limit=5
`
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 22:06 UTC
for now getting all since it runs quite faster and im using offset and limit not much to worry at the point
Jason Luboff
@JLuboff
Jan 26 2018 22:06 UTC
So I specified the cover field. which then has cloudinary_id as a property in it
what endpoint are you using for the request as well?
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 22:06 UTC
image.png
makes sense :D
yeah tested out one looks alot better than what I had before
Jason Luboff
@JLuboff
Jan 26 2018 22:07 UTC
Yup, there you go. So just use that url I posted above
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 22:07 UTC
im working with node/axios for the backend just the usual :D
how's c#? have you left the js life?
and thanks @JLuboff
CamperBot
@camperbot
Jan 26 2018 22:07 UTC
tiagocorreiaalmeida sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2310 | @jluboff |http://www.freecodecamp.org/jluboff
Jason Luboff
@JLuboff
Jan 26 2018 22:08 UTC
The problem I had with the images after that is that they aren't all the same size but oh well I made it work lol
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 22:08 UTC
im gonna use a defiend size and object-fit I guess this is just for pratice propuse :D
Jason Luboff
@JLuboff
Jan 26 2018 22:08 UTC
C# is good, passed my certification test a few weeks back and finished my first application today. Going to be building a web based application for work that will use node so haven't left js ;)
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 22:10 UTC
nice :D another thing I found strange with this api 90% of the games lack cover image?
Jason Luboff
@JLuboff
Jan 26 2018 22:11 UTC
Mmmm...I stuck with PS4/XB1 games so I don't think I ran into that issue
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 22:11 UTC
maybe im just searching really random names and that's the problem :D
Jason Luboff
@JLuboff
Jan 26 2018 22:13 UTC
Possibily. It is an odd API. Like why the hell do I need so many damn endpoints which then some can convert the returned numbers (i.e publishers is a number instead of a name) to an actual name and others cant.
Tiago Correia
@tiagocorreiaalmeida
Jan 26 2018 22:15 UTC
yeah noticed taht seems you are forced to expand the sections or something similiar I dont know tbh Didnt wasted alot of time in the documentation
Jason Luboff
@JLuboff
Jan 26 2018 22:15 UTC
Ah, ya expand thats the word
but you can't expand the same properties from one endpoint to another. Fucking stupid lol
aRtoo
@artoodeeto
Jan 26 2018 22:17 UTC
hey fam can you help me find bugs? i need to add one more animation if the user doesnt turn on strict if he gets wrong theres should be effect but i couldnt get a mp3 error to embed. but heres my pen. https://codepen.io/artoo/pen/opQZWy?editors=0010
CamperBot
@camperbot
Jan 26 2018 23:42 UTC
gusd773 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4674 | @masd925 |http://www.freecodecamp.org/masd925
jusgoose
@gusd773
Jan 26 2018 23:43 UTC
@Marmiz thank you I def learned about the && operator 4 years ago along with else if statements I really needed this to humble me lol
CamperBot
@camperbot
Jan 26 2018 23:43 UTC
gusd773 sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1134 | @marmiz |http://www.freecodecamp.org/marmiz