These are chat archives for FreeCodeCamp/HelpJavaScript

9th
Mar 2018
Tai Jones
@taiJones00
Mar 09 2018 00:09
This. was working yesterday. Why are all these errors showing up? https://codepen.io/taiJones00/pen/oEKZYL?editors=1010
Tai Jones
@taiJones00
Mar 09 2018 00:14
o_0 it works. Must have been the server
FlashHero
@FlashHero
Mar 09 2018 00:46
How do you make images responsive with reactstrap
Gulsvi
@gulsvi
Mar 09 2018 01:02
@FlashHero class="img-fluid"
  render() {
    return (
      <Container>
        <Row>
          <Col>
            <img
              class="img-fluid"
              src="https://placehold.it/4000x4000"
            />
          </Col>
        </Row>
      </Container>
    );
  }
FlashHero
@FlashHero
Mar 09 2018 01:06
@gulsvi that's reactstrap? I thought it had built in components
but i couldn't find the image component
Gulsvi
@gulsvi
Mar 09 2018 01:07
I don't know if they have an image component, but that works fine with Reactstrap
FlashHero
@FlashHero
Mar 09 2018 01:09
@gulsvi thanks, you know how to center a image inside of a column
Gulsvi
@gulsvi
Mar 09 2018 01:09
@FlashHero class="img-fluid d-block mx-auto"
It looks like they have some image examples here: https://reactstrap.github.io/components/media/
FlashHero
@FlashHero
Mar 09 2018 01:12
@gulsvi thanks man it worked
CamperBot
@camperbot
Mar 09 2018 01:12
flashhero sends brownie points to @gulsvi :sparkles: :thumbsup: :sparkles:
:star2: 2660 | @gulsvi |http://www.freecodecamp.org/gulsvi
Gulsvi
@gulsvi
Mar 09 2018 01:12
Glad I could help
FlashHero
@FlashHero
Mar 09 2018 01:13
I looked at that but i wasn't sure it was for images
Gulsvi
@gulsvi
Mar 09 2018 01:13
I can't get it working to be honest - but if I figure it out, I'll let you know
FlashHero
@FlashHero
Mar 09 2018 01:13
ok @gulsvi thanks
CamperBot
@camperbot
Mar 09 2018 01:13
flashhero sends brownie points to @gulsvi :sparkles: :thumbsup: :sparkles:
api offline
Tai Jones
@taiJones00
Mar 09 2018 03:37
Is this valid in react?
generateList(typeOfUsers) {
    this.state.typeOfUsers.map((user, i) => (
      <li
        key={i}
        className="col-xs-12 col-sm-6 col-md-4 col-lg-3 listStyle"
      >
        <h4 className = "numberedStyle">{i + 1}</h4>
        <img src={user.img} className = "imgStyle" />
        <h4 className = "userNameStyle">{user.username}</h4>
        <h5 className = "pointsStyle">{user.points}</h5>
      </li>
    ));
const recentUsers = generateList(recentUsers);
this.generateList = this.generateList.bind(this);
I also binded the method in the constructor but my page won't load when I have this method
Basically i'm doing that instead of something like this
const allTimeUsers = this.state.allTimeUsers.map((user, i) => (
      <li
        key={i}
        className="col-xs-12 col-sm-6 col-md-4 col-lg-3 listStyle"
      >
        <h4 className = "numberedStyle">{i + 1}</h4>
        <img src={user.img} className = "imgStyle" />
        <h4 className = "userNameStyle">{user.username}</h4>
        <h5 className = "pointsStyle">{user.points}</h5>
      </li>
    ));
abraham anak agung
@padunk
Mar 09 2018 03:40
@taiJones00 why you have parameter typeOfUsers if you don't use it?
everything seems fine
Tai Jones
@taiJones00
Mar 09 2018 03:41
I do. this.state.typeOfUsers
abraham anak agung
@padunk
Mar 09 2018 03:41
i think it should be this.state[typeOfUsers] it not the same
Tai Jones
@taiJones00
Mar 09 2018 03:42
@padunk
Okay i'll try that
this.state[typeOfUsers].map((user, i) like this? @padunk
abraham anak agung
@padunk
Mar 09 2018 03:43
yes
Tai Jones
@taiJones00
Mar 09 2018 03:43
Hm it's not working
abraham anak agung
@padunk
Mar 09 2018 03:47
what are you trying to do? your code is confusing.
@taiJones00 i see your code now, you have to invoke it with this.generateList("recentUsers")
Tai Jones
@taiJones00
Mar 09 2018 03:50
So this method should map through an array in my Components state. Each index of this array i'm targeting is an object. I'm matching each property of each object to an element in a list. Like with img src equaling user.img
ohhhh
abraham anak agung
@padunk
Mar 09 2018 03:51
@taiJones00 it is difference if you name your parameter with the value you passed through
Tai Jones
@taiJones00
Mar 09 2018 03:51
Ah. That didn't do it
What do you mean? @padunk
abraham anak agung
@padunk
Mar 09 2018 03:53
@taiJones00 nvm, i mean you can't call a function with function(something) {} except something already have a value store in variable.
Tai Jones
@taiJones00
Mar 09 2018 03:54
What do you mean?
abraham anak agung
@padunk
Mar 09 2018 03:54
because it is async i think. so your array still empty
@taiJones00 nah, i mean the last time you call generateList(recentUsers)
Tai Jones
@taiJones00
Mar 09 2018 03:54
Oh no that's not it. It worked perfectly fine with I didn't make this list assignment it's own method. It's only acting up because i'm getting the syntax wrong somehow
abraham anak agung
@padunk
Mar 09 2018 03:55
@taiJones00 try open it in debug mode and open your devtools (F12 in windows)
Tai Jones
@taiJones00
Mar 09 2018 03:56
It keeps saying read property of map undefined... hmmm @padunk
abraham anak agung
@padunk
Mar 09 2018 03:57
@taiJones00 because it async i think, cause componentDidMount run after render
why you put it in render ?
Tai Jones
@taiJones00
Mar 09 2018 03:58
Hmm. I'll just put it back to how it was. Thank you @padunk
CamperBot
@camperbot
Mar 09 2018 03:58
taijones00 sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 470 | @padunk |http://www.freecodecamp.org/padunk
Tai Jones
@taiJones00
Mar 09 2018 03:58
It works in render. It's some syntax thing that happened when I made the list assignment happen in it's own method
abraham anak agung
@padunk
Mar 09 2018 03:59
@taiJones00 :+1:
abraham anak agung
@padunk
Mar 09 2018 06:49
Anyone can help with async await? say i have zero data, then i call api-username.com to get only the username and store it in an array. After got the username than i need to call api-moredata/{username}.com to get more data. How to do this properly?
Claudio Restifo
@Marmiz
Mar 09 2018 07:43
@padunk it's easy to chain async/await function so that they look like synchronous code:
// call username and return the username
const userAPI = async () => {
  const name = await myUsernameAPI().then(res => res)
  return name;
}

// call a second API, that rely on the username to be called first:
const dataAPI = async () => {
  const name = await userAPI();
  const data = await fetchData(name)

  console.log(data)
}
abraham anak agung
@padunk
Mar 09 2018 07:51
@Marmiz name in dataAPI will be an array or object right? So you can await the async function again with await userAPI never tought about that. Thanks.
CamperBot
@camperbot
Mar 09 2018 07:51
padunk sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1185 | @marmiz |http://www.freecodecamp.org/marmiz
Claudio Restifo
@Marmiz
Mar 09 2018 07:54

@padunk if you notice the first function, userAPI is returning whatever data gets returned from the query.
So in the second function the const name will hold whatever the first value returns, then use that value as param for the second api call fetchData.

this is an idea, but you should be able to adapt it to your needs pretty easily

abraham anak agung
@padunk
Mar 09 2018 07:55
@Marmiz yes, i know. working on it now :smile:
Claudio Restifo
@Marmiz
Mar 09 2018 08:07
happy coding :sparkles:
abraham anak agung
@padunk
Mar 09 2018 08:22
@Marmiz more question, will setState have the value from await or just have undefined?
const userAPI = async () => {
  const name = await myUsernameAPI().then(res => res)
  this.setState({ name })
}
Claudio Restifo
@Marmiz
Mar 09 2018 08:32

@padunk set state will be evaluated after the await resolve, so it should have the name value.

But I would consider also error handling

alpox
@alpox
Mar 09 2018 08:32
@padunk it will have thr name which is returned from the promise. Btw. The .then(res => res) can be removed. It does pretty much nothing
abraham anak agung
@padunk
Mar 09 2018 08:34
@alpox even i use fetch? how to write it properly in codepen? i hv Uncaught ReferenceError: regeneratorRuntime is not defined error.
alpox
@alpox
Mar 09 2018 08:34
@padunk with fetch you usually need the res.json() so there you might need it
That error comes when async await is not supported by your babel. You have to add a plugin/environment
Claudio Restifo
@Marmiz
Mar 09 2018 08:35

then(res => res) can be removed. It does pretty much nothing

it reminds you that you are not handling errors :smile:

abraham anak agung
@padunk
Mar 09 2018 08:36
@alpox ah, so more work. i think i switch working in my VScode then :smile: Thanks btw.
CamperBot
@camperbot
Mar 09 2018 08:36
padunk sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1580 | @alpox |http://www.freecodecamp.org/alpox
alpox
@alpox
Mar 09 2018 08:36
@Marmiz i do, he doesnt - yet :D
abraham anak agung
@padunk
Mar 09 2018 08:36
lol....
btw how you handling error with async await ? with try and catch?
Claudio Restifo
@Marmiz
Mar 09 2018 08:38
yep, or you can get the err if the promise get rejected. Up to you
@alpox :smile: :smile: :smile: I was being sarcastic :smile: :+1:
abraham anak agung
@padunk
Mar 09 2018 08:40
@Marmiz :+1:
jetjet-ma
@jetjet-ma
Mar 09 2018 08:46
I don't know,What does This section (Word Blanks)want me to do?
abraham anak agung
@padunk
Mar 09 2018 08:50
@jetjet-ma concat a string.
Francois Beyers
@Blusoup
Mar 09 2018 09:03
I'm having trouble with regex. I have 2 radio buttons: a "Yes" and a "No" button. I want to capture whatever button is selected and have it just print out "Y" or "N". I can capture the "Yes" or "No", but even with the RegEx that I have it still does not change. Can some tell me what is wrong with this code? Thank you. $('input[name="balanceTransferOption"]:checked').next().text().replace(/^[a-zA-Z]{1}$/);
alpox
@alpox
Mar 09 2018 10:12
@Blusoup better use the value of the input (.val()) instead of getting the text like now. You can already set the value to Y or N so that you dont need regex
Francois Beyers
@Blusoup
Mar 09 2018 10:37
thank you @alpox
CamperBot
@camperbot
Mar 09 2018 10:37
blusoup sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1581 | @alpox |http://www.freecodecamp.org/alpox
Jefferson
@jeffersonnnn
Mar 09 2018 13:44
hi guys, i am stuck with an elementary problem. I am trying to write a function that that determines if a word is an isogram . Here is my code. Help!
function isIsogram(word){
  if (typeof(word) === "boolean" ) {
    return "true"
  } else {
    "false"
  }


isIsogram("Dermatoglyphics");
Stephen James
@sjames1958gm
Mar 09 2018 13:52
@jeffersonnnn
  1. you are missing a closing }
  2. Are you supposed to return a string or a boolean?
  3. Why are you testing for type boolean?
abraham anak agung
@padunk
Mar 09 2018 13:53
@jeffersonnnn what is isogram?
Arturo Mago
@ArturoMago
Mar 09 2018 13:54
where are you defining which word is Boolean?
Jefferson
@jeffersonnnn
Mar 09 2018 13:54
@sjames1958gm 1. thanks, i have amended that. 2. I am supposed to return a string 3. Ofcouse! I was testing for string 'Boolean'! That was my error. Thanks guys @sjames1958gm @padunk @ArturoMago !!
CamperBot
@camperbot
Mar 09 2018 13:54
jeffersonnnn sends brownie points to @sjames1958gm and @padunk and @arturomago :sparkles: :thumbsup: :sparkles:
:cookie: 214 | @arturomago |http://www.freecodecamp.org/arturomago
:cookie: 472 | @padunk |http://www.freecodecamp.org/padunk
:star2: 9074 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Mar 09 2018 14:12
@jeffersonnnn :+1:
Nate Mallison
@NJM8
Mar 09 2018 14:55
Hey all I have some questions about minification of HTML, CSS, and JS
Nate Mallison
@NJM8
Mar 09 2018 15:03
Obviously it's a good idea. But my big questions are:
  1. At what point is the return so small it isn't worth while, like if my CSS and JS files are > 50 lines?
  2. If I minify files from the cmd line should I have a working branch and a deploy branch? I assume once the code is minified it's hard to read and work with. So I imagine, do all work on working branch, merge to master, minify and deploy from master?
  3. Finally, some of my websites are getting low scores on pageSpeed insights because I load lots of resources. They are on CDN's, but I use Materialize CSS on some sites so I have jQuery, materialize css and js, as well as my own js and css, maybe also font-awesome and popper.js. That's a lot of calls out to resources. Would it be a good idea to download the non-minified code for all these frameworks and minify them together (in proper order) along with my JS so it can all be served from one cdn call? I'm using cloudfare so all my code is basically on a cdn. (Although there could be issues here in browser caching, so maybe I just minify all my outside sources together and leave my js separate, cache the outside sources and not mine? Well in that case it would be best to cache outside sources and just minify my own code and serve it fresh each time. Then I wouldn't need to minify outside sources together to lower calls.)
Stephen James
@sjames1958gm
Mar 09 2018 15:06
@NJM8 webpack is a tool that is designed to build bundles like you are talking about.
Nate Mallison
@NJM8
Mar 09 2018 15:07
@sjames1958gm But I like reinventing wheels!
Stephen James
@sjames1958gm
Mar 09 2018 15:07
@NJM8 I think webpack supports dev and production modes which may allow non-minification for dev code.
I have used it mostly around react which is compiled as it is
Nate Mallison
@NJM8
Mar 09 2018 15:10
Have you tried it on static websites? I think I may be over optimizing. Some of my pages are less than 100 lines combined html, css and js.
I think at this point making sure my caching is working correctly will be enough
ehutchllew
@ehutchllew
Mar 09 2018 15:39
@NJM8 I think minifying is a benefit when you have like thousands of lines of code. Otherwise I don't think it's going to make a huge impact.
Jason Luboff
@JLuboff
Mar 09 2018 16:09
Morning (afternoon/evening/night)
Arturo Mago
@ArturoMago
Mar 09 2018 16:12

var myObj = {
dog: "Perro",
cat: "Gato",
monkey: "Mono"
};

function propObj(checkProp){

resultado = "";

if (myObj.hasOwnPropety(checkProp)){
 resultado = myObj[checkProp];

}else{
    resultado= "No se encontro";
}

return resultado;

}

propObj("dog");

please
Jason Luboff
@JLuboff
Mar 09 2018 16:15
@ArturoMago You misspelled property in hasOwnProperty
Markus Kiili
@Masd925
Mar 09 2018 16:22
:wave:
Jason Luboff
@JLuboff
Mar 09 2018 16:23
What up
Markus Kiili
@Masd925
Mar 09 2018 16:23
@JLuboff Told my boss today that I will quit. Seems that I will have to / have a chance to learn Clojure on my new job.
I have been looking for some real language to learn, so not a problem.
Stephen James
@sjames1958gm
Mar 09 2018 16:24
@Masd925 :+1:
Jason Luboff
@JLuboff
Mar 09 2018 16:25
How'd you're boss take it?
Markus Kiili
@Masd925
Mar 09 2018 16:25
@JLuboff Not the most pleasant thing to say on a small firm, but that happens.
Jason Luboff
@JLuboff
Mar 09 2018 16:25
As they say, you don't owe your employer anything
Markus Kiili
@Masd925
Mar 09 2018 16:26
@JLuboff Yes, and we only work because the mailbox is full of bills.
Jason Luboff
@JLuboff
Mar 09 2018 16:26
Exactly
Markus Kiili
@Masd925
Mar 09 2018 16:27
@JLuboff Also some TDD is on the learning map.
Ken Haduch
@khaduch
Mar 09 2018 16:28
@Masd925 - best of luck on the new job!
Markus Kiili
@Masd925
Mar 09 2018 16:29
@khaduch @JLuboff @sjames1958gm Thanks!
CamperBot
@camperbot
Mar 09 2018 16:29
masd925 sends brownie points to @khaduch and @jluboff and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2360 | @jluboff |http://www.freecodecamp.org/jluboff
:star2: 9075 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
:star2: 3783 | @khaduch |http://www.freecodecamp.org/khaduch
Markus Kiili
@Masd925
Mar 09 2018 16:29
First big firm that I work for in ICT sector.
Jason Luboff
@JLuboff
Mar 09 2018 16:30
@Masd925 Ohhh TDD...fun. I'd really like to take some time to learn more about testing
Markus Kiili
@Masd925
Mar 09 2018 16:33
@JLuboff Me too.
@JLuboff I would also like to work with requirements process, which is sick.
Jason Luboff
@JLuboff
Mar 09 2018 16:36
Super sick
Markus Kiili
@Masd925
Mar 09 2018 16:37
@JLuboff I could clean IT-firm toilets, so most likely I will not get unemployed.
Arturo Mago
@ArturoMago
Mar 09 2018 16:47
@JLuboff thanks bro
CamperBot
@camperbot
Mar 09 2018 16:47
arturomago sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2361 | @jluboff |http://www.freecodecamp.org/jluboff
Tiago Correia
@tiagocorreiaalmeida
Mar 09 2018 16:48
return temp.sort((a,b)=> a[2] - b[2] || a[0] + b[0]);
doesnt this sort's by the second condition if in the first they are equal?
Stephen James
@sjames1958gm
Mar 09 2018 17:53
@tiagocorreiaalmeida yes
Tiago Correia
@tiagocorreiaalmeida
Mar 09 2018 17:57
@sjames1958gm somehow its failing me will send you the challenge and my code
alpox
@alpox
Mar 09 2018 18:38
@Masd925 Oh lucky you! I'd like to get into a clojure job a lot.
function digitDifferenceSort(a) {
    let temp = a.map((ele,i)=>{
        let sum = ele < 10 ? 0 : (Math.max.apply(null,ele.toString().split("")) - Math.min.apply(null,ele.toString().split("")));
        return [i,ele,sum];
    })

    let sortedData = temp.sort((a,b)=> a[2] - b[2] || a[0] + b[0]);

    console.log(sortedData);

    return sortedData.map((ele)=>ele[1]);
}
Ayush Bahuguna
@relentless-coder
Mar 09 2018 18:42
function newEl(){
  const el = document.createElement('p');
  const dl = document.createElement('p');
  dl.innerText = 'Yo Yo';
  el.innerText = 'Hello wolrd';
  const els = [el, dl];
  const returnP = (ps)=>{
    return ps.forEach(el => el.outerHtml)
  };
  return `
    <div>${returnP(els)}</div>
  `
}
Hey, yeah so, I am trying out something, I need ideas with this. I am trying to dynamically get outerHtml of an element within a string literal
Markus Kiili
@Masd925
Mar 09 2018 18:56
@alpox There is some training at the start of the job that uses clojure. Not sure about the actual work. They use java backend so maybe clojure too.
Ayush Bahuguna
@relentless-coder
Mar 09 2018 19:07
function newEl(){
  const el = document.createElement('p');
  const dl = document.createElement('p');
  dl.innerText = 'Yo Yo';
  el.innerText = 'Hello wolrd';
  const els = [el, dl];
  console.log(el.outerHTML);
  const returnP = (ps)=>{
    return ps.map(el => el.outerHTML).join('\n')
  };
  return `<div>
    ${returnP(els)}
</div>`
}
Okay, I got it
Tiago Correia
@tiagocorreiaalmeida
Mar 09 2018 19:07
@sjames1958gm any idea?
Tiago Correia
@tiagocorreiaalmeida
Mar 09 2018 19:51
@alpox around to help me on this one?
Randell Dawson
@RandellDawson
Mar 09 2018 19:58
@tiagocorreiaalmeida - When I click on the link, it says I am not authorized for the challenge. What is the function supposed to return and can you supply a couple test cases, so I can see what the argument a looks like?
Tiago Correia
@tiagocorreiaalmeida
Mar 09 2018 19:58
@randelldawson hum crap :\ I can indeed copy and past the challenge code and send you some test code ona jsfidle sec
alpox
@alpox
Mar 09 2018 19:58
@tiagocorreiaalmeida im not authorized to see it :D
Also, im on phone :/
Tiago Correia
@tiagocorreiaalmeida
Mar 09 2018 19:59
yeah figure it out no worries @alpox
@randelldawson
t0cc
@t0cc
Mar 09 2018 20:39
Hi, I set the latest jquery version and I can use eg css() click() or other selectors, except usinf $(this) seems not to work at all. What might be the cause for this?
Is $(this) deprecated somehow? I wonder...
I my better ask in the mian channel
Tiago Correia
@tiagocorreiaalmeida
Mar 09 2018 20:43
try to console.log($(this)) to see what it returns first?
Adel
@AdelMahjoub
Mar 09 2018 20:43
@t0cc maybe you the callback is a fat arrow function
Matej BoĆĄnjak
@mbosnjak01
Mar 09 2018 20:43
console.log N1 problem solver in the universe
Adel
@AdelMahjoub
Mar 09 2018 20:49
@t0cc replace that fat arrow callback function with function and the code you posted in the main channel should work
@t0cc this in your case don't refer to the clicked object
Tiago Correia
@tiagocorreiaalmeida
Mar 09 2018 20:52
hey @AdelMahjoub do you normal do codefights?
Adel
@AdelMahjoub
Mar 09 2018 20:52
@tiagocorreiaalmeida tried some couple of codewars that's all
Tiago Correia
@tiagocorreiaalmeida
Mar 09 2018 20:53
there's one challenge on codefights, do you have 2min to give a look in an issue im running into to?
Adel
@AdelMahjoub
Mar 09 2018 20:55
@tiagocorreiaalmeida I have to sign in first I guess, let's give it a shot
Tiago Correia
@tiagocorreiaalmeida
Mar 09 2018 20:55
yeah indeed @AdelMahjoub and thanks :D
CamperBot
@camperbot
Mar 09 2018 20:55
tiagocorreiaalmeida sends brownie points to @adelmahjoub :sparkles: :thumbsup: :sparkles:
:cookie: 666 | @adelmahjoub |http://www.freecodecamp.org/adelmahjoub
Tiago Correia
@tiagocorreiaalmeida
Mar 09 2018 20:55
damn the 666
Adel
@AdelMahjoub
Mar 09 2018 20:56
@tiagocorreiaalmeida that should be over 670, the bot is tired of counting :laughing:
@tiagocorreiaalmeida which section then, interview or learn ? or the choice doesn't matter to see the challenge
Tiago Correia
@tiagocorreiaalmeida
Mar 09 2018 20:57
arcade mode task 120
you can unlock unthil tere with coins if you dont have them done
if you can't see it I sent above a codepen but would be harder that way
Randell Dawson
@RandellDawson
Mar 09 2018 21:03
@tiagocorreiaalmeida
let sortedData = temp.sort((a,b)=> a[2] === b[2] ? b[0] - a[0]: a[2] - b[2]);
Adel
@AdelMahjoub
Mar 09 2018 21:14
@tiagocorreiaalmeida it is easy to access unsolved section but for challenges it will need sometime to hack it, I'll take a look at the challenges on that jsfiddle
Tiago Correia
@tiagocorreiaalmeida
Mar 09 2018 21:28
no need @AdelMahjoub my sort was really dumb I need to take a nap :D thanks @randelldawson for the code
CamperBot
@camperbot
Mar 09 2018 21:28
tiagocorreiaalmeida sends brownie points to @adelmahjoub and @randelldawson :sparkles: :thumbsup: :sparkles:
:cookie: 311 | @randelldawson |http://www.freecodecamp.org/randelldawson
api offline
Brian
@BrianCodes33
Mar 09 2018 21:38
const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
  "use strict";
  // change code below this line
  const squaredIntegers = arr.map((num) => num > 0 && num % 1 === 0).filter((num) => num > 0);
  // change code above this line
  return squaredIntegers;
};
// test your code
const squaredIntegers = squareList(realNumberArray);
console.log(squaredIntegers);
Use arrow function syntax to compute the square of only the positive integers (fractions are not integers) in the array realNumberArray and store the new array in the variable squaredIntegers.
Adel
@AdelMahjoub
Mar 09 2018 22:24
@tiagocorreiaalmeida check this when you come back :laughing:
function digitDifferenceSort(arrayToSort) {
        return arrayToSort.map((number, index) => {
            const sortedDigits = number.toString().split('').map(char => +char).sort((a,b) => b - a);
            const possibleLargestAndSmallestDigitsDiff = sortedDigits[0] - sortedDigits[sortedDigits.length - 1];
            return {diff: possibleLargestAndSmallestDigitsDiff, index, number}
        }).sort((a, b) => {
            return a.diff - b.diff ? a.diff - b.diff : b.index - a.index 
        }).map(result => result.number);
    }
Tiago Correia
@tiagocorreiaalmeida
Mar 09 2018 22:33
@AdelMahjoub allready got it working ehehe, close to what I had yours awell, I like codefights somehow has interesting challenges, but sometimes feels like codewars you can't figure out what they are asking :D
still thanks @AdelMahjoub for your time
CamperBot
@camperbot
Mar 09 2018 22:34
tiagocorreiaalmeida sends brownie points to @adelmahjoub :sparkles: :thumbsup: :sparkles:
:cookie: 667 | @adelmahjoub |http://www.freecodecamp.org/adelmahjoub
Adel
@AdelMahjoub
Mar 09 2018 22:35
@tiagocorreiaalmeida no problem, maybe I'll try to do that arcade mode
Tiago Correia
@tiagocorreiaalmeida
Mar 09 2018 22:50
can be fun @AdelMahjoub and some of the bots challenge aswell
Ryan Williams
@Ryanwfile
Mar 09 2018 23:10
I'm trying to alternate 2 functions indefinitely that simply display text to the same html paragraph, what would be a good way to do this, here is the codepen so far https://codepen.io/Ryanwfile/pen/QQgjyM
Jason Luboff
@JLuboff
Mar 09 2018 23:21
@Ryanwfile Looks like you're going down the right path using setTimeout. You'd want to then call the next function after completetion. Maybe have another if statement checking if i == length
in which you'd then call the next function, back and forth
Ryan Williams
@Ryanwfile
Mar 09 2018 23:22
@JLuboff Thank you so much for the help, I will try that
CamperBot
@camperbot
Mar 09 2018 23:22
ryanwfile sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2362 | @jluboff |http://www.freecodecamp.org/jluboff