These are chat archives for FreeCodeCamp/Help

12th
Nov 2018
troncarter
@troncarter
Nov 12 2018 00:39
how come i dont see the backend part of the curriculum?
Christopher McCormack
@cmccormack
Nov 12 2018 00:57
@troncarter api and microservices, information security and quality assurance, the interview prep
kinopotato
@kinopotato
Nov 12 2018 03:53
Hi, can someone please explain Get and Set in JS as if you are explaining to a complete idiot?
is this like
let a = [1, 2, 3, 4];
a[0] = 4;
a; // 4, 2, 3, 4
but for functions?
Aditya
@ezioda004
Nov 12 2018 03:56
@kinopotato Which get and set? Object/Classes one?
kinopotato
@kinopotato
Nov 12 2018 03:56
there's TWO?! O.O
this I guess? from MDM "The get syntax binds an object property to a function that will be called when that property is looked up."
Aditya
@ezioda004
Nov 12 2018 03:58
Its the same thing, you can use that on classes as well.
kinopotato
@kinopotato
Nov 12 2018 03:59
so it's basically a way to input a parameter inside a function?


var person = {
    firstName: 'Jimmy',
    lastName: 'Smith',
  get  fullName() {
        return this.firstName + ' ' + this.lastName;
    },
  set  fullName (name) {
        var words = name.toString().split(' ');
        this.firstName = words[0] || '';
        this.lastName = words[1] || '';
    }
}

person.fullName = 'Jack Franklin';
console.log(person.firstName); // Jack
console.log(person.lastName) // Franklin
because when I remove get and set, console.log returns jimmy smith instead
what I really don't understand is that I seem to remember just using functions from objects without the need to use get and set.
Aditya
@ezioda004
Nov 12 2018 04:01
@kinopotato get and set are keywords
Its a bit more complicated than that - there are two types of properties in objects:
  1. Data property
  2. Accessor property
So using get and set uses [[Get]] and [[Set]] methods internally
kinopotato
@kinopotato
Nov 12 2018 04:03
accessor property is the same with property accessors?
Aditya
@ezioda004
Nov 12 2018 04:03

So:

 set  fullName (name) {
        var words = name.toString().split(' ');
        this.firstName = words[0] || '';
        this.lastName = words[1] || '';
    }

fullName is a property and you're providing an internal method for the engine to use

kinopotato
@kinopotato
Nov 12 2018 04:04
so it's a property AND a function
Aditya
@ezioda004
Nov 12 2018 04:05
Accessor property is the one which doesnt have value.
All properties have few "configs" like enumerable, configurable
Data properties have: value and writeable
Accessor properties have get and set
You can think of it as a property which executes a function when called
But its semantics look like "property"
kinopotato
@kinopotato
Nov 12 2018 04:06
so get and set are for accessor properties, and accessor properties are for properties whose value is derived from other things, in this case it is from the firstname and lastname
Aditya
@ezioda004
Nov 12 2018 04:07
They dont store a value of their own - they are basically functions. They set and get other data properties
kinopotato
@kinopotato
Nov 12 2018 04:08
hmm this is actually convenient, hmmm
Aditya
@ezioda004
Nov 12 2018 04:08
I believe this is still new, introduced in ES6
kinopotato
@kinopotato
Nov 12 2018 04:09
I'm trying to do the es6 before moving to the projects, haha. so I encountered get and set in youtube. it really does seem useful somehow but I'm still too inexperienced to fully get how it can be used
or even how to use it
Aditya
@ezioda004
Nov 12 2018 04:09
I've used get and set 0 times practically :D
Its more useful for people who work on libraries/framework to create API
kinopotato
@kinopotato
Nov 12 2018 04:10
I'm trying to see how it can be better than just writing a function that doesn't use it :|
Aditya
@ezioda004
Nov 12 2018 04:13
@kinopotato Like use cases?
kinopotato
@kinopotato
Nov 12 2018 04:15

I tried rewriting it without using get/set,

var person = {
    firstName: 'Jimmy',
    lastName: 'Smith',
    fullName(x){
     x.split(" ");
     firstName = x[0];
     lastName = x[1];
     return `${firstName} ${lastName}`; 
    }
}

person.fullName = 'Jack Franklin';
console.log(person.firstName); // jimmy
console.log(person.lastName) // smith

didn't work. haha

