These are chat archives for FreeCodeCamp/Help

22nd
Sep 2017
Engjell Bislimi
@Engjell00
Sep 22 2017 00:34
Is it me or some challenges in Javascript are really confusing
@bestintown23 The image is taking 100% of the width in my guess which is why the paragraph can't filled the place
try to put image and text in a container after that a id for the image and P
try width 30% on image 65% on the P
Engjell Bislimi
@Engjell00
Sep 22 2017 00:42
there is many ways to actually put it but just remember that if you don't fix the width of your element he will take all the width page.
even better putting the text at margin: auto;
crystalclea
@crystalclea
Sep 22 2017 01:12

Hi guys! I’m on the task “Check for palindromes”. It asks me to remove all the non-alphanumeric characters and turn things into lower case in order to check for palindromes. Here’re the codes I’ve put but they don’t work…

function palindrome(str) {
// Good luck!
if (str.replace(/[^\w\s]/gi, '').toLowerCase())
return true;
else {
return false;
}

}
palindrome("not a palindrome”);

Does anyone know what’s wrong with my codes?

Manish Giri
@Manish-Giri
Sep 22 2017 01:17
@crystalclea str.replace(/[^\w\s]/gi, '').toLowerCase()
this returns a value
but you're not using it anywhere
crystalclea
@crystalclea
Sep 22 2017 01:18
@Manish-Giri what do you mean by that?
Manish Giri
@Manish-Giri
Sep 22 2017 01:19
@crystalclea don't you want to compare that value with something?
crystalclea
@crystalclea
Sep 22 2017 01:19
it asks me to return “true” if the string is a palindrome and return “false” after testing that it’s not
@Manish-Giri however, after typing the conditions, i tested the strings and no matter what i put, they return “true"
Manish Giri
@Manish-Giri
Sep 22 2017 01:20
and how do you check if something is a palindrome?
@crystalclea
crystalclea
@crystalclea
Sep 22 2017 01:21
by removing all the weird symbols and turning them all to lowercase? then if the string reverse and it’s still spelt the same, it’s a palindrome
Manish Giri
@Manish-Giri
Sep 22 2017 01:22
yea
but you only did the first part
where's this part?
then if the string reverse and it’s still spelt the same,
crystalclea
@crystalclea
Sep 22 2017 01:23
oh yeah ! let me rethink about it
Manish Giri
@Manish-Giri
Sep 22 2017 01:24

and it's returning true always because of this line
if (str.replace(/[^\w\s]/gi, '').toLowerCase())

this just checks if what's inside the if is a truthy value, and unless you enter an empty string, it will always return true

crystalclea
@crystalclea
Sep 22 2017 01:25
oh…they don’t have taking out the symbols and turning to lowercase?
Manish Giri
@Manish-Giri
Sep 22 2017 01:25
um
this line does that
example - if your input was Wo$rD
this if would return the value word
and if(word) is always true
crystalclea
@crystalclea
Sep 22 2017 01:27
ohhh!! i get what u mean
after removing all the weird stuff, it doesn’t help validate thevakue
Manish Giri
@Manish-Giri
Sep 22 2017 01:30
nope
you need to write more code for that
i'd recommend starting with saving the lowercased value first
var cleanedUp = str.replace(/[^\w\s]/gi, '').toLowerCase();
then you can compare this to it's reversed value
and check if it's equal or not
if equal -> palindrome
else no palindrome
crystalclea
@crystalclea
Sep 22 2017 01:31
ohhhhhhh!!! ur tips are super useful
Manish Giri
@Manish-Giri
Sep 22 2017 01:34
:+1:
Gersho
@Gersho
Sep 22 2017 01:49
And finnally i have internet back :D that was long
Hello everyone
Eric Miller
@ericmiller777
Sep 22 2017 02:03
@Gersho hello
@Gersho wb
Gersho
@Gersho
Sep 22 2017 02:04
Oh Eric, lost power when we were talking the overday xD and when power went back on internet didn't
how's your tictactoe going ?
crystalclea
@crystalclea
Sep 22 2017 02:05
@Manish-Giri i’ve passed the challenge!!! Thank you so much!!!
CamperBot
@camperbot
Sep 22 2017 02:05
crystalclea sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6562 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Sep 22 2017 02:06
@crystalclea niice!
i didnt do the no win thing, since it wasnt a requirement anymore
Gersho
@Gersho
Sep 22 2017 02:07
didn't either, i feel like it should be easy since it's a children game
your tictactoe looks cool, only bad thing i have to say is that you can't play twice
Eric Miller
@ericmiller777
Sep 22 2017 02:08
you can
just give it a sec
i can lower the time
Gersho
@Gersho
Sep 22 2017 02:08
oh i see it
Ken Haduch
@khaduch
Sep 22 2017 02:08
@ericmiller777 - nice styling on the tic-tac-toe - I like that! They removed the "no win" requirement? That's good (I think)
Eric Miller
@ericmiller777
Sep 22 2017 02:09
yea, its not even a bonus staory anymore
story
i should start on simon but i been lazy
Gersho
@Gersho
Sep 22 2017 02:10
Simon's CSS drove me crazy
Grigor Minasyan
@gogminsam
Sep 22 2017 02:10
can someone help? I am on Pairwise challenge, I can't find the mistake on my code
function pairwise(arr, arg) {
  if (arr.length == 0) return 0;
  var objarr = [];
  var final = 0;
  for (i=0;i<arr.length;i++) {
    objarr.push({
      "id":i,
      "value":arr[i],
      "canused": true
    });
  }

  for (j=0;j<arr.length;j++) {
    if (objarr[j].canused) {
      for (k=1;k<arr.length;k++) {
        if (objarr[j].canused && objarr[k].canused && objarr[j].value + objarr[k].value == arg) {
          final = final + j+k;
          objarr[j].canused = objarr[k].canused = false;
          console.log(objarr[j].canused + objarr[k].canused);
        }
      }
    }
  }

  return final;
}

pairwise([1, 1, 1], 2);
Eric Miller
@ericmiller777
Sep 22 2017 02:10
yea, if i want it to look like simon looks hard
Gersho
@Gersho
Sep 22 2017 02:11
is pairwise the name of the challenge ?
Eric Miller
@ericmiller777
Sep 22 2017 02:11
havnt dont that one yet, gl and congrtas on finishing
done
its the last advanced algorithm
Gersho
@Gersho
Sep 22 2017 02:12
oh that's why i couldn't find it in my profile page, haven't done it yet xD
Grigor Minasyan
@gogminsam
Sep 22 2017 02:14
nevermind @Gersho i've fixed my mistake, i should have written j !== k . yes pairwise is the challenge's name.
Eric Miller
@ericmiller777
Sep 22 2017 03:16
@Gersho did you make a circle simon or a square, square seems simple
Gersho
@Gersho
Sep 22 2017 03:25
circle, i did it with 4 square (1 each color) and making it round with border radius
@ericmiller777
Eric Miller
@ericmiller777
Sep 22 2017 03:26
i see
@Gersho thanks
CamperBot
@camperbot
Sep 22 2017 03:26
ericmiller777 sends brownie points to @gersho :sparkles: :thumbsup: :sparkles:
:cookie: 443 | @gersho |http://www.freecodecamp.com/gersho
Gersho
@Gersho
Sep 22 2017 03:27
with that method i had to use z-index so the center interface is visible
Darren
@DarrenfJ
Sep 22 2017 03:56
evening fCC
Gersho
@Gersho
Sep 22 2017 03:56
:wave:
Darren
@DarrenfJ
Sep 22 2017 03:56
@thekholm80 hey thanks for the thanks!
CamperBot
@camperbot
Sep 22 2017 03:56
darrenfj sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1480 | @thekholm80 |http://www.freecodecamp.com/thekholm80
Darren
@DarrenfJ
Sep 22 2017 03:56
camperbot was down earlier
@Gersho hye brutha what up?
Gersho
@Gersho
Sep 22 2017 03:57
my internet was down for the last few days
also water
but everything's back we can be humans again
Darren
@DarrenfJ
Sep 22 2017 03:57
yer water was off too?
Gersho
@Gersho
Sep 22 2017 03:57
we had stock ^^
Darren
@DarrenfJ
Sep 22 2017 03:58
nothing quite like being human again ;)!~
Gersho
@Gersho
Sep 22 2017 03:59
on a more funny note, Canal + building was damaged a bit, the C fell of the main display
Darren
@DarrenfJ
Sep 22 2017 04:00
oh yah! i forgot yer in the path of that latest hurricane
:O
all good?
Gersho
@Gersho
Sep 22 2017 04:01
well apart from the water and internet yeah
heroiczero
@heroiczero
Sep 22 2017 04:01
@DarrenfJ TY :cookie: for you :)
CamperBot
@camperbot
Sep 22 2017 04:01
heroiczero sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2042 | @darrenfj |http://www.freecodecamp.com/darrenfj
Gersho
@Gersho
Sep 22 2017 04:02
minimal damage in town, mostly stuff that we're glad it broke down so the town will be forced to deal with it
Darren
@DarrenfJ
Sep 22 2017 04:06
oh thanks man for the brownies :D
and some back atcha
thanks @Gersho @heroiczero
CamperBot
@camperbot
Sep 22 2017 04:07
darrenfj sends brownie points to @gersho and @heroiczero :sparkles: :thumbsup: :sparkles:
:cookie: 444 | @gersho |http://www.freecodecamp.com/gersho
:star2: 1760 | @heroiczero |http://www.freecodecamp.com/heroiczero
Darren
@DarrenfJ
Sep 22 2017 04:07
@Gersho honestly, i am glad you are ok :D
Gersho
@Gersho
Sep 22 2017 04:07
thanks @DarrenfJ :)
CamperBot
@camperbot
Sep 22 2017 04:07
gersho sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2043 | @darrenfj |http://www.freecodecamp.com/darrenfj
Darren
@DarrenfJ
Sep 22 2017 04:27
ok gonna sneak off and watch vids/podcasts :D
Manish Giri
@Manish-Giri
Sep 22 2017 04:35
@DarrenfJ ty
CamperBot
@camperbot
Sep 22 2017 04:35
manish-giri sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2044 | @darrenfj |http://www.freecodecamp.com/darrenfj
Manish Giri
@Manish-Giri
Sep 22 2017 04:36
@Gersho good to hear you're safe..
heroiczero
@heroiczero
Sep 22 2017 04:36
@Manish-Giri :wave: Hello Cookie to you TY
CamperBot
@camperbot
Sep 22 2017 04:36
heroiczero sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6563 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Sep 22 2017 04:36
@heroiczero :wave: ty
(@&$@#&$@#&$)@##@$
Gersho
@Gersho
Sep 22 2017 04:36
\o/ thanks @Manish-Giri
CamperBot
@camperbot
Sep 22 2017 04:36
gersho sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6564 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Sep 22 2017 04:36
@heroiczero thx
oh ffs
@heroiczero ty
CamperBot
@camperbot
Sep 22 2017 04:37
manish-giri sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1761 | @heroiczero |http://www.freecodecamp.com/heroiczero
Sandeep Chary
@dsandeepchary
Sep 22 2017 04:51
Hi everyone
:wave:
Ken Haduch
@khaduch
Sep 22 2017 04:51
@dsandeepchary - hey there...
khaduch @khaduch - signing off for the night - happy coding everyone!
Eric Miller
@ericmiller777
Sep 22 2017 04:56
@khaduch good night
leisong1125
@leisong1125
Sep 22 2017 08:14
hello
Augustas
@AugustasV
Sep 22 2017 10:44
@camperbot sup
Stephen James
@sjames1958gm
Sep 22 2017 10:52
Hello
Martynas
@FlintMayers
Sep 22 2017 11:50
Is there anyone from UK here working as a developer?
rscales02
@rscales02
Sep 22 2017 12:46
function sumPrimes(num) {
  var arr = [];
  var newArr;

  for (var i =2; i<= num; i++){
    arr.push(i);

  }

  for (var x = 2; x < arr.length; x++){
    var m = Math.sqrt(arr[x]);
    for (var y = 2; y<= m; y++){
      if (arr[x]%y === 0){
        arr.splice(x,1);
      }
    }
  }
  console.log(newArr);
  return arr;
}

sumPrimes(20); //[2,3,5,7,9,11,13,16,17,19]
I need help understanding why 9 and 16 have shown up where they aren't wanted... based on the for(y) loop m = 3, which should splice out on the second running when 3%3 = 0, right?
korzo
@korzo
Sep 22 2017 12:56
@rscales02 Is't problem here? var m = Math.sqrt(arr[x]);
rscales02
@rscales02
Sep 22 2017 13:02
I don't think so... that decreases the number of iterations for my for(y) loop by half, I shouldn't need to test anything above the square root of arr[x]... for the example of 9: m=3 meaning 'for(y)would test 2 and 3. givingif (9%3 == 0) {splice(9)}`
korzo
@korzo
Sep 22 2017 13:14
@rscales02 Your loop doesn't run for numbers 5, 7, 9, 16
rscales02
@rscales02
Sep 22 2017 13:15
Any idea why?
korzo
@korzo
Sep 22 2017 13:16
you need x--; after splice
rscales02
@rscales02
Sep 22 2017 13:16
ah!
thanks!
korzo
@korzo
Sep 22 2017 13:16
because you remove element, but don't move counter and one element is skipped
rscales02
@rscales02
Sep 22 2017 13:17
Thanks @korzo !
CamperBot
@camperbot
Sep 22 2017 13:17
rscales02 sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 530 | @korzo |http://www.freecodecamp.com/korzo
korzo
@korzo
Sep 22 2017 13:25
@rscales02 Rule of thumb is to not use splice inside for loop. It introduces bugs like this.
Also you can clean your code a bit by using filter or extracting part of the code to function isPrime
rscales02
@rscales02
Sep 22 2017 13:27
as in making a new function isPrime(){}? Or is that built in?
korzo
@korzo
Sep 22 2017 13:28
function isPrime(){}
It's easier to process true/false inside loop
rscales02
@rscales02
Sep 22 2017 13:31
Why make things easier on myself lol :smile: let me see if I can implement that...
korzo
@korzo
Sep 22 2017 13:33

Because you have to return sum of primes.
If you extract

    var m = Math.sqrt(arr[x]);
    for (var y = 2; y<= m; y++){
      if (arr[x]%y === 0){
        arr.splice(x,1);
      }
    }

to function and the just test if arr[x] is prime and add it to sum

or use reduce as you have numbers in array
rscales02
@rscales02
Sep 22 2017 13:43
I am not clear on what you are suggesting... If I take that out of the loop and place it into another function x becomes an undefined variable unless I also include var x = ;
I am also not sure how true and false results could be turned back on the sumPrime() function usefully...
rscales02
@rscales02
Sep 22 2017 13:51
function sumPrimes(num) {
    var arr = [];
    var newArr;

    for (var i = 2; i <= num; i++) {
        arr.push(i);

    }

    for (var x = 2; x < arr.length; x++) {
        if (isPrime() === false) {
            arr.splice(x, 1);
            x--;
        }
    }

    function isPrime() {
        var m = Math.sqrt(arr[x]);
        for (var y = 2; y <= m; y++) {
            if (arr[x] % y === 0) {
                return false;
            } else {
                return true;
            }
        }
    }
    console.log(arr);
}

sumPrimes(20);
something like that?
Stephen James
@sjames1958gm
Sep 22 2017 13:53
@rscales02 You need to be careful about if return else return inside a loop or it won't loop - your true condition is probably not valid until the loop completes
@rscales02 Pass a value to the isPrime function and test that value
    function isPrime(v) {
        var m = Math.sqrt(v);
korzo
@korzo
Sep 22 2017 14:00
@rscales02
function sumPrimes(num) {
  var arr = [];
  var newArr;

  for (var i =2; i<= num; i++){
    arr.push(i);

  }

    return arr.reduce((a,e) => isPrime(e) ? a+e : a , 0);

}

function isPrime(n) {
    var m = Math.sqrt(n);
    for (var y = 2; y<= m; y++){
      if (n%y === 0){
        return false;
      }

    }
  return true;
}
rscales02
@rscales02
Sep 22 2017 14:06
ok... wow...
korzo
@korzo
Sep 22 2017 14:09
@rscales02 Or with for loop
function sumPrimes(num) {  
  var sum = 0;
  for (var i =2; i<= num; i++){
    if(isPrime(i)) {
      sum +=i;
    }
  }  
  return sum;
}

function isPrime(n) {
    var m = Math.sqrt(n);
    for (var y = 2; y<= m; y++){
      if (n%y === 0){
        return false;
      }        
    }
  return true;
}
rscales02
@rscales02
Sep 22 2017 14:13
That one I understand and I see what you mean by cleaning it up
why don't you have to specify if(isPrime(i) == true?
korzo
@korzo
Sep 22 2017 14:19
@rscales02 because isPrime return boolean (true or false)
rscales02
@rscales02
Sep 22 2017 14:21
OK, I think I understand... although my brain hurts now... thanks @korzo
CamperBot
@camperbot
Sep 22 2017 14:21
:cookie: 531 | @korzo |http://www.freecodecamp.com/korzo
rscales02 sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
korzo
@korzo
Sep 22 2017 14:22
@rscales02 if you compare to true ( === true) you don't have to specify it.
Javascript will convert expression to boolean automatically
Stephen James
@sjames1958gm
Sep 22 2017 14:44
@rscales02 Try reading the code in natural language.
start sum at zero
for each number from 2 to num
   if number isPrime
      add number to sum
rscales02
@rscales02
Sep 22 2017 14:51
I am still trying to get google translate to work that out for me into javascript lol, thanks @sjames1958gm I will try that out...
CamperBot
@camperbot
Sep 22 2017 14:51
rscales02 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8475 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Sep 22 2017 15:16
@rscales02 lol :)
Bikram Bhattacharya
@bikrambhattacharya
Sep 22 2017 16:09
How to search a question in stackoverflow using api?
artbohr
@artbohr
Sep 22 2017 16:19
Hey guys, can't understand why my bars are drawen from the wrong side instead of 1950 being the lowest value, highest GDP is drawen in 1950 instead of 2015.
https://codepen.io/artbohr/pen/mMKxKg?editors=1010
also if you see any clear bug in there, would be much appreciated apparts of the stated main problem
Stephen James
@sjames1958gm
Sep 22 2017 16:27
@artbohr Possibly reverse the range ([0, height]);
.range([0, height]);
artbohr
@artbohr
Sep 22 2017 16:29
@sjames1958gm that does it, but why is it working tho? I mean in all the tutorial examples it's like I had it because of the Y axis being drawn from above, do I probably have something reversed in the code? thanks
CamperBot
@camperbot
Sep 22 2017 16:29
artbohr sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8476 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Sep 22 2017 16:31
hmm, not sure
Christopher McCormack
@cmccormack
Sep 22 2017 16:32
Yeah you're numbers are backwards, the bars should increase
artbohr
@artbohr
Sep 22 2017 16:32
@cmccormack ye, but where? xD
Christopher McCormack
@cmccormack
Sep 22 2017 16:32
I remember having trouble with that as well haha
Christopher McCormack
@cmccormack
Sep 22 2017 16:45
Jeeze just realized how bad my code was for that project, you sure learn a lot as you go
rscales02
@rscales02
Sep 22 2017 16:57
So i have a function that ends with return a and the result is d, but when I try return a.match(/a-z/) it returns null shouldn't it return 0 since the string is only one letter long?
rscales02
@rscales02
Sep 22 2017 17:07
nevermind brackets apparently make a difference :smile:
artbohr
@artbohr
Sep 22 2017 17:07
@cmccormack haha, usual thing ^^, so didn't find the mystery reverse?
Christopher McCormack
@cmccormack
Sep 22 2017 17:08
@artbohr in your code?
artbohr
@artbohr
Sep 22 2017 17:09
@cmccormack ye
Christopher McCormack
@cmccormack
Sep 22 2017 17:11

@artbohr you're using

  const y = d3.scaleLinear()
              .domain([0,20000])
              .range([height,0]);

Which means when you pass a value to the scaling function you're going to return a number for the range. So if 0 goes in, height will come out. You just need to swap that

honestly you can do it a few different ways, it all depends on how you draw it
Stephen James
@sjames1958gm
Sep 22 2017 17:12
@rscales02 Yes /a-z/ means a then dash then z
rscales02
@rscales02
Sep 22 2017 17:13
Its always the little things :smile:
quickspeedy
@quickspeedy
Sep 22 2017 17:14
Hello, I'm working on seek and destroy exercise and I am so close to finishing it but I am stuck on the part where return word !== array[i]; only inspect the 2nd argument and not the 3rd argument. I can't think of any other ways for the filter to check the third argument. Any help is appreciated!
function destroyer(arr) {
  // Remove all the values
  var array = [];
  for(var i = 1; i<arguments.length; i++) {
    array.push(arguments[i]);
  }

  return arr.filter(function(word){
    for(var i = 0; i < arguments.length; i++) {
//       console.log(word !== arguments[i]);
      return word !== array[i];
    }
  });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Christopher McCormack
@cmccormack
Sep 22 2017 17:14
You could also do it like you have it now but then draw it like this:
      .attr("height", d => {
        return height - y(d[1]);
      })
...
      .attr("y", d => {
        return y(d[1]);
      });
artbohr
@artbohr
Sep 22 2017 17:16
@cmccormack that's the thing I was looking for, thank you very much!
CamperBot
@camperbot
Sep 22 2017 17:16
artbohr sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1220 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Sep 22 2017 17:17
@artbohr I would also recommend using your extents for your domain as well:
.domain(d3.extent(data.data, (d)=>d[1]))
artbohr
@artbohr
Sep 22 2017 17:19
@cmccormack got it, ty
CamperBot
@camperbot
Sep 22 2017 17:19
artbohr sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
api offline
Christopher McCormack
@cmccormack
Sep 22 2017 17:20
@artbohr thank you for forcing me to evaluate my own code and make it better :D
CamperBot
@camperbot
Sep 22 2017 17:20
cmccormack sends brownie points to @artbohr :sparkles: :thumbsup: :sparkles:
:cookie: 309 | @artbohr |http://www.freecodecamp.com/artbohr
artbohr
@artbohr
Sep 22 2017 17:21
@cmccormack you are welcome! haha
Alexander Køpke
@alexanderkopke
Sep 22 2017 17:25
@quickspeedy https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments a little down there is a shown a way to store arguments in an array (Array.from(arguments). In this case also the array passed into the function would be included but you can use the shift method to get rid of that array. So you'll have arr, which is the array passed in, and you'll have an array with the 2 and 3 in this case. Then you can filter arr with indexOf on last array.
quickspeedy
@quickspeedy
Sep 22 2017 17:29
Ok thanks for the advice! @alexanderkopke
CamperBot
@camperbot
Sep 22 2017 17:29
quickspeedy sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1657 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Razvan
@razvanlikespizza
Sep 22 2017 18:17
How to center a div, and to be responsive at the same time? plss pleaseeee <3
piteto
@piteto
Sep 22 2017 18:47
@razvanlikespizza Depends on the content in the div, but for most you can start with:
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
aRtoo
@artoodeeto
Sep 22 2017 18:55
fam im setting up a new value for the first name but it not returing the value from the parameter that i set.
var Person = function(firstAndLast) {
    // Complete the method below and implement the others similarly
    // this.getFullName = function() {
    //   return "";
    // };


    var first = firstAndLast.split(' ')[0];
    var last = firstAndLast.split(' ')[1];
    var fullName = first + ' ' + last;


    return  {
      getFullName: function() {
        return fullName;
      },

      getFirstName: function() {
        return first;
      },

      getLastName: function() {
        return last;
      },

      setFirstName: function(newFirst) {
         first = newFirst;
      },

      setLastName: function(newLast) {
         last = newLast;
      },

      setFullName: function(newFullname) {
         firstAndLast = newFullname;
      }
    };
};

var bob = new Person('Bob Ross');

 bob.setFirstName('check');
 bob.getFullName();
ehutchllew
@ehutchllew
Sep 22 2017 18:55
@razvanlikespizza I suggest taking a look at flexbox, using their justification and alignment. But otherwise try
margin: 0 auto;
ehutchllew
@ehutchllew
Sep 22 2017 19:14
@artoodeeto still there?
@artoodeeto The reason is because your getFullName() is calling your var fullName which is set as soon as the function is called.
@artoodeeto and isn't changed by calling setFirstName();
@artoodeeto if you do something like this:
getFullName: function(){
fullName = first + ' ' +last;
return fullName;
}
Christopher McCormack
@cmccormack
Sep 22 2017 19:16
Yeah it was answered in Help JavaScript as well and he never responded
ehutchllew
@ehutchllew
Sep 22 2017 19:16
damn, been a while since i've been on here, sticky fingers.
ah okay.
Christopher McCormack
@cmccormack
Sep 22 2017 19:17
@ehutchllew I agree with your solution though
or just return the interpolation without creating a variable, either way
ehutchllew
@ehutchllew
Sep 22 2017 19:18
yeah, I haven't used that type of function syntax in a minute
been mainly working with React.
Christopher McCormack
@cmccormack
Sep 22 2017 19:19
Yeah weird how with React you stop writing normal code haha
it's almost all declarative
ehutchllew
@ehutchllew
Sep 22 2017 19:20
yeah, I do like components and classes though :D
aRtoo
@artoodeeto
Sep 22 2017 19:27
@ehutchllew yow bro
@ehutchllew broooo??
ehutchllew
@ehutchllew
Sep 22 2017 19:36
@artoodeeto what's up
Mike Batista
@mbmontana
Sep 22 2017 19:41
The challenge is to remove all elements in the array [1, 2, 3, 1, 2, 3] that match the arguments outside the array (2, 3). Trying to iterate through arr and args, then filtering and returning whatever isn't equal.
Am I in the ballpark here?
function destroyer(arr) {
  // Remove all the values
  var args = Array.prototype.slice.call(arguments);

 var newArray;

    newArray=arr.filter(function(arr){
      for (var i=0; i < arr.length; i++) {for (var j=1; j < args.length; j++)
      return arr[i] != args[j]; }
    });

 return args[1];

}


destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Razvan
@razvanlikespizza
Sep 22 2017 19:44
I'm on my phone , waisting time, what should I read?
Ravi Kishore Thella
@ravikishorethella
Sep 22 2017 21:32
@razvanlikespizza go through this
http://www.ecma-international.org/ecma-262/
keanusuasuasuasuasuas
@keanusuasuasuasuasuas
Sep 22 2017 21:45
Hey! I'm trying to make a gradient background (going diagonal). This works: background: linear-gradient(to right, red, yellow); but this doesn't: background: linear-gradient(to bottom right, red, yellow); when I try this, the backgorund just starts repeating.
piteto
@piteto
Sep 22 2017 21:56
@keanusuasuasuasuasuas :point_up: I answered you over here
korzo
@korzo
Sep 22 2017 22:18
@ravikishorethella :smile:
Ravi Kishore Thella
@ravikishorethella
Sep 22 2017 22:19
@korzo :smile: that is a good thing to read right?
korzo
@korzo
Sep 22 2017 22:24
@ravikishorethella it is, but probably not something to read nonchalantly on mobile
Ravi Kishore Thella
@ravikishorethella
Sep 22 2017 22:25
@korzo yes, you are right. I should have suggested him to read YDKJS book. That would be a good option and infact that is quite interesting as well
korzo
@korzo
Sep 22 2017 22:27
@ravikishorethella yes, this is much better option. or JS the right way
ECMA is extremely hard to read and you need to have open several pages for references.
Ravi Kishore Thella
@ravikishorethella
Sep 22 2017 22:28
Yes