Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
CamperBot
@camperbot
aguyinmontreal sends brownie points to @relentless-coder :sparkles: :thumbsup: :sparkles:
:cookie: 385 | @relentless-coder |http://www.freecodecamp.org/relentless-coder
Amit Patel
@AmitP88

@eweiss17


function largestOfFour(arr) {
  // You can do this!



  // loop through all the sub-arrays
  for(var i = 0; i < arr.length; i++) {

       var maxElement = Math.max.apply(null, arr[i]);  
       var newArray = [];
       newArray.push(maxElement);

      return newArray;     
  }




}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

Here's what I did after ditching the j loop like you suggested

Nick
@rhozeta
@relentless-coder how would I go about animating that static element?
ehutchllew
@ehutchllew
@zifahm not familiar with panel group but have you tried adding any styling?
Ayush Bahuguna
@relentless-coder
@rhozeta translate
Eric Weiss
@eweiss17
did it work?
Muhammed Hafiz
@zifahm
@KoniKodes nope no change
Amit Patel
@AmitP88
@eweiss17 the output now is [5]
Ayush Bahuguna
@relentless-coder
@rhozeta i mean the translate3d
Muhammed Hafiz
@zifahm
@ehutchllew when i try without the map func it works fine
Eric Weiss
@eweiss17
return newArray outside of the for loop
Nick
@rhozeta
@relentless-coder so I would have to use #truck.css({translate3d: x,x,x });
Amit Patel
@AmitP88
@eweiss17 now I get [1001]
Ayush Bahuguna
@relentless-coder
ehutchllew
@ehutchllew
@zifahm try defining your state inside the constructor:
constructor(){
super();
this.state = {}
}
Amit Patel
@AmitP88
@eweiss17 it also says that return newArray is out of scope
Muhammed Hafiz
@zifahm
@ehutchllew i tried that too
Ayush Bahuguna
@relentless-coder
@rhozeta I am sorry if this going to sound rude, but kindly look up translate3d property on Google, and take it from there :)
ehutchllew
@ehutchllew
@zifahm remove the logic from the render method, create your own class methods and then render based off of their output.
Amit Patel
@AmitP88
@eweiss17 just solved it by moving var newArray=[] outside of scope
Ayush Bahuguna
@relentless-coder
@AmitP88 why are you so obsessed with the correct solution? Instead think of your approach
Eric Weiss
@eweiss17
great
Kaz Baig
@kbaig
@relentless-coder no clue what the technical answer would be to that but it def is a pretty computationally minimally expensive solution, assuming the operators and methods work efficiently
Amit Patel
@AmitP88
@relentless-coder lol because I've been stuck on this for hours and hours. but yeah, you're right. I need to focus on the steps and strategy, not the solution itself
Muhammed Hafiz
@zifahm
@ehutchllew like functions to handle output?
could you give an example
Amit Patel
@AmitP88
after getting it to work thanks to @eweiss17 and @relentless-coder , I now see that I was waaaaaaay overthinking this.
CamperBot
@camperbot
amitp88 sends brownie points to @eweiss17 and @relentless-coder :sparkles: :thumbsup: :sparkles:
api offline
:cookie: 603 | @eweiss17 |http://www.freecodecamp.org/eweiss17
Ayush Bahuguna
@relentless-coder
@kbaig what's the basis of your response?
@kbaig leave it, I am going crazy due to AWS Developer Support's service.
Amit Patel
@AmitP88
I need to take the absolute simplest approach to problems now. thanks guys :) I'll restudy this solution for a while, make sure I get the lesson lol
ehutchllew
@ehutchllew
@zifahm yeah, like
_getRecipes(){
   this.state.map( () => {
   // logic goes here, then return
    }
}

render(){
  return(
      {this._getRecipes()}
);
}
Muhammed Hafiz
@zifahm
@ehutchllew okay let me try :smile:
Kaz Baig
@kbaig
@relentless-coder well the fastest way to do it logically would be to replace each item in the array with the highest item in the array, which is what I'm doing
ehutchllew
@ehutchllew
@zifahm Or instead of directly calling the function in the render return, try setting the function output to constructor variables or state variables and then populating your HTML based off of said variables.
Kaz Baig
@kbaig
It would be faster if you used for loops probably since apparently they're faster than Array methods
ehutchllew
@ehutchllew
@kbaig If I'm not mistaken, map and forEach are faster than for
I could be wrong though, I'm not an expert haha
Toni Shortsleeve
@KoniKodes
@zifahm I'm sorry. I do think @ehutchllew is correct.
Muhammed Hafiz
@zifahm
what to do
ehutchllew
@ehutchllew
@zifahm okay so my suggestion is, if it's still not working, take a step back and just get something extremely basic to render like: <div><p> HI </p> </div> add some styling to it to make sure it's not empty, and then work up from there.
Muhammed Hafiz
@zifahm
okay
@ehutchllew see now it renders without the map
ehutchllew
@ehutchllew
@zifahm Okay I'm testing some stuff gimme one sec
Muhammed Hafiz
@zifahm
@ehutchllew thank you
CamperBot
@camperbot
zifahm sends brownie points to @ehutchllew :sparkles: :thumbsup: :sparkles: