These are chat archives for FreeCodeCamp/HelpJavaScript

12th
Aug 2017
Tai Jones
@taiJones00
Aug 12 2017 00:00
           // Change between F and C when the temp div is clicked
    $("#temp").on(click, function() {
     if ("#temp" == temp + "&deg F")
       {
         temp *= 1.8 + 32;
         $("#temp").html(temp + "&deg C");
         console.log("hey");
       }
      else
        {
          temp -= 32 * (5/9);
          $("#temp").html(temp + "&deg F");
          console.log("howdy");
        }
    });
also does this look right
ha never mind
crazy bug
Keon Samuel
@keonsam
Aug 12 2017 00:11
if ("#temp"
Tai Jones
@taiJones00
Aug 12 2017 00:12
should I use document.getElementByID instead
Keon Samuel
@keonsam
Aug 12 2017 00:12
that is a string,
Tai Jones
@taiJones00
Aug 12 2017 00:12
what is
Keon Samuel
@keonsam
Aug 12 2017 00:13
"#temp"
a7n007
@a7n007
Aug 12 2017 00:17
@taiJones00 yes you can
dyon3334
@dyon3334
Aug 12 2017 00:18
how to itterate multidimensional arrays javascript ?any help ?
how to loop over multidimensional arrays javascript ?any help ?
kumquatfelafel
@kumquatfelafel
Aug 12 2017 00:39
There's an example in the instructions
dyon3334
@dyon3334
Aug 12 2017 00:43
@kumquatfelafel thanks !!!
CamperBot
@camperbot
Aug 12 2017 00:43
dyon3334 sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 598 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Tai Jones
@taiJones00
Aug 12 2017 00:43
$("#temp").on("click", function() {
     if (document.getElementByID("temp") == temp + "&deg C")
       {
         $("#temp").html(tempF + "&deg F");
         console.log("hey");
       }
      else
        {
          $("#temp").html(temp + "&deg C");
          console.log("howdy");
        }
    });
so why isn't this working
dyon3334
@dyon3334
Aug 12 2017 00:44
@kumquatfelafel i did that task buts its to short im gonna do more research about it
kumquatfelafel
@kumquatfelafel
Aug 12 2017 00:44
@taiJones00 should be getElementById for one.
dyon3334
@dyon3334
Aug 12 2017 00:44
im gonna dedicate my night to learn multi dimensional arrays
kumquatfelafel
@kumquatfelafel
Aug 12 2017 00:44
@taiJones00 also, you say == temp... what is temp?
Tai Jones
@taiJones00
Aug 12 2017 00:45
$.getJSON(`https://fcc-weather-api.glitch.me/api/current?lat=${lat}&lon=${lon}`, function(json) {
   //List of all possible keys and values //$("#data").html(JSON.stringify(json));
    var temp = json.main.temp;
    var name = json.name;
    var country = json.sys.country;
    var icon = json.weather[0].icon;
    var tempF = (temp - 32) * (5/9);

    //The icon of location
    $('#icon').html(`<img src='${icon}'>`);

    //The temperature for location
    $("#temp").html(temp + "&deg C");

    //The country of location
    $("#location").html(name + ", " + country);

    // Change between F and C when the temp div is clicked
    $("#temp").on("click", function() {
     if (document.getElementById("temp") == temp + "&deg C")
       {
         $("#temp").html(tempF + "&deg F");
         console.log("hey");
       }
      else
        {
          $("#temp").html(temp + "&deg C");
          console.log("howdy");
        }
    });
dyon3334
@dyon3334
Aug 12 2017 00:46
do someone know or have good resources for functions and multidimensional arrays
i mean iiterate with a function over multidimensional arrays
kumquatfelafel
@kumquatfelafel
Aug 12 2017 00:47
@dyon3334 probably good to get a strong grasp of multidimensional arrays/for loop. That can make understanding a lot of higher order functions much easier
:)
dyon3334
@dyon3334
Aug 12 2017 00:48
@kumquatfelafel thanks for the motivation speak
CamperBot
@camperbot
Aug 12 2017 00:48
dyon3334 sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:warning: dyon3334 already gave kumquatfelafel points
kumquatfelafel
@kumquatfelafel
Aug 12 2017 00:53
@taiJones00 console.log(typeof temp). console.log(typeOf document.getElementById("temp")
Also, console.log(temp) and console.log(document.getElementById("temp"))
Tai Jones
@taiJones00
Aug 12 2017 00:54
I'm lost
kumquatfelafel
@kumquatfelafel
Aug 12 2017 01:01

@taiJones00 the most important one is really this... console.log(typeof document.getElementByID("temp"));

What does that give you in the console?

It gives you object, right?
Tai Jones
@taiJones00
Aug 12 2017 01:04
it gives me some error
deffered exception
kumquatfelafel
@kumquatfelafel
Aug 12 2017 01:05
Can you post code pen?
Tai Jones
@taiJones00
Aug 12 2017 01:05
"jQuery.Deferred exception: document.getElementByID is not a function" "TypeError: document.getElementByID is not a function
    at HTMLDocument.<anonymous> (pen.js:76:31)
    at j (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:29999)
    at k (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:30313)" undefined
kumquatfelafel
@kumquatfelafel
Aug 12 2017 01:05
Sorry, id
*Id
the test is on line 30
kumquatfelafel
@kumquatfelafel
Aug 12 2017 01:07
@taiJones00 as stated, misspelled. Should be getElementById. Sorry, it's unfortunately easy to spell fully capped as force of habit. :laughing:

@taiJones00 but yeah, that should give you object.

And what do we know about comparisons when objects are involved? (if you don't know, then I'll tell you :p )

Tai Jones
@taiJones00
Aug 12 2017 01:08
it's okay. So I changed it to Id and no object was logged to the console
kumquatfelafel
@kumquatfelafel
Aug 12 2017 01:09
@taiJones00 did you click run? It's showing up for me just fine.
right under hello
Tai Jones
@taiJones00
Aug 12 2017 01:10
it may be my browser
one second
kumquatfelafel
@kumquatfelafel
Aug 12 2017 01:11

In any case... objects.

Say I have {"Hi":"Bye"} == {"Hi":"Bye"}

Should this return true?

Tai Jones
@taiJones00
Aug 12 2017 01:12
Yes it should
kumquatfelafel
@kumquatfelafel
Aug 12 2017 01:12
It doesn't.
Tai Jones
@taiJones00
Aug 12 2017 01:12
both the key and value in both are the same
kumquatfelafel
@kumquatfelafel
Aug 12 2017 01:12
The reason is that these are two different objects found in different memory locations
believe it or not :laughing:
Tai Jones
@taiJones00
Aug 12 2017 01:13
oh okay
kumquatfelafel
@kumquatfelafel
Aug 12 2017 01:14
Basically, with object comparison, key-value comparison doesn't occur... It's more like it only returns true when you're comparing an object with itself.
Tai Jones
@taiJones00
Aug 12 2017 01:14
if (document.getElementById("temp") == temp + "&deg C") so this isn't valid?
kumquatfelafel
@kumquatfelafel
Aug 12 2017 01:15
yeah. not valid.
Tai Jones
@taiJones00
Aug 12 2017 01:16
becuase i'm reffering to the memory location. So how do I refer to what's actually in the ID from the html
kumquatfelafel
@kumquatfelafel
Aug 12 2017 01:16
regardless though, it might be easier to just set up a variable that knows whether ºF or ºC without having to worry about extracting some piece of the given element. And have said variable change from one to other whenever element clicked.
e.g.
if ( blah == 5)
is a lot cleaner, and easier to handle than
if ( something.getSomething.doSomething() + somethingElse == someOtherThing + 5)
zongsheng Lu
@melzs
Aug 12 2017 02:16

function slasher(arr, howMany) {
arr.splice(0,howMany);

return arr;
}

slasher([1, 2, 3], 2);

I want to ask why arr = arr.splice(0, howMany); different from arr.splice(0,howMant)
their value of return is different
Moisés Man
@moigithub
Aug 12 2017 02:25
splice mutates/changes the original array
it also return the element sliced
kumquatfelafel
@kumquatfelafel
Aug 12 2017 02:25
@melzs arr = arr.splice(0,howMany); does modify the original array. However due to assigning it to same variable, you then overwrite arr with the returned array of deleted elements. :point_down:
Moisés Man
@moigithub
Aug 12 2017 02:25
a=[1,2,3,4,5]
b=a.splice(2,1)
b will be [3]
a will be [1, 2, 4, 5]
aRtoo
@artoodeeto
Aug 12 2017 02:29
hello masters!! need help. i have a problem on algorithm entitled pig latin.
how can i stop the loop when it hit another consonant?? i tried return and i cant make it work.heres my code:
function translatePigLatin(str) {
  var vowelsArr = 'aeiou'; //way
  //var constArr = 'BCDFGHJKLMNPQRSTVWXYZ'.toLowerCase(); //ay
  var uno = [];
  var dos = [];
  str = str.split('');

  if (vowelsArr.indexOf(str[0]) === -1) {
    for (var i = 0; i < str.length; i++) {
      if (vowelsArr.indexOf(str[i]) === -1) {
        dos.push(str[i]);
      } else if (vowelsArr.indexOf(str[i]) > -1) {
        uno.push(str[i]);
        uno = uno.join('');
        dos = dos.join('');
        return uno + dos;
      }
    }
  } else {
    return str.join('') + 'way';
  }
}

//translatePigLatin("consonant");
//translatePigLatin("california"); //should return "aliforniacay".
//translatePigLatin("paragraphs"); //should return "aragraphspay".
translatePigLatin('glove'); //should return "oveglay".
//translatePigLatin("algorithm"); //should return "algorithmway".
//translatePigLatin("eight"); //should return "eightway".
Joel Y.
@zapcannon99
Aug 12 2017 02:38

since you are using a for loop, you could exit out of the for loop by making the loop's iterating variable something that would make the checking condition false. @artoodeeto

So using what you got, you can make i = str.length;

This way, for loop will become false when it checks the next iteration.
kumquatfelafel
@kumquatfelafel
Aug 12 2017 02:39
@zapcannon99 or could just use break
Joel Y.
@zapcannon99
Aug 12 2017 02:40
true. Your way would be better Xp
Dunno why I forgot about that.
me le noob
kumquatfelafel
@kumquatfelafel
Aug 12 2017 02:40
Though still trying to read through what this code does to see if this actually makes sense.

At the very least, this line is definitely a problem.

uno.push(str[i]);

@artoodeeto also, you still need to add "ay" when string doesn't start with vowel.
Joel Y.
@zapcannon99
Aug 12 2017 02:42
How so?
kumquatfelafel
@kumquatfelafel
Aug 12 2017 02:44

@zapcannon99 str[i] is a character.

So suppose word is halfway. Pushes 'h' to dos, then winds up executing else if. pushes 'a' to uno... joins uno, joins dos, returns "ah"

Joel Y.
@zapcannon99
Aug 12 2017 02:45
@kumquatfelafel Got it.
zongsheng Lu
@melzs
Aug 12 2017 02:45
@kumquatfelafel @moigithub thanks , it also returns the element sliced.
CamperBot
@camperbot
Aug 12 2017 02:45
melzs sends brownie points to @kumquatfelafel and @moigithub :sparkles: :thumbsup: :sparkles:
:cookie: 599 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
:star2: 3578 | @moigithub |http://www.freecodecamp.com/moigithub
kumquatfelafel
@kumquatfelafel
Aug 12 2017 02:45
I suppose you could say "the block as a whole is problematic". Technically you could still make it work with the push, but you'd need another for loop... or... well... some kind of loop to push the rest of the string into uno.
Joel Y.
@zapcannon99
Aug 12 2017 02:47
I see. I need to improve my code reading skills. :/
kumquatfelafel
@kumquatfelafel
Aug 12 2017 02:51
@zapcannon99 I've done tutoring on and off in the past, so at this point I feel like I pretty much read any kind of code and non-code imaginable. :laughing:
Answering questions on sites like this definitely helps you with debugging/code comprehension though.
Joel Y.
@zapcannon99
Aug 12 2017 02:52
Ah nice. Regardless, it is something I would like to improve because it seems to be my weak point.
Indeed.
Kaeleb Rocha
@Kralleb
Aug 12 2017 02:53
function steamrollArray(arr) {
  // I'm a steamroller, baby\
  function loops(arg) {
    for(var element in arg) {
       if(arg.length > 1) {
          arr.push(arg[1]);
       }
       return arg[element];
    }
  }
    for(var i = 0; i < arr.length; i++) {
      if(Array.isArray(arr[i])) {
         if(arr[i].length === 0) {
           arr.splice(i,i);
         }
      }
      while(Array.isArray(arr[i])) {
         arr[i] = loops(arr[i]);
      } 
   }
  return arr;
}

steamrollArray([1, [], [3, [[4]]]]);
Is this a good approach @kumquatfelafel ?
@kumquatfelafel Rather, do you see anything problematic with it?
Joel Y.
@zapcannon99
Aug 12 2017 02:57
@Kralleb I know you didn't ask me, but I wanted to take shot if that's okay with you.
Kaeleb Rocha
@Kralleb
Aug 12 2017 02:57
Sure!
Joel Y.
@zapcannon99
Aug 12 2017 02:58

Thanks.

First thing I notice is that I don't think you are doing anything for non array elements

They are getting thrown out.
Kaeleb Rocha
@Kralleb
Aug 12 2017 02:59
@zapcannon99 Well it actually passes
kumquatfelafel
@kumquatfelafel
Aug 12 2017 02:59
I'm a bit unsure why you're telling it to remove i elements with splice.
Kaeleb Rocha
@Kralleb
Aug 12 2017 02:59
@zapcannon99 I kept the original array and modified it so i wouldn't have to worry about it
Joel Y.
@zapcannon99
Aug 12 2017 02:59
Everything passes?
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:00
Yes
Joel Y.
@zapcannon99
Aug 12 2017 03:00
interesting
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:00
@zapcannon99 Oh yes... i should of spliced 1 not i
Joel Y.
@zapcannon99
Aug 12 2017 03:00
Ah I see.
Also, tagged the wrong person Xp
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:01
Haha
@kumquatfelafel I should of spliced i and 1 not i and i.
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:01

@Kralleb consider the following scenario... even with 1.

https://repl.it/KHAl

Kaeleb Rocha
@Kralleb
Aug 12 2017 03:02
@kumquatfelafel What do you recommend?
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:03
Problem is, splice modifies original array... changing element your index, i, refers to.
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:03
Ohh well i could add i--
@kumquatfelafel So i set it back one point in the array to make up for it.
Joel Y.
@zapcannon99
Aug 12 2017 03:05
What if the first element is [] though?
Nvm, for loop will take care of it
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:07
hmm i did notice if it equals [[[]]] then it returns null...
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:10

basically.

That would be the quick fix here.

@zapcannon99 fortunately, although you're then talking about a nonexistent index, arr[-1] is undefined (and doesn't try to access something like arr[-1].length, e.g., which would break it).

Though yeah, the logic here holds in javascript, though doesn't necessarily hold in other languages. :p

e.g. in java, arr[-1] would throw ArrayIndexOutOfBoundsException.

Joel Y.
@zapcannon99
Aug 12 2017 03:11
True. Though, i-- would be taken care of by the for loop if i-- is placed after any access to the array right?
Oh wait, that while loop uses i. Hmmm
This is getting complicated for my tyro coding brain.
js coding brain that is.
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:15
@zapcannon99 the way the code is set up could be a little clearer. :p
(no offense)
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:15
@kumquatfelafel I just finished it lol... I haven't even added notes.
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:15
@Kralleb Anywho, another scenario to consider https://repl.it/KHAl/1
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:16
@kumquatfelafel Yes, i caught that. i was thinking of checking if it equals null and if so splice it out
Joel Y.
@zapcannon99
Aug 12 2017 03:16
This makes me wonder, what the hell did I do? Let me check....
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:17
[] != null.
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:17
Right, But i could check it in the while loop
Joel Y.
@zapcannon99
Aug 12 2017 03:17
Hmm. It seems I did recursive calls. O__o
Yeah, but checking [[]] would not give you null
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:18
It returns null due to the while loop always reducing it
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:18
@zapcannon99 Issue here is... it's not truly recursive so the handling is inconsistent.
Joel Y.
@zapcannon99
Aug 12 2017 03:18
No I meant my answer was recursive.

function steamrollArray(arr) {
  // I'm a steamroller, baby
  var result = [];

  arr.forEach(function(element) {
    if(Array.isArray(element)) {
      var temp = steamrollArray(element);
      temp.forEach(function(e) {
        result.push(e);
      });
    } else {
      result.push(element);
    }
  });

  return result;
}

steamrollArray([1, [2], [3, [[4]]]]);
@Kralleb Gotcha.
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:19
@Kralleb It doesn't return null though. when arr = [], arr[0] = undefined, not null.
Joel Y.
@zapcannon99
Aug 12 2017 03:20
So it's instead check for undefined?
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:21
.length
[null,{},3,4,5,7]
Christopher McCormack
@cmccormack
Aug 12 2017 03:21
maybe check for nothing.
> [1,2,3].concat([])
[ 1, 2, 3 ]
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:26
@kumquatfelafel Doesn't recursion cost a ton of memory?
Christopher McCormack
@cmccormack
Aug 12 2017 03:26
yes, but for projects like this it's not too bad
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:27
@cmccormack So what exactly does arr.concat([]) do?
Christopher McCormack
@cmccormack
Aug 12 2017 03:28
basically combines two arrays, and if an array is empty nothing gets added
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:28
@Kralleb result on line below. :point_up:
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:28
@kumquatfelafel Right, But why would i want to check for nothing?
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:30
Either you have some kind of check (explicit or ... implied?) for an empty array, or you wind up pushing a value that shouldn't exist to your array.
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:33
function steamrollArray(arr) {
  // I'm a steamroller, baby
  //Loop
  function loops(arg) {
    for(var element in arg) {
       if(arg.length > 1) {
          arr.push(arg[1]);
       }
       return arg[element];
    }
  }
    for(var i = 0; i < arr.length; i++) {
      while(Array.isArray(arr[i])) {
         arr[i] = loops(arr[i]);
         if(arr[i] === undefined) {
            arr.splice(i,1);
         }

      } 
   }
  return arr;
}

steamrollArray([[[]], [], [], {}, [3, [[4],[5,7]]]]);
Well this is the finished product
@kumquatfelafel @zapcannon99 @cmccormack Thanks for the feed back.
CamperBot
@camperbot
Aug 12 2017 03:33
kralleb sends brownie points to @kumquatfelafel and @zapcannon99 and @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 332 | @zapcannon99 |http://www.freecodecamp.com/zapcannon99
:star2: 1125 | @cmccormack |http://www.freecodecamp.com/cmccormack
:cookie: 600 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Christopher McCormack
@cmccormack
Aug 12 2017 03:34
Can we share ours now? :D
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:34
Hahaha
Sure if you want to.
Christopher McCormack
@cmccormack
Aug 12 2017 03:35
This could be simplified using reduce I bet but I haven't gone back to it:
function steamrollArray(arr) {
  var result = [];

  for (var i = 0; i < arr.length; i++){
    Array.isArray(arr[i]) ? result = result.concat(steamrollArray(arr[i])) : result.push(arr[i]);
  }
  return result;
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:36
@cmccormack haha nice a short
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:36
My solution to this challenge is as follows.
this.tests = ['true'];
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:37
I didn't want to use recursion, I felt like maybe bad practice if i ever get a job.
Christopher McCormack
@cmccormack
Aug 12 2017 03:37
@Kralleb recursion is fine most of the time. Unless you're doing something with incredibly large datasets, it's easier to implement. It only has a high memory usage until you start popping items off the stack
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:39
@cmccormack Or use it in a very long loop
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:39
You can also employ strategies like splitting up the data into pieces before throwing it into recursive algorithm so less likelihood of program frying.
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:40
@kumquatfelafel Did you get work in the field?
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:40
Nah.
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:41
Don't want to?
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:41
Not sure yet.
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:41
What's stopping ya?
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:43
Though yeah... some mathematical algorithms basically abuse recursion, because even though it's slower and more memory intensive, it's also a lot more clear and easy to code... and they have supercomputers so what do they care. :p
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:44
Haha. I was more worried about big projects. I can only imagine you have a massive project and you used recursion to solve your problem and it screws it all up
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:45
pretty much the only way for recursion to screw it up is if you use up the stack. Though this is not to say it's the best choice for what you're doing.
Christopher McCormack
@cmccormack
Aug 12 2017 03:45
Recursion is not going to be used often. Maybe when doing works with graphs or something like that where it only makes sense
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:46
:point_up: depends on application
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:46
@cmccormack Do you work in the field?
Christopher McCormack
@cmccormack
Aug 12 2017 03:47
I work in A field
not like a wheat field or something though
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:47
I sleep in a field. :o
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:47
haha
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:47
And avoid the farmers!
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:48
@cmccormack Do you have a job coding?
Christopher McCormack
@cmccormack
Aug 12 2017 03:48
I'm a network engineer, some coding of my own but not my focus
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:49
oh alright. why not apply for front-end?
Christopher McCormack
@cmccormack
Aug 12 2017 03:50
I love my job! I code for fun right now, I want to know about all the technologies out there and how to use them, maybe do some side business a little later
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:51
@cmccormack fair enough. I'm just trying to get an idea of when to apply.
Christopher McCormack
@cmccormack
Aug 12 2017 03:51
Get your confidence to mid-level then start applying, then keep studying
Marc
@MWBauer
Aug 12 2017 03:52
I'm currently skipping ahead in the lessons to the Cipher. I enjoy ciphers.
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:53
@cmccormack So if i get the front-end certificate should i start applying for a job?
Marc
@MWBauer
Aug 12 2017 03:53
I'm currently skipping ahead in the algorithms and working on Ceasar's cipher. I enjoy ciphers.
I'm having a hard time tho.
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:54
Okay, what's up @MWBauer
Christopher McCormack
@cmccormack
Aug 12 2017 03:54
@Kralleb it's up to you - I usually recommend getting comfortable with something first, but not trying to be the best at something before attempting to apply
if you wait until you're an expert you could miss out on opportunities
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:54

@MWBauer Depending on how far you skipped ahead, this could be perfectly understandable.

For that matter, even if you didn't skip ahead, this would be understandable. :p

Marc
@MWBauer
Aug 12 2017 03:55
I have a plan. A plan for the ages. I know what I want to do, but I'm unsure of how to do it.
Kaeleb Rocha
@Kralleb
Aug 12 2017 03:55
lol
Christopher McCormack
@cmccormack
Aug 12 2017 03:56
@MWBauer keep learning until you do?
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:56
There's a part of me that feels like I want to teach... But that would mean years of college.
Christopher McCormack
@cmccormack
Aug 12 2017 03:56
@kumquatfelafel only a couple probably
Marc
@MWBauer
Aug 12 2017 03:56
I know it says to use the string.prototype.charCodeAt and string.prototype.charFrom. I'm trying to figure out how to step thru a For loop, take each iteration and use the codeAt
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:57
What do you have so far.
Christopher McCormack
@cmccormack
Aug 12 2017 03:57
@MWBauer just do what you just said!
Marc
@MWBauer
Aug 12 2017 03:58
Ya'll so funny.
kumquatfelafel
@kumquatfelafel
Aug 12 2017 03:59
oh... didn't realize what time it was haha
"Why am I so tired" :o
Marc
@MWBauer
Aug 12 2017 03:59
for (I=0; I <=str.length; I++); This gives me the For loop so that it'll step thru the length of whatever the string is.
the action that I need within the For loop needs a variable that each iteration will assign to
So.... {var uniCode;
Christopher McCormack
@cmccormack
Aug 12 2017 04:01
don't forget to declare your iterator
kumquatfelafel
@kumquatfelafel
Aug 12 2017 04:01
two things. First off, I would make it var l = 0;
Marc
@MWBauer
Aug 12 2017 04:01
Isn't that what the first part of the for loop does?
kumquatfelafel
@kumquatfelafel
Aug 12 2017 04:02
as general rule of thumb, I would make variables global only on purpose, not by accident or out of indifference.
Marc
@MWBauer
Aug 12 2017 04:06
Ok. So...
var I = 0
for loop
kumquatfelafel
@kumquatfelafel
Aug 12 2017 04:06
third thing, looking closer, that doesn't appear to be an l, but an uppercase i. By convention, variable names in camel case, so if that is indeed an uppercase i, then you should be using iinstead.
The second thing... is something I'll let you encounter in the course of writing/running your code. :p
Marc
@MWBauer
Aug 12 2017 04:08
I don't assign uppercase variables unless its camelcase
Christopher McCormack
@cmccormack
Aug 12 2017 04:08
@kumquatfelafel that was only like a semi answer
kumquatfelafel
@kumquatfelafel
Aug 12 2017 04:08
@cmccormack ya, but you're here, and I'm going to sleep. :laughing:
Christopher McCormack
@cmccormack
Aug 12 2017 04:08
haha see ya
kumquatfelafel
@kumquatfelafel
Aug 12 2017 04:08
night
Marc
@MWBauer
Aug 12 2017 04:11
As far as I've gotten is...
function rot13(str) { // LBH QVQ VG!
var uniCode = "i";
for (i = 0; i <= str.length; i++) {
if (uniCode <= 74)
newCode = uniCode + 13;
else newCode = uniCode - 13;
}
return str;
and we all know it isn't working yet.
Christopher McCormack
@cmccormack
Aug 12 2017 04:12
@MWBauer :) just do for (var i = 0; ...
Marc
@MWBauer
Aug 12 2017 04:12
Ok. Thank you.
Angel J Piscola
@Redmega
Aug 12 2017 04:12
@MWBauer Is "i" <= 74?
Marc
@MWBauer
Aug 12 2017 04:12
I wasn't sure how you thought that was supposed to go.
Christopher McCormack
@cmccormack
Aug 12 2017 04:12
initialize your iterator in the for loop.
Marc
@MWBauer
Aug 12 2017 04:12
Let me walk you thru it, from my perspective.
Straighten my path when you see a way to.
I have my For loop.
I want the var i to be assigned to uniCode which will be passed thru the charCodeAt
Christopher McCormack
@cmccormack
Aug 12 2017 04:14
why do you want that at all?
Marc
@MWBauer
Aug 12 2017 04:14
then the Unicode needs to be evaluated to either move up 13 steps or down 13 steps.
Angel J Piscola
@Redmega
Aug 12 2017 04:15
var i; is what you're using to count your place in the for loop
Guderian Raborg
@hypercuber
Aug 12 2017 04:15
How would I rotate one square rather than the whole canvas?
https://codepen.io/hypercuber/pen/vJJgZd
Marc
@MWBauer
Aug 12 2017 04:15
Once I have the new position I can return to alpha from uni and then reassemble.
Angel J Piscola
@Redmega
Aug 12 2017 04:15
If you assign it to the charCode it'll bork up everything
Marc
@MWBauer
Aug 12 2017 04:15
ok.
Christopher McCormack
@cmccormack
Aug 12 2017 04:15
@hypercuber wehee! I'm dizzy now
Guderian Raborg
@hypercuber
Aug 12 2017 04:16
@cmccormack lol
Angel J Piscola
@Redmega
Aug 12 2017 04:17
@hypercuber When I increase the height of the pen it stops spinning and starts just blinking squares in and out of existence from the middle
Is that in the code or is that a bug?
Guderian Raborg
@hypercuber
Aug 12 2017 04:19
@Redmega The code is really bad. Just want to know simple rotation of one square without rotating the canvas so I can use the concept in other stuff
Christopher McCormack
@cmccormack
Aug 12 2017 04:21
why is all the code in your update attached to c?
Marc
@MWBauer
Aug 12 2017 04:23
I guess I've forgotten how to capture the iterations into a variable where I can do something with it.
Guderian Raborg
@hypercuber
Aug 12 2017 04:24
@cmccormack Some people use ctx. I use c.
Christopher McCormack
@cmccormack
Aug 12 2017 04:24
@MWBauer i is your iterator, and to access a position in str you can use str[i]
@hypercuber but you're trying to rotate elements, not c
I gotta run good luck all
Guderian Raborg
@hypercuber
Aug 12 2017 04:27
@cmccormack ok thanks
CamperBot
@camperbot
Aug 12 2017 04:27
:star2: 1126 | @cmccormack |http://www.freecodecamp.com/cmccormack
hypercuber sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
Marc
@MWBauer
Aug 12 2017 04:30
Chris says to use str[i]. so it would be str[i].charCodeAt() right?
Jim Tryon
@jimtryon
Aug 12 2017 04:31
That looks right to me @MWBauer
Marc
@MWBauer
Aug 12 2017 04:33
Ok. So do I place that as the action of my FOr loop?
Jim Tryon
@jimtryon
Aug 12 2017 04:35
I would need to see the code that you’re talking about.
Marc
@MWBauer
Aug 12 2017 04:35
function rot13(str) { // LBH QVQ VG!
var uniCode;
for (var i = 0; i <= str.length; i++) {
str[i].charCodeAt();
}
Yuserah Din
@YuserahN
Aug 12 2017 04:36
```
function fearNotLetter(str) { 

  var num;  


  for(var i = 0; i < str.length; i++) {  
    num = str.charCodeAt(i); 

    if(num - (str.charCodeAt(i + 1)) !== -1) {
      return String.fromCharCode(num + 1); 
    }   
  }

  return undefined; 
}

fearNotLetter("abcdefghjklmno");
```
Why is my code not working?
I'm supposed to find the missing letter from the given str. If there is no missing letter, I'm supposed to return undefined. The first part is working, the latter is not.
Meaning that it's able to find and return the missing letter, but in the case where there is no missing letter, it's not returning undefined.
Jim Tryon
@jimtryon
Aug 12 2017 04:38
@MWBauer Yeah, it would go inside of the body of the for loop.
Kaeleb Rocha
@Kralleb
Aug 12 2017 04:39
@YuserahN WHat is the challenge?
Yuserah Din
@YuserahN
Aug 12 2017 04:41
They gave a string, such as "abce." In this string, the letter "d" is missing. So I'm supposed to find the missing letter and return it. If there is no missing letter in the string, I'm supposed to return undefined.
So far, my code is able to find and return the missing letter. But it's not returning undefined when there is no missing letter.
Kaeleb Rocha
@Kralleb
Aug 12 2017 04:42
@YuserahN You need to make sure that it doesn't check the end of the loop
@YuserahN i would put something to make sure it isn't the last element in the array so it doesn't do that and you should be good
Marc
@MWBauer
Aug 12 2017 04:43
Unable to get property "charCodeAt" of undefined or null reference
Gulsvi
@gulsvi
Aug 12 2017 04:43
^^ yeah, fearNotLetter("bcd"); is going to return e instead of undefined with your current code
Yuserah Din
@YuserahN
Aug 12 2017 04:45
Oh I see. Thanks you guys.
Kaeleb Rocha
@Kralleb
Aug 12 2017 04:45
@YuserahN Np
Marc
@MWBauer
Aug 12 2017 04:58
What's a null reference?
prakash chandra yadav
@prakashyadav008
Aug 12 2017 05:37
hey can anyone help me out
how do i get the font to be a little bit brighter
Jim Tryon
@jimtryon
Aug 12 2017 05:38
@prakashyadav008 You could adjust the hex values or you can use lighten/darken functions
prakash chandra yadav
@prakashyadav008
Aug 12 2017 05:39
lighten/darken functions..? @jimtryon
Jim Tryon
@jimtryon
Aug 12 2017 05:41
@prakashyadav008 Look at CSS filter functions
prakash chandra yadav
@prakashyadav008
Aug 12 2017 05:44
@jimtryon got it
thanks
Jefferson
@jeffersonnnn
Aug 12 2017 06:36
hi guys, can i get help with the mutations challenge?

function mutation(arr) {
  var elem0 = arr[0].toLowerCase();
  var elem1 = arr[1].toLowerCase();
  for (var i = 0; elem1.length; i++) {
    var check = elem0.indexOf(elem1[i]);
    if (check === -1){
      return false;
    }
  }
  return true;
}
mutation(["hello", "hey"]);
Jefferson
@jeffersonnnn
Aug 12 2017 07:14
help, maybe?
lfvpCO
@lfvpCO
Aug 12 2017 07:40
FreeCodeCamp stratford-Upon-Avon
Alexander Køpke
@alexanderkopke
Aug 12 2017 07:40
I don't understand your conditional in the for loop. You have elem1.length; usually you'd have something like i < elem1.length; so that as the value of i goes up at one point the condition is no longer true and so the loop stops
@jeffersonnnn
Chris Juchtmans
@kjuchtmans
Aug 12 2017 08:48
morning all coders! :wave:
陈兴利
@lily0101
Aug 12 2017 08:50
'''
CamperBot
@camperbot
Aug 12 2017 08:50
:bulb: to format code use backticks! ``` more info
Chris Juchtmans
@kjuchtmans
Aug 12 2017 08:50

Who has done the FCC InfoSec certificate?

In my regular road map this chapter doesn't feature, but it still seems to be accessible as beta.

陈兴利
@lily0101
Aug 12 2017 08:53
hi,guys ! Could you tell me what's wrong with my code? thanks so much.
function palindrome(str) {
  // 
  str.replace(/\W|_/g,'').toLowerCase();
  str.toLowerCase();
  var maxLength = str.length-1;
  for(var  i = 0;i <= maxLength/2;i++)
    {
      if(str[i] !== str[maxLength-i])
        return false;
    }
  return true;
}
palindrome("eye");
Ken Haduch
@khaduch
Aug 12 2017 09:18
@lily0101 - the first thing that I can see is that you are calling str.toLowerCase()and that returns the lowercased string, but you are not saving that value. The same with the .replace() - you have to save the value in a new string variable. You could also avoid the for loop comparison by generating a reversed copy of the string and using an === comparison between the forward and reversed copy, after the removal of special characters and lowercasing it.
@kjuchtmans - good morning Chris - I haven't done (or even heard of) the InfoSec certificate?
陈兴利
@lily0101
Aug 12 2017 09:20
@khaduch I see. thanks so much.
CamperBot
@camperbot
Aug 12 2017 09:20
lily0101 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3195 | @khaduch |http://www.freecodecamp.com/khaduch
Chris Juchtmans
@kjuchtmans
Aug 12 2017 09:26

@khaduch me neither; always interested to learn though. did you check the beta page with assignments ?

I wonder whether completing these actually work, is this certificate still being awarded? Me, I still have to do back end, data vizualisation first

Ken Haduch
@khaduch
Aug 12 2017 09:35
@kjuchtmans - I am still working on the front end certification - I am being a slug on the projects, I guess... :) I should try and complete those and forge ahead! I'm confused about the Beta site - are some people working through those, or is it just out there at this point for reference / testing?
Chris Juchtmans
@kjuchtmans
Aug 12 2017 09:39

No idea, to be frank. Anyone with InfoSec skills could prob better judge whether these pages are up to date, or legacy, or coming up

@khaduch are you doing the front end certif to refresh? It would seem to me sir you had that one knocked out some time already.

Ken Haduch
@khaduch
Aug 12 2017 09:46
@kjuchtmans - it's somewhat of a refresh, but I'm not a front-end developer, so there is a lot of new learning for me. My problem with finishing it is that when I sit down and start looking at the chat rooms, I spend more time (or spent more time) answering questions / helping and not focusing on doing my own things. At least that was the way it was. Now that the flow of things in these chatrooms has changed so much, maybe it's time to try and push through the projects and move along?
Chris Juchtmans
@kjuchtmans
Aug 12 2017 10:00
@khaduch right. I picked up front end (and JS as such) 5 months ago. the JS chatroom has indeed helped a great deal; some seriously altruistic and patient folks about, so thanks ! :clap:
CamperBot
@camperbot
Aug 12 2017 10:00
kjuchtmans sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3196 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Aug 12 2017 10:02
@kjuchtmans - you're welcome, and thanks for the kind words (on behalf of those who are much more active here than I have been lately) Good luck with the continued learning!
CamperBot
@camperbot
Aug 12 2017 10:02
khaduch sends brownie points to @kjuchtmans :sparkles: :thumbsup: :sparkles:
:cookie: 297 | @kjuchtmans |http://www.freecodecamp.com/kjuchtmans
namethatisnottaken
@namethatisnottaken
Aug 12 2017 10:09
hi can anyone tell me how to use jquery custom slider ?
i want to load it from cdn i suppose
Ken Haduch
@khaduch
Aug 12 2017 10:25
@namethatisnottaken - I'm not familiar with it, but it looks like it is part of the jquery UI package? http://api.jqueryui.com/slider/ - if you're using CodePen, there is a quick-add on the JS config tab for jqueryUI.
namethatisnottaken
@namethatisnottaken
Aug 12 2017 10:34
yes thanks for advice mate thanks @khaduch
CamperBot
@camperbot
Aug 12 2017 10:34
namethatisnottaken sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3197 | @khaduch |http://www.freecodecamp.com/khaduch
Parsuli
@par5ul1
Aug 12 2017 10:54
hello
what does ? : do
Stephen James
@sjames1958gm
Aug 12 2017 10:57
@par5ul1 It is called the ternary operator it is a short hand for if / else -
Parsuli
@par5ul1
Aug 12 2017 10:57
@sjames1958gm thanks
CamperBot
@camperbot
Aug 12 2017 10:57
par5ul1 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8301 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 12 2017 10:57
@par5ul1 it also is an expression which returns a value
var result = condition ? it_true : if_false
Shakil
@shaqc97
Aug 12 2017 12:07
Hello
Ene Catalin
@EneCatalin
Aug 12 2017 12:08
hello
Shakil
@shaqc97
Aug 12 2017 12:09
Can you give me a hand with these two ajax calls
I'm trying to call both these functions
Ene Catalin
@EneCatalin
Aug 12 2017 12:10
oh boy, I suck at this too
Shakil
@shaqc97
Aug 12 2017 12:10
ah rip
they both work individually
Ene Catalin
@EneCatalin
Aug 12 2017 12:10
maybe include one in the other ?
so when one gets called you call both ?
Shakil
@shaqc97
Aug 12 2017 12:11
Ok ill try that
It works but when I try to access the the data outside of the function it returns undefined
logging it at the end of the callback works as intended
but logging it from outside returns undefined
Ene Catalin
@EneCatalin
Aug 12 2017 12:15
hmm
try to define the var outside
and just say x = whatevs inside
I am shooting in the dark here tbh
Shakil
@shaqc97
Aug 12 2017 12:16
I know what the problem is
its this
"because your AJAX call can get data at any time (it could take 1 second; it could take 10 seconds), the rest of the code (including the return statement) will execute synchronously, i.e. before the server even has a chance to respond with data."
but I don't know how to work around it
Ene Catalin
@EneCatalin
Aug 12 2017 12:17
wait
I had this problem quite recently
I included my thing that depended on it
in the success part
so try putting the 2nd ajax there
Ene Catalin
@EneCatalin
Aug 12 2017 12:27
any luck ?
Shakil
@shaqc97
Aug 12 2017 12:27
Think I figured it out
you just have to handle the data in the success callback only
I'm just working on rendering stuff now with Mustache.js
got it to work :)
Simey de Klerk
@simeydk
Aug 12 2017 12:51
Hi Everyone. I have a question on HTTP requests (like AJAX). I'm trying to avoid JQuery and do it from first principles. I have wrapped a XMLHTTPRequest in a Promise. However, It fails because it's cross original, whereas $.AJAX doesn't fail. Any thoughts on this?
Diego Mayer
@Chrono79
Aug 12 2017 12:53
Simey de Klerk
@simeydk
Aug 12 2017 12:57
@Chrono79 Thanks for the idea. However, I'm hoping to find a solution that doesn't require the user to have a special extention installed (or doesn't limit the user to Chrome!).
How does JQuery achieve this? Is there a (simple) way to mimic this by hand without having to import the entire JQuery?
CamperBot
@camperbot
Aug 12 2017 12:57
simdk8 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4520 | @chrono79 |http://www.freecodecamp.com/chrono79
Stephen James
@sjames1958gm
Aug 12 2017 13:04
@Simdk8 Here is a site that shows jsonp with promises - https://github.com/camsong/fetch-jsonp/blob/master/src/fetch-jsonp.js
Diego Mayer
@Chrono79
Aug 12 2017 13:08
After seeing that I would use jQuery ;)
Simey de Klerk
@simeydk
Aug 12 2017 13:08
@sjames1958gm Thanks. Is there no simpler way to do this? I have been reading http://eloquentjavascript.net/17_http.html and really like the, well, eloquence of the promise + XHR based 'get' function in there. However, it is severely limited because it can't do cross origin
CamperBot
@camperbot
Aug 12 2017 13:08
simdk8 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8302 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 12 2017 13:10
In order to get around cross origin you create a script tag with a callback function. that is what jquery is doing for you.
Of course fetch is a browser API that supports promises already
Simey de Klerk
@simeydk
Aug 12 2017 13:14
how does the script tag with a callback function solve the problem? Is it not just shifting the cross-origin request from one source to another?
(i'm working on the Wikipedia Viewer site, by the way)
Stephen James
@sjames1958gm
Aug 12 2017 13:17
@Simdk8 because it is no longer an XHR request, but a script load request, which makes the difference, of course the far end has to support it.
Btw, origin=* in your wikipedia URL will allow cross-origin requests
Simey de Klerk
@simeydk
Aug 12 2017 13:18
thanks! @ origin
Abdullah-Al-Zubair
@a2-zubair
Aug 12 2017 14:03

Hello guys, need your help about basic algorithm problem 'Chunky Monkey'. I'm stuck in the for loop with slice the array into 2 groups
here is my code:

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var myArr = [];

  for(var i = 0; i < arr.length; i++){
    myArr = arr.slice(arr[i], size);
    console.log(myArr);
  }
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

I don't understand, how to create the logic that slice the array into two groups?
like this output:

[['a', 'b'], ['c', 'd']];
Datikzz
@Datikzz
Aug 12 2017 14:04
var a = arr.length / 2
then slice starting from arr[a]
Abdullah-Al-Zubair
@a2-zubair
Aug 12 2017 14:20

@Datikzz I still don't understand how am i get this 2 groups array:

[['a', 'b'], ['c', 'd']];

I'm sure i do something idiotic logic. can you tell me where am i doing wrong , plz? and how can i get those outputs


function chunkArrayInGroups(arr, size) {
  // Break it up.
  var myArr = [];
  var a = arr.length / size;

  for(var i = 0; i < a; i++){
    myArr = arr.slice(arr[a], size);
    console.log(myArr);
  }
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
korzo
@korzo
Aug 12 2017 14:34
@a2-zubair your for loop is wrong
@a2-zubair You iterate to only to length/size, so you left part of arr off
@a2-zubair you should iterate to the end of the arr by i+size steps
Stephen James
@sjames1958gm
Aug 12 2017 15:09
@a2-zubair You for loop should be ok as a is not an integer your slice should
use i and i + size
@a2-zubair Then you should probably return something
@a2-zubair myArr = this will overwrite myArr not accumulate an answer
LiciniusRex
@hashtagyolo1
Aug 12 2017 16:12

howdy folks, struggling on chunky monkey today. I'm using splice, but instead of returning intergers it's giving me a string. Anyone can help me out?

```function chunkArrayInGroups(arr, size) {
var newArray = [];
while (arr.length) {
newArray += arr.splice(0, size);
}
console.log([newArray]);
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2);
```

function chunkArrayInGroups(arr, size) {
  var newArray = [];
  while (arr.length) {
    newArray += arr.splice(0, size);
  }
  console.log([newArray]);
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2);
or seperating into multiple arrays
Pethaf
@Pethaf
Aug 12 2017 16:16
@hashtagyolo1 Do you really want to use += ?
Don't you want to use push?
LiciniusRex
@hashtagyolo1
Aug 12 2017 16:18
@Pethaf you absolute legend. Thank you
CamperBot
@camperbot
Aug 12 2017 16:18
hashtagyolo1 sends brownie points to @pethaf :sparkles: :thumbsup: :sparkles:
:cookie: 383 | @pethaf |http://www.freecodecamp.com/pethaf
May Kittens Devour Your Soul
@diomed
Aug 12 2017 16:49
hey . is anyone here good with regex???
Moisés Man
@moigithub
Aug 12 2017 16:51
u
May Kittens Devour Your Soul
@diomed
Aug 12 2017 16:53
not really. can u help me out maybe? @moigithub
my logic is wrong
<RegEx find="(!?e)seda(?![m|tiv])" replaceWith="sjeda" />
I need to exclude e in the beginning
and I also need to have everything but sedativ
sedat :ballot_box_with_check:
sedativ :x:
Having trouble stopping my countdown.
Actually, I'm not even sure why its executing on the Start
var time = setInterval(timer, 1000);
    function timer() {
      counterSession -= 1;
      if (counterSession === 0) {
        clearInterval(time);
}
Why would that execute ? I never actually call the function.
Christopher McCormack
@cmccormack
Aug 12 2017 17:06
time only exists in your start function, make it global
Bradley Sands
@sandsbe
Aug 12 2017 17:08
I believe I tried that but I'll try again because that at least seems to make more sense.
Christopher McCormack
@cmccormack
Aug 12 2017 17:10
Make sure time exists in the outer scope of both those functions and that nothing else is messing with it
Bradley Sands
@sandsbe
Aug 12 2017 17:16
Ok. Working better now. Couple more tweeks.
Abdullah-Al-Zubair
@a2-zubair
Aug 12 2017 17:33
@korzo @sjames1958gm thanks
CamperBot
@camperbot
Aug 12 2017 17:33
a2-zubair sends brownie points to @korzo and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 369 | @korzo |http://www.freecodecamp.com/korzo
:star2: 8305 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
aRtoo
@artoodeeto
Aug 12 2017 17:41

hello masters!! need help. i have a problem on algorithm entitled pig latin.
how can i stop the loop when it hit another consonant?? i tried return and i cant make it work.heres my code:

function translatePigLatin(str) {
  var vowelsArr = 'aeiou'; //way
  //var constArr = 'BCDFGHJKLMNPQRSTVWXYZ'.toLowerCase(); //ay
  var uno = [];
  var dos = [];
  str = str.split('');

  if (vowelsArr.indexOf(str[0]) === -1) {
    for (var i = 0; i < str.length; i++) {
      if (vowelsArr.indexOf(str[i]) === -1) {
        dos.push(str[i]);
      } else if (vowelsArr.indexOf(str[i]) !== -1) {
        uno.push(str[i]);
        uno = uno.join('');
        dos = dos.join('');
        return uno + dos + 'ay';
      }
    }
  } else {
    return str.join('') + 'way';
  }
}

//translatePigLatin("consonant");
//translatePigLatin("california"); //should return "aliforniacay".
//translatePigLatin("paragraphs"); //should return "aragraphspay".
translatePigLatin('glove'); //should return "oveglay".

do i need to put a counter so i can count how many characters to remove? im not gonna use substr im just going to use splice.

Christopher McCormack
@cmccormack
Aug 12 2017 17:44
once you've found the first part, just return the slice of the second part and append your modified first part
May Kittens Devour Your Soul
@diomed
Aug 12 2017 17:51
:cake:
Bradley Sands
@sandsbe
Aug 12 2017 17:52
function sessionTimer() {
    if (counterSession > 0) {
      counterSession -= 1;
    } else {
      clearInterval(sessionTime);
      toggleButtons();
      breakTime = setInterval(breakTimer, 1000);
      counterSession = startSessionTime;
      $("#sessionNum").html(counterSession);
    }
    $("#sessionNum").html(counterSession);
  }

  function breakTimer() {
    if (counterBreak > 0) {
      counterBreak -= 1;
    } else {
      clearInterval(breakTime);
    }
  }
first sessionTimer function works great. Trying to call the breakTime at 0 .
May Kittens Devour Your Soul
@diomed
Aug 12 2017 17:53
over 1kV per cm
Christopher McCormack
@cmccormack
Aug 12 2017 17:54
@sandsbe here's a tip, treat break timer and session timer as just values, and use a single timer that just switches out session and break timer values when one reaches 0
Bradley Sands
@sandsbe
Aug 12 2017 17:56
@cmccormack i love tips. thank you.
CamperBot
@camperbot
Aug 12 2017 17:56
sandsbe sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1127 | @cmccormack |http://www.freecodecamp.com/cmccormack
Stephen James
@sjames1958gm
Aug 12 2017 18:15
@artoodeeto If you break from your for when you find a vowel, i will be the number of consonants, so you can do all
The manipulation after the loop.
Conor Murphy
@cmurphy580
Aug 12 2017 18:50
Is there a deep copy function for nested objects in lodash?
alpox
@alpox
Aug 12 2017 19:11
@cmurphy580 you could use merge
@cmurphy580 or better just: https://lodash.com/docs/#cloneDeep
luccifer00
@luccifer00
Aug 12 2017 19:22

hi there

function changeBackground(icon){

    if (icon == "fog" || icon == "snow" || icon == "sleet" || icon == "clear-night" ){
      $('body').css('background-image', 'url = (https://c1.staticflickr.com/9/8688/28088923173_c00879ee11_b.jpg)');
    }   else if 
       (icon == "cloudy" || "partly-cloudy-night" || "partly-cloudy-day" );{
      $('body').css('background-image', 'url(https://68.media.tumblr.com/32bd8387a7a810b07015a3f1dd412f26/tumblr_o27c7fByaO1tchrkco1_500.gif)');
       }
    else 
       (icon == "clear-day" || "clear-night"  );{
      $('body').css('background-image', 'url(http://www.marinarium.com/wp-content/gallery/sunny-day/396357_283473645047262_234962699898357_788751_2035093401_n1.jpg)');

    }
  }

how can i créate a if statement with 3 variables in JS, i can not allowed to put else if... why not?

May Kittens Devour Your Soul
@diomed
Aug 12 2017 19:25
just use else
luccifer00
@luccifer00
Aug 12 2017 19:36
@diomed thanks , i the semicolon have the fault on the error ! i get it now!
CamperBot
@camperbot
Aug 12 2017 19:36
luccifer00 sends brownie points to @diomed :sparkles: :thumbsup: :sparkles:
:star2: 5206 | @diomed |http://www.freecodecamp.com/diomed
luccifer00
@luccifer00
Aug 12 2017 20:14
https://codepen.io/luccifer00/pen/prPoLR?editors=0100 I just finish my weather app after 2 weeks.... criticisms are well received!!
Margaret
@Margaret2
Aug 12 2017 20:18
wow, @diomed in the JS room? :o
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:19
@Margaret2 diomed needs help with regex, but no1 cares :/
Margaret
@Margaret2
Aug 12 2017 20:19
:scream:
what are you working on
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:19
Margaret
@Margaret2
Aug 12 2017 20:20
@diomed hmm, i'll see if i can work it out
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:21
Ii wonder is this just tricky or not possible. lol
Margaret
@Margaret2
Aug 12 2017 20:22
@diomed are you looking for sedat as a word on its own, or could it be part of another word
like sedate
or ysdlksedat
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:23
sedat is not a word but key part of words
sedativ - i'm trying to expel
but in the same time words with sedat should be able to stay
I guess only iv should be expelled
or only v
but my main problem is in front
Chris Juchtmans
@kjuchtmans
Aug 12 2017 20:25
evening coders! :wave:
Margaret
@Margaret2
Aug 12 2017 20:26
ah ok
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:26
can't figure out how to get rid of e in the beginning
Good Evening, Chris
Margaret
@Margaret2
Aug 12 2017 20:27
@diomed well \b means a word boundary, so you could do /\bsedat/
and that just means the word has to start with sedat
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:28
yeah, that's no good
letters must be before
only not e
Margaret
@Margaret2
Aug 12 2017 20:28
@diomed ok, how about
/e{0}sedat/
makes sure there are 0 occurences of e
Chris Juchtmans
@kjuchtmans
Aug 12 2017 20:29

who is a fan of reduce, to solve any string or array related operations? By this I mean, as much as possible rewriting map, filter, for-loops, while-loops etc with reduce, as advocated in this post

It would seem certain frameworks (eg Redux) heavily rely on reduce

just polling

May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:29
@Margaret2 unsure .gonna check
Margaret
@Margaret2
Aug 12 2017 20:34
hmm maybe not ...
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:34
I really never encountered {0} before
Margaret
@Margaret2
Aug 12 2017 20:36
there's gotta be a way to do it
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:37
where there's a will, there's a way. oi clichey :smile:
Margaret
@Margaret2
Aug 12 2017 20:37
[^e](sedat)(?!iv).*\b @diomed
\b is kind of optional there
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:39
oh FML
Margaret
@Margaret2
Aug 12 2017 20:40
:(
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:42
I think you got it right @Margaret2 :smile:
thank you @Margaret2
CamperBot
@camperbot
Aug 12 2017 20:42
diomed sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 2877 | @margaret2 |http://www.freecodecamp.com/margaret2
Margaret
@Margaret2
Aug 12 2017 20:42
:sweat_smile: glad i could help
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:43
<RegEx find="[^e]seda(?![m|tiv)" replaceWith="sjeda" />
in the end
Margaret
@Margaret2
Aug 12 2017 20:43
ah nice
is <RegEx> an HTML element?
i haven't seen it like that before
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:44
I should remove [
it is XML
Margaret
@Margaret2
Aug 12 2017 20:44
:o
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:45
yeah this is all in 1 big XML file
Margaret
@Margaret2
Aug 12 2017 20:45
wow, idk much about xml
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:46
coz it's replaced by json
:D
Margaret
@Margaret2
Aug 12 2017 20:46
oh haha
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:46
I mena, not really.. but yeah, that's what it basically is
Margaret
@Margaret2
Aug 12 2017 20:46
data interchange format ?
Guderian Raborg
@hypercuber
Aug 12 2017 20:46
I got my squares to rotate yay
https://codepen.io/hypercuber/pen/vJJgZd
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:46
they're similar
Margaret
@Margaret2
Aug 12 2017 20:47
@hypercuber good for you
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:47
now they run like a swiss clock
Margaret
@Margaret2
Aug 12 2017 20:48
replace yoongi with diomed :smile_cat: x
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:49
I only wish 2 be cudled like that :sob:
Margaret
@Margaret2
Aug 12 2017 20:49
:sob:
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:49
but I gave my heart to bottom of the empty cold well
so, no :smiling_imp:
Guderian Raborg
@hypercuber
Aug 12 2017 20:52
@Margaret2 thanks
CamperBot
@camperbot
Aug 12 2017 20:52
hypercuber sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 2878 | @margaret2 |http://www.freecodecamp.com/margaret2
Guderian Raborg
@hypercuber
Aug 12 2017 20:52
@Margaret2 nice profile pic btw
Margaret
@Margaret2
Aug 12 2017 20:52
ha thanks
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:52
yea, she's a sea pancake
Margaret
@Margaret2
Aug 12 2017 20:52
Tortilla del Mar that's me :joy:
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:53
he heh
Guderian Raborg
@hypercuber
Aug 12 2017 20:53
@diomed sea pancake lol
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:53
moto panekeku!
Margaret
@Margaret2
Aug 12 2017 20:53
I'm not gonna be getting one of those clay stingrays :crying_cat_face:
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:53
choto! kinichiro! dozo!
Margaret
@Margaret2
Aug 12 2017 20:54
i was gonna go up to $70, but they're like $90+ :(
guess it was a good thing, made me save my money
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:54
@Margaret2 link me
Margaret
@Margaret2
Aug 12 2017 20:55
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:55
wow! they're that expensive?!?!?
Margaret
@Margaret2
Aug 12 2017 20:55
even with that price, whenever she updates her shop, her stuff sells out in like 1 min, literally
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:56
where is her shop
Margaret
@Margaret2
Aug 12 2017 20:56
like i happened to refresh the page right on the hour she updated, clicked on a product just to look at it, already sold out
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:56
oh lol
Margaret
@Margaret2
Aug 12 2017 20:57
@diomed https://www.etsy.com/shop/FromJae/ she just has stickers now lol
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:58
she has lots of admirers and has very - how does one say
small possibilities to produce
Margaret
@Margaret2
Aug 12 2017 20:58
lol what? :joy:
i really don't see why she doesn't make more
it seems like it could be her full time job
May Kittens Devour Your Soul
@diomed
Aug 12 2017 20:59
demand is bigger than her supply
Margaret
@Margaret2
Aug 12 2017 20:59
but i think she still has some other job lol
May Kittens Devour Your Soul
@diomed
Aug 12 2017 21:00
and takes time to make them, she's the only artist that knows how and that's a problem, I gues
May Kittens Devour Your Soul
@diomed
Aug 12 2017 21:01
@Margaret2 worry not, me and @Manish-Giri shall chip in
Margaret
@Margaret2
Aug 12 2017 21:01
ahahahhahaa
May Kittens Devour Your Soul
@diomed
Aug 12 2017 21:01
seriously
Margaret
@Margaret2
Aug 12 2017 21:02
don't encourage him :P
May Kittens Devour Your Soul
@diomed
Aug 12 2017 21:02
I don't see how that's a bad thing
present 4 a friend
Margaret
@Margaret2
Aug 12 2017 21:03
says the cat who won't even let me give him $3 :unamused:
on ko-fi
May Kittens Devour Your Soul
@diomed
Aug 12 2017 21:04
u need that for rays
Margaret
@Margaret2
Aug 12 2017 21:07
hey if i give you exactly 1.17 coffees, that will hit your target amount of three fiddy
May Kittens Devour Your Soul
@diomed
Aug 12 2017 21:09
lol
Christopher McCormack
@cmccormack
Aug 12 2017 21:18
In React, what's the best way to handle component updates when your initial dataset is empty and components are trying to look in the data to render? Use a conditional to display the component? Use shouldComponentUpdate? something else? (assuming async call to get data)
intcreate
@intcreate
Aug 12 2017 22:01

In PassportJs how do I get the user that clicks a certain button?
I know I can do req.session.passport.user
But what if there are multiple users logged in.

Will req.session.passport.user have a lot of users?

Michiel
@MichielHuijse
Aug 12 2017 22:08
Hello I am working on a website and the mobile menu is open on the page load. www.ilprecords.com how can I prevent this?
window.onload = function () { $( "ul#navlist" ).slideup( "fast" ); }

$( document ).ready(function() {

// Jquery script for sliding nav menu up and down when pressing on the hamburger.
$( ".container" ).click(function() {
  $( "ul#navlist" ).slideToggle( "fast" );});

});
This is my current code.
dyon3334
@dyon3334
Aug 12 2017 22:18
can someone help me

function largestOfFour(arr) {
 var largest =0;
  var output =[];
for (i=0;i<arr.length;i++){
  for(j=0;j<arr[i][j].length;j++){
  if (arr[i][j] > largest){
    largest =  arr[i][j];
    output.push(largest); 
}    
}
  largest = 0;
}
  return output;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
i only get a empty array
Christopher McCormack
@cmccormack
Aug 12 2017 22:23
@MichielHuijse check your toggleList function and make sure your display is set correctly on different viewports
@dyon3334 for your inner loop use j<arr[i].length or your going to only iterate once
@dyon3334 you also don't want to push largest inside your inner loop
if your array was sorted, it would add all 4 items
Michiel
@MichielHuijse
Aug 12 2017 22:49
@cmccormack thanks
CamperBot
@camperbot
Aug 12 2017 22:49
michielhuijse sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1128 | @cmccormack |http://www.freecodecamp.com/cmccormack
Ruchika Sharma
@ruchika90
Aug 12 2017 22:50
@Manish-Giri ty it worked
CamperBot
@camperbot
Aug 12 2017 22:50
ruchika90 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6403 | @manish-giri |http://www.freecodecamp.com/manish-giri
insouciantone
@insouciantone
Aug 12 2017 23:23
Hey all, I'm (finally) on the tail end of my Weather API app and I'm trying to clean it up now and make it relatively nice looking.
How do I strip the quotation marks out of the data returned from the API call?
Oleh
@Lufter
Aug 12 2017 23:25
Hey guys, I'm stuck with this code to task "Wherefore art thou", actually I don't understand the origin of this error "Type error: collection[i] is undefined".
Could you please explain me why i see this error and how to avoid it?
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var sourceKey = Object.keys(source);
  var collectionKey = Object.keys(collection);
  for (var i=1; i <= collectionKey.length; i++){
    var collectionItem = collection[i];
    var sourceItem = source;
    if (collection[i].hasOwnProperty(sourceKey) && collection[i][sourceKey] === source[sourceKey]){
     arr.push(collectionItem);
    } 
  }
  arr.push(source);
  // Only change code above this line
  return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
//whatIsInAName([{ "a": 1 }, { "a": 1 }, { "a": 1, "b": 2 }], { "a": 1 });
insouciantone
@insouciantone
Aug 12 2017 23:26
collection isn't defined in your code
Christopher McCormack
@cmccormack
Aug 12 2017 23:27
@Lufter you're doing i <= collectionKey.length but that will put your index i one more than the values available during the final iteration of the loop. Remember indexes start at 0 and end at length - 1
Oleh
@Lufter
Aug 12 2017 23:30
@insouciantone var collection comes from the function itself
@cmccormack thanx :)
CamperBot
@camperbot
Aug 12 2017 23:30
lufter sends brownie points to @insouciantone and @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @insouciantone |http://www.freecodecamp.com/insouciantone
:star2: 1129 | @cmccormack |http://www.freecodecamp.com/cmccormack
insouciantone
@insouciantone
Aug 12 2017 23:31
@Lufter Yes but the range is undefined as chris pointed out.
baersc
@baersc
Aug 12 2017 23:48
Hey, does anyone have any experience with airbnb style guide? I'm trying to install it into my project using npm. I'm finding that it doesn't lint if i install the base package. I only works if I install the complete framework with react support, but I'm not using react. Anyone have any clues what I'm doing wrong?
Tai Jones
@taiJones00
Aug 12 2017 23:49
https://codepen.io/taiJones00/pen/xLqemx any idea why only one quote is being returned?
fdemaa
@fdemaa
Aug 12 2017 23:50
how can i set an on/of state to me slider button, i think it behaves like a checkbox? any clues ?
luccifer00
@luccifer00
Aug 12 2017 23:50
@taiJones00 i can read diferent quotes...
@taiJones00 it run well on my browser...
baersc
@baersc
Aug 12 2017 23:52
@insouciantone Oh man, I remember I had that image you're using in your weather app as my background, like 10 years ago. Blast from the past lol
insouciantone
@insouciantone
Aug 12 2017 23:53
@baersc Ye it's been sitting on my harddrive for about that long.
luccifer00
@luccifer00
Aug 12 2017 23:53

https://codepen.io/luccifer00/pen/YxxjxE?editors=0010

i am on Wikipedia viewer.... and i dont know if i understand the wiki api.... or i dont know how to finish my function to bring the results on the main page... any help??