Aditya
@ezioda004
Nov 12 2018 04:15
Do this.firstName = x[0] and likewise for lastName
And also return${this.firstName}
kinopotato
@kinopotato
Nov 12 2018 04:17
var person = {
    firstName: 'Jimmy',
    lastName: 'Smith',
    fullName(x){
     x.split(" ");
     this.firstName = x[0];
     this.lastName = x[1];
     return `${this.firstName} ${this.lastName}`; 
    }
}

person.fullName = "Jack Franklin";
console.log(person.firstName); // jimmy 
console.log(person.lastName) // smith
haha, still didn't work.
Aditya
@ezioda004
Nov 12 2018 04:19

var person = {
    firstName: 'Jimmy',
    lastName: 'Smith',
    fullName(x){
     x = x.split(" ");
     this.firstName = x[0];
     this.lastName = x[1];
     return `${this.firstName} ${this.lastName}`; 
    }
}

person.fullName("Jack Franklin");
console.log(person.firstName); // Jack
console.log(person.lastName)  // Franklin
.fullName is a method, you're using it as a property. Also, .split() returns a new array.
kinopotato
@kinopotato
Nov 12 2018 04:20
hmm, but if x is not splitting then it should return J A right?
Aditya
@ezioda004
Nov 12 2018 04:21
Well you were using it as a property thats why. If you used it as a method and didnt assign x then yes it'd return J and a
kinopotato
@kinopotato
Nov 12 2018 04:23
so when it was just x.split(" ") what was happening when I did the person.fullName?
Aditya
@ezioda004
Nov 12 2018 04:27
You were overwriting the method with a new property.
person.fullName = "Jack Franklin"; //overwritten
kinopotato
@kinopotato
Nov 12 2018 04:28
var person = {
    firstName: 'Jimmy',
    lastName: 'Smith',
    fullName(x){
     x.split(" ");
     this.firstName = x[0];
     this.lastName = x[1];
     return `${this.firstName} ${this.lastName}`; 
    }
}
console.log(person.firstName); // Jack
console.log(person.lastName)  // Franklin
person.fullName("Jack Franklin");
that returns J a
well what we can get from this is that, I have other things to worry about than Get and Set xD
Aditya
@ezioda004
Nov 12 2018 04:29
Well yeah, x is a string and x[0] corresponds to Jand x[1] is a
Strings can act as an array.
Claudio Restifo
@Marmiz
Nov 12 2018 04:32
@kinopotato espectially since you are not assigning the splitted string to anything. x is still the original string
by the look of it you wanted to work on an array: ['Jack', 'Franklin']
kinopotato
@kinopotato
Nov 12 2018 04:34
hopefully I get the hang of this soon, I'm beginning to see how this works, barely. haha
Claudio Restifo
@Marmiz
Nov 12 2018 04:36

@kinopotato I mean, as you can see from the docs split returns a new array.

This means that the original string is not mutated, but a new value is returned (created).
Or in other words

    fullName(x){
     let s = x.split(" ");
     console.log(`x is ${x}, while s is ${s}`)
    }
Aditya
@ezioda004
Nov 12 2018 04:37
Strings are immutable so any method you use will always return a new string/array.
kinopotato
@kinopotato
Nov 12 2018 04:37
ohhh, so that's why .push works when .concat doesn't because you need a new array
so you always need to assign with something like .split .map .concat because they are supposed to not mutate the original array
Aditya
@ezioda004
Nov 12 2018 04:41
Most of the time you dont need to mutate the original array and all array methods also return a new array, except sort(). push() and few others.
kinopotato
@kinopotato
Nov 12 2018 04:43
this is why I've always had some trouble using concat when I want it to function like push. hmm
thanks again guys! that was insightful
Lia-Sue-Kim
@Lia-Sue-Kim
Nov 12 2018 05:20
is it okay if I put
<li class="menu"><a href=""><div></div><div></div><div></div></a></li>
Karma Drukpa
@coderkarma
Nov 12 2018 05:20
const JSX = (
  <div>
  {/*<h1>This is a block of JSX</h1>  
    <p>Here's a subtitle</p>
   */}
  </div>
);
Lia-Sue-Kim
@Lia-Sue-Kim
Nov 12 2018 05:20
to create menu icon
Karma Drukpa
@coderkarma
Nov 12 2018 05:21
why that commenting part is not working.
Lia-Sue-Kim
@Lia-Sue-Kim
Nov 12 2018 05:22
typing tags maybe?
i mean you literally wrote html in there
Aditya
@ezioda004
Nov 12 2018 05:25

@coderkarma

Add a comment somewhere within the provided div element, without modifying the existing h1 or p elements.

You dont need to comment the h1 and p tags, just need to add a comment.
Karma Drukpa
@coderkarma
Nov 12 2018 05:30
sorry, didn't realized that I misread.. thanks
Claudio Restifo
@Marmiz
Nov 12 2018 05:47
@Lia-Sue-Kim it's a valid markup, the only downside is selectors through child and sibilings since you have loads of divs
but yeah, I have in some nav:
nav
  ul
   li
    div ico
    div text
    div button
ReesesLover123
@ReesesLover123
Nov 12 2018 06:38
Is it possible for a script to change the class on another HTML page? I don't use external js sheets yet, but would that be the only way?
example - I want a function I call on this page to change the class on the bing website.
Claudio Restifo
@Marmiz
Nov 12 2018 07:52
nope, that would be cross scripting. Imagine all the bad things people can do if they could change something on another page without telling you @ReesesLover123
kinopotato
@kinopotato
Nov 12 2018 09:07
Hello, is there a way to multiply the int here by 2 in one line?
const squaredIntegers = arr.filter((int)=> Number.isInteger(int) && int > 0)
I mean by only using the one .filter
Stephen James
@sjames1958gm
Nov 12 2018 09:23
Filter only filters. To modify the values you need .map.
You could use reduce to filter and map at the same time
kinopotato
@kinopotato
Nov 12 2018 09:24
I keep forgetting what it is that reduce does exactly.
I just remember it when I need to sum an array. hahaha
kinopotato
@kinopotato
Nov 12 2018 09:50
so how do you do this with reduce?
const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34, -2];
const squareList = (arr) => {
  "use strict";
  // change code below this line
  const squaredIntegers = arr.filter((int)=>Number.isInteger(int) && int > 0).map((e)=>e*e);
  // change code above this line
  return squaredIntegers;
};
// test your code
const squaredIntegers = squareList(realNumberArray);
console.log(squaredIntegers);
Aditya
@ezioda004
Nov 12 2018 10:23
@kinopotato
arr.reduce((a, int) => Number.isInteger(int) && int > 0 ? a.push(int**2) && a: a, []);
kinopotato
@kinopotato
Nov 12 2018 10:25
@ezioda004 thanks dude! I'll try to understand this.
kinopotato
@kinopotato
Nov 12 2018 10:55
Aren't I doing "destructuring with reassigning" with my code?
const AVG_TEMPERATURES = {
  today: 77.5,
  tomorrow: 79
};

function getTempOfTmrw(avgTemperatures) {
  "use strict";
  // change code below this line
  const {tomorrow : tempOfTomorrow} = AVG_TEMPERATURES; // change this line
  // change code above this line
  return tempOfTomorrow;
}

console.log(getTempOfTmrw(AVG_TEMPERATURES)); // should be 79

it returns 79, and I did the whole

const {tomorrow : tempOfTomorrow} = AVG_TEMPERATURES;

but I'm not passing this
destructuring with reassignment was used

the guide says
Reassign properties using deconstruction.

var basicOjb = {x: 40};
//To reassign 'get the value of the x property of basicObj and place its value into bigX' in ES6:
const { x: bigX } = basicOjb;
consle.log(bigX) // ans = 40

which is what I did

Aditya
@ezioda004
Nov 12 2018 10:58
@kinopotato You need to destructure the function parameter not the global object.
kinopotato
@kinopotato
Nov 12 2018 10:59
the avgTemparatures?
welp, it worked.
Aditya
@ezioda004
Nov 12 2018 10:59
Yes.
kinopotato
@kinopotato
Nov 12 2018 11:00
was the es6 section new?
Aditya
@ezioda004
Nov 12 2018 11:01
Yep.
kinopotato
@kinopotato
Nov 12 2018 11:01
the section really seems odd compared to everything else that I've done
ohhhh, so that makes sense
Aditya
@ezioda004
Nov 12 2018 11:01
Odd in the sense?
Not polished?
kinopotato
@kinopotato
Nov 12 2018 11:01
yes
weird too especially with the higher order arrow function
Write Higher Order Arrow Functions << this one
Aditya
@ezioda004
Nov 12 2018 11:02
I dont think I've done that, but yeah ES6 section could use some more work.
kinopotato
@kinopotato
Nov 12 2018 11:02
completely unnecessarily difficult and unreasonable
it asks you to use higher order functions without even explaining what they are. xD it's just a passing thing, but to a beginner might as well be written in Japanese (well if you don't know Japanese)
Aditya
@ezioda004
Nov 12 2018 11:04
True, when I started out I felt the same about many challenges - back then there used to reference to MDN, like which concept/method was used so it was good but theres no direct reference anymore which kinda sucks.
kinopotato
@kinopotato
Nov 12 2018 11:07
plus, clicking that "hint" button makes you feel dirty. I clicked it on every ES6 challenge :|
Aditya
@ezioda004
Nov 12 2018 11:11
Hah, dont feel dirty, newer syntax takes time to sink in and besides you can see the section is not polished
Darren
@DarrenfJ
Nov 12 2018 12:33
morning fCC.. hope all the coding is going well :smile:
Niraj Nandish
@Nirajn2311
Nov 12 2018 13:32
Have to start coding for the day
@DarrenfJ morning, hows it going in Toronto
Luc Martin
@fmartin5
Nov 12 2018 14:27
Yeah some challenge descriptions need to be clearer and more helpful
@kinopotato Higher order functions is just a nice term for functions of functions
Luc Martin
@fmartin5
Nov 12 2018 14:36
So they are not restricted to just iterative functions like .map and .filter
Niraj Nandish
@Nirajn2311
Nov 12 2018 15:05
@diomed No puzzles today??
林剑豪
@xiaojianr
Nov 12 2018 15:10

<style>
.red-text {
color: red;
}

h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}

.smaller-image {
width: 100px;
}

.thin-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
}
</style>

<h2 class="red-text">CatPhotoApp</h2>

<img class="thick-green-border smaller-image" src="/images/relaxing-cat.jpg">

董兴龙
@xiaojilinggui
Nov 12 2018 15:20
为什么输入正确都不能过
May Kittens Devour Your Soul
@diomed
Nov 12 2018 16:11
@xiaojianr it aint thin, it's thick
Niraj Nandish
@Nirajn2311
Nov 12 2018 16:12
And the :cat: finally arrives
May Kittens Devour Your Soul
@diomed
Nov 12 2018 16:12
@Nirajn2311 I don't see people, so what's the point :P
Niraj Nandish
@Nirajn2311
Nov 12 2018 16:12
Yeah, it was a bit boring for me
I was the only one in the last hour going through PRs
So boring when no one else is there
May Kittens Devour Your Soul
@diomed
Nov 12 2018 16:13
lol, don't u have something interesting to do?
like - my datatablen for instance? :smiling_imp:
:yum:
Niraj Nandish
@Nirajn2311
Nov 12 2018 16:17
@diomed I solved your data table problem, but you never sent me the extra 500 entries you said you were going to send

lol, don't u have something interesting to do?

No, nothing to do just anxiously waiting for the positions for students day to come out

May Kittens Devour Your Soul
@diomed
Nov 12 2018 16:20
@Nirajn2311 so you want those 500 entries as well?
positions for what now?
Niraj Nandish
@Nirajn2311
Nov 12 2018 16:22

@Nirajn2311 so you want those 500 entries as well?

@diomed Send them to me

positions for what now?

Like who gets to be which teacher or supervisor

May Kittens Devour Your Soul
@diomed
Nov 12 2018 16:27
@Nirajn2311 are you gonna be teacher or superwisor
Niraj Nandish
@Nirajn2311
Nov 12 2018 16:28
Yeah, hoping for a supervisor
Gtg, will be back in 30 min
Send the data by then
May Kittens Devour Your Soul
@diomed
Nov 12 2018 16:28
ok.you'll get in pm
idris
@idris12
Nov 12 2018 18:16
hello
Philip Durbin
@pdurbin
Nov 12 2018 18:17
hi
May Kittens Devour Your Soul
@diomed
Nov 12 2018 20:20
internet is gonna be full of Marvel grief today/tomorrow
Christopher McCormack
@cmccormack
Nov 12 2018 20:21
@diomed what happened?
May Kittens Devour Your Soul
@diomed
Nov 12 2018 20:27
that old cameo man died
:disappointed:
Christopher McCormack
@cmccormack
Nov 12 2018 20:30
Stan Lee?
May Kittens Devour Your Soul
@diomed
Nov 12 2018 20:31
yes, Stanley
Christopher McCormack
@cmccormack
Nov 12 2018 20:31
aw that's sad.
I figured he would be some kind of god-like character expanded upon in the last movies
Cale Bybee
@calebybee
Nov 12 2018 20:35
Hey does anyone know QA testing in ruby?
Christopher McCormack
@cmccormack
Nov 12 2018 20:36
nope sorry
Lance
@texas2010
Nov 12 2018 22:54
hi everyone