Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:33
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • May 10 09:13
    @bjorno43 banned @zhaokunhaoa
  • Apr 25 17:12
    @mstellaluna banned @cmal
  • Apr 01 18:11
    thecodingaviator labeled #31179
  • Apr 01 18:11
    thecodingaviator labeled #31179
  • Apr 01 18:09
    thecodingaviator commented #31179
  • Apr 01 18:09
    thecodingaviator labeled #31182
  • Apr 01 18:09
    thecodingaviator labeled #31182
  • Apr 01 18:07
    thecodingaviator commented #31182
  • Apr 01 18:07
    thecodingaviator labeled #31190
  • Apr 01 18:07
    thecodingaviator labeled #31190
  • Apr 01 18:07
    thecodingaviator commented #31190
  • Apr 01 18:05
    thecodingaviator commented #31157
  • Apr 01 18:04

    thecodingaviator on master

    remove A (#31157) (compare)

  • Apr 01 18:04
    thecodingaviator closed #31157
  • Apr 01 18:04
    thecodingaviator closed #33788
  • Apr 01 18:04
    thecodingaviator commented #33788
  • Apr 01 18:02
    thecodingaviator closed #31059
  • Apr 01 18:02
    thecodingaviator commented #31059
Thomas
@sjurs1
@SweetCodingInc Actually it did work, but I'd refreshed the page so it just removed everything instead. LOL
amatayamada
@amatayamada
the trolls in this chat man...
:shipit:
next they'll suggest alt+f4 ;-)
Keon Samuel
@keonsam
ctrl + shift +c
Frostbites
@Frostbites
hey dudes
I need some help

function largestOfFour(arr) {

  var final = [];


  for (var i = 0; i < arr[i]; i++) {
    for (var j = 0; j < arr[i][j]; j++) {
      if (arr.indexOf(j) < arr.indexOf(j + 1)) {
        final.unshift(j);

      } 
    }
  } 
  return final.sort();
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
This is my coee
code
and I need to create an array that has the largest numbers from all the sub arrays
Keon Samuel
@keonsam
@Frostbites j is just the for loop count.
plus you should use .push
final.push();
Frostbites
@Frostbites
@keonsam can you please help me understand this phenomenon?
the j part?
Long Nguyen
@longnt80
@Frostbites what's your logic?
what are you trying to do?
Keon Samuel
@keonsam
use the two for loop count to get the number in the array
Frostbites
@Frostbites
make a new array with the largest values in all sub arrays
Keon Samuel
@keonsam
for example: arr[i][j];
Long Nguyen
@longnt80
I know the requirement, I want to know what you're trying to do,
Frostbites
@Frostbites
my logic is that the value that is counting the loop would be (supposedly) the value of the index from which the loop is iterating
that (j + 1) part is messy
Keon Samuel
@keonsam
yh indexOf(j) with alway be < indexOf(j +1);
or unknown or -1.
Long Nguyen
@longnt80
if (arr.indexOf(j) < arr.indexOf(j + 1)) {
        final.unshift(j);

      }
in this part, you insert the smaller value, not the bigger
Frostbites
@Frostbites
@longnt80 thanks bro.
CamperBot
@camperbot
frostbites sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 415 | @longnt80 |http://www.freecodecamp.com/longnt80
Frostbites
@Frostbites
so I just reverse the comparison operator?
Long Nguyen
@longnt80
@Frostbites what @keonsam said
:point_up: June 28, 2017 6:11 PM
@Frostbites and reverse
kaishuideweidao
@kaishuideweidao
I couldn't understand it
Long Nguyen
@longnt80
@Frostbites do you know the method sort()?
Frostbites
@Frostbites
yes
@longnt80 yes I do
I think I am making a terrible mistake
Long Nguyen
@longnt80
no, you can do it your way
still work
Frostbites
@Frostbites

function largestOfFour(arr) {

  var final = [];


  for (var i = 0; i < arr[i]; i++) {
    for (var j = 0; j < arr([i][j]); j++) {
      if (arr.charAr[i][j] > arr.charAt[i][j + 1]) {
       final = final.push(arr.charAt(j));        
      } 
    }
  } 
  return final.sort();
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
this is the new code
nope
Frostbites
@Frostbites
I tried indexOf() too
Keon Samuel
@keonsam
indexOf() don't work that way.
arr[i][j] will work
Frostbites
@Frostbites
can you guys give me a hint
?
Keon Samuel
@keonsam

function largestOfFour(arr) {

  var final = [];

  for (var i = 0; i < arr[i]; i++) {
    for (var j = 0; j < arr([i][j]); j++) {
      if (arr[i][j] arr[i][j + 1]) {
       final.push(arr[i][j]);        
      } 
    }
  } 
  return final;
}