These are chat archives for FreeCodeCamp/HelpJavaScript

30th
Aug 2016
@eduwin7 Please format your code
'''
CamperBot
@camperbot
Aug 30 2016 00:00
:bulb: to format code use backticks! ``` more info
Ian
@IMLaing
Aug 30 2016 00:00
just realized I am in JS room my bad
Egoscio
@Egoscio
Aug 30 2016 00:00
Lol it's fine :)
Ian
@IMLaing
Aug 30 2016 00:00
Thank you again
lol
eduwin7
@eduwin7
Aug 30 2016 00:00
what do you mean?
have patience with me jeje
Ian
@IMLaing
Aug 30 2016 00:00
use the ticks @eduwin7
does the camperbot take questions now?
Egoscio
@Egoscio
Aug 30 2016 00:01
console.log('you can format your code with backticks')
eduwin7
@eduwin7
Aug 30 2016 00:01
tickts?
Ian
@IMLaing
Aug 30 2016 00:01
next to the 1 key
Egoscio
@Egoscio
Aug 30 2016 00:01
Top left of your screen next. same key as ~
Ian
@IMLaing
Aug 30 2016 00:01
``````
I can add in code stuff
just add three of ``` and then press enter
and add you code between them
eduwin7
@eduwin7
Aug 30 2016 00:02
function lookUpProfile(firstName, prop){
// Only change code below this line
var i= 0;
var found;
while (i < contacts.length){
if (contacts [i] .firstName ==
firstName) {
found = contacts[i];
}
i++;
}
Egoscio
@Egoscio
Aug 30 2016 00:02
Screen Shot 2016-08-29 at 5.01.54 PM.png
Juan
@juanm18
Aug 30 2016 00:02
@Egoscio got it, Thanks man. i tried to return randomWholeNum() at first but didnt work. all i had to do was remove the parenthesis at the end.
CamperBot
@camperbot
Aug 30 2016 00:02
juanm18 sends brownie points to @egoscio :sparkles: :thumbsup: :sparkles:
:cookie: 34 | @egoscio |http://www.freecodecamp.com/egoscio
Egoscio
@Egoscio
Aug 30 2016 00:02
Adding js at the end specifies the syntax language
eduwin7
@eduwin7
Aug 30 2016 00:04
function lookUpProfile(firstName, prop){
// Only change code below this line
var i= 0;
var found;
while (i < contacts.length){
if (contacts [i] .firstName ==
firstName) {
found = contacts[i];
}
i++;
}
```
Egoscio
@Egoscio
Aug 30 2016 00:04
@eduwin7 Does it specify using a while loop, or can you use other functions (like filter)
Austin Law
@alaw989
Aug 30 2016 00:04
Hello my friends
eduwin7
@eduwin7
Aug 30 2016 00:04
it doesn't specify
Jeffrowetull
@Jeffrowetull
Aug 30 2016 00:05
hi im checking for palindromes and I am trying to use .replace to get rid of the special characters and spaces. My problem is that I don't know how to list all the special characters inside of one .replace(). Is it possible?
Austin Law
@alaw989
Aug 30 2016 00:05
my fellows coders, please lend my your assistance with this basic algorithm
function chunkArrayInGroups(arr, size) {
  var newArr = [];
  for (i = 0; i < arr.length; i += size) {
      newArr.push(arr.slice(i, i + size));
  }
  return newArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Alexander Køpke
@alexanderkopke
Aug 30 2016 00:05
@Jeffrowetull you can use a regex inside the replace(put regex here, '')
eduwin7
@eduwin7
Aug 30 2016 00:05
@Jeffrowetull .replace(/\w/g)
Austin Law
@alaw989
Aug 30 2016 00:06
is the i += size saying i goes up by increments of whatever number size is?
Ken Haduch
@khaduch
Aug 30 2016 00:06
@eduwin7 - you can use this - a for loop is a bit easier, but this should work. If you find a firstName match, then you should do one of two things - check to see if that particular contact record (which is an Object) has the property that is being searched for or determine that it does not. As long as the firstName matches, those are the only two possible things you should do. And you can make the appropriate return as directed by the problem statement.
eduwin7
@eduwin7
Aug 30 2016 00:06
str.replace(/[\W_]/g, '')
Austin Law
@alaw989
Aug 30 2016 00:06
@eduwin7 what does that regexp say?
Jeffrowetull
@Jeffrowetull
Aug 30 2016 00:07
@alexanderkopke I have heard of regex, but I am afraid I still don't understand it. Do you know of a good tutorial because all of the ones I have read didn't help me
Egoscio
@Egoscio
Aug 30 2016 00:07
@eduwin7 First off, you should probably make use of the prop argument. Also, are you returning anything?
@Jeffrowetull Outside FCC, http://regexr.com/ is a great source for mastering regex. I personally use it quite often.
Jeffrowetull
@Jeffrowetull
Aug 30 2016 00:08
@Egoscio thank you
CamperBot
@camperbot
Aug 30 2016 00:08
jeffrowetull sends brownie points to @egoscio :sparkles: :thumbsup: :sparkles:
:cookie: 35 | @egoscio |http://www.freecodecamp.com/egoscio
kennyq94
@kennyq94
Aug 30 2016 00:09
can someone help me I want my hexagon to stay fixed when minimizing screen. I want it to have the same effect when minizing screen from the right. Notice the padding causes picture to shift with the screen when minizing screen from the left. Thank You!!!
https://codepen.io/kennyqsoftware/pen/OXKomj
lettda
@lettda
Aug 30 2016 00:11
can't do the chunkyArray algorithm but got the Slasher one in 20 secs -__-
Egoscio
@Egoscio
Aug 30 2016 00:12
@kennyq94 Hi kenny! Just to let you know, this is the Javascript channel. The folks at HelpFrontEnd are likely more experienced in such areas :)
eduwin7
@eduwin7
Aug 30 2016 00:14
@Egoscio nope
Stephen James
@sjames1958gm
Aug 30 2016 00:14
@alaw989 Your code is correct.
Alexander Køpke
@alexanderkopke
Aug 30 2016 00:16
@Jeffrowetull http://regexr.com/ I use this one as well. click cheatsheat in the menu and try out some regex codes to see what they do. for example /\w/g, /\s/g, /\d/g to name a few.. those are the codes you would put inside replace(/\w/g, ''); if you want to use more than one code you can group them in a bracket /[\w_]/g or /[\w\s\d]/g
Austin Law
@alaw989
Aug 30 2016 00:18
@sjames1958gm yes, i know. i am seeking an explanation for i += size, is that just saying i goes up in increments of whatever number size is ?
Egoscio
@Egoscio
Aug 30 2016 00:18
@eduwin7 What I don't understand is why you need a prop argument if you explicitly define the target property as firstName?
kevlozano
@kevlozano
Aug 30 2016 00:21
hey guys I need help with the Return Largest Numbers in Arrays challenge
this is my code, but it aint working

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

var finalArray=[];
var largestNum=0;

for (var i = 0; i < arr.length ; i++){
for (var n=0; n< arr[n].length ; n++){
if (arr[i][n]>largestNum){
largestNum=arr[i][n];
finalArray.push(largestNum);
}
}
finalArray=largestNum;
}
return finalArray;
}

any ideas?
Egoscio
@Egoscio
Aug 30 2016 00:22

To make sense, you would need two arguments: prop and value:

function lookUpProfile(prop, value) {
    return contacts.filter(function(contact) {
        return contact[prop] === value
    })
}

I apologies if it confuses you, but this is what makes sense from the context you provide.

Johnny
@JohnnyBizzel
Aug 30 2016 00:22
function largestOfFour(arr) {
// You can do this!

var finalArray=[];
var largestNum=0;

for (var i = 0; i < arr.length ; i++){
for (var n=0; n< arr[n].length ; n++){
if (arr[i][n]>largestNum){
largestNum=arr[i][n];
finalArray.push(largestNum);
}
}
finalArray=largestNum;
}
return finalArray;
}
Egoscio
@Egoscio
Aug 30 2016 00:22
then you could do lookUpProfile('firstName', 'John')
Johnny
@JohnnyBizzel
Aug 30 2016 00:23
@kevlozano I'm confused. Is it a multi dimentional array?
Elizabeth Crummy
@lizzyac
Aug 30 2016 00:24
I'm trying to return the first letter of each word capitalized in a string and am not sure if I'm on the right track. Any help would be appreciated!
function titleCase(str) {
 var splitString = str.split(" ");
 // for loop to each word
 for (i =0; i < splitString.length; i++) {
   var arrayIndex = splitString[i];
   for (var j = i; j < arrayIndex.length; j++) {
    var firstLetter = arrayIndex[j];
    firstUpperCase = firstLetter[0].toUpperCase;
      }

 }
   return firstUpperCase;
}

titleCase("I'm a little tea pot");
Jeffrowetull
@Jeffrowetull
Aug 30 2016 00:24
Regexr is really good, I like it a lot. I put the /[\W__]/g into my .replace(), but now it won't show the outputs in my console. Instead it refuses to load script because it violates the following content security policy directive. Then it lists a bunch of weird stuff.
Egoscio
@Egoscio
Aug 30 2016 00:24
@JohnnyBizzel IIRC, there are nested arrays in this example, like so: [[1, 4, 7], [9, 4, 0], [10, 5, 9]] etc
Johnny
@JohnnyBizzel
Aug 30 2016 00:24
@Jeffrowetull Tried this? http://regexr.com/
kevlozano
@kevlozano
Aug 30 2016 00:25
yes, they're nested arrays @JohnnyBizzel
Jeffrowetull
@Jeffrowetull
Aug 30 2016 00:25
@JohnnyBizzel Yeah the other guys clued me in on that site and I have been using it.
Egoscio
@Egoscio
Aug 30 2016 00:25
@lizzyac Does the exercise specify having to use for loops?
Jeffrowetull
@Jeffrowetull
Aug 30 2016 00:25
@JohnnyBizzel Now I cant get the console to work
Egoscio
@Egoscio
Aug 30 2016 00:26
Or is it not an exercise at all? (personal project)
greg
@wearenotgroot
Aug 30 2016 00:26
@lizzyac toUpperCase is missing () also you need to declare firstUpperCase somewhere on the top
firstUpperCase = firstLetter[0].toUpperCase();
Elizabeth Crummy
@lizzyac
Aug 30 2016 00:26
@Egoscio no, it's open to any method.
@wearenotgroot thanks! forget it included parentheses.
CamperBot
@camperbot
Aug 30 2016 00:27
lizzyac sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1504 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Egoscio
@Egoscio
Aug 30 2016 00:27
@lizzyac greg is right on that part, but I was just thinking you could make it simpler with .map().
Johnny
@JohnnyBizzel
Aug 30 2016 00:28
@lizzyac Don't understand why you do j = i in the second loop
greg
@wearenotgroot
Aug 30 2016 00:28
@lizzyac you only really need one for loop and just slice that string(lowercase everything first)
Johnny
@JohnnyBizzel
Aug 30 2016 00:29
@kevlozano Do you have to return the largest item from each array or the largest overall?
kevlozano
@kevlozano
Aug 30 2016 00:29
largest from each array @JohnnyBizzel
Stephen James
@sjames1958gm
Aug 30 2016 00:29
@alaw989 For slice the second parm is the end index so it needs to move up by size each time as well
Elizabeth Crummy
@lizzyac
Aug 30 2016 00:30
@JohnnyBizzel I wanted the second loop to go through each word.
Johnny
@JohnnyBizzel
Aug 30 2016 00:30
@kevlozano Can you split the arrays first and they join them back together when you;ve found the largest from each?
Elizabeth Crummy
@lizzyac
Aug 30 2016 00:31
@Egoscio Thanks, I don't remember using the map() function before. I'll try it out.
CamperBot
@camperbot
Aug 30 2016 00:31
lizzyac sends brownie points to @egoscio :sparkles: :thumbsup: :sparkles:
:cookie: 36 | @egoscio |http://www.freecodecamp.com/egoscio
Jeffrowetull
@Jeffrowetull
Aug 30 2016 00:32
I added in the regular expression, but my code is still not being accepted and I'm lost as to what's wrong. Here it is.

function palindrome(str) {
// take the string, take out any spaces and special characters.
string=str.replace(/[\W_]/g,'');
array=string.split('');
lower= str.toLowerCase();
reverseArray=array.reverse();
reverseString=reverseArray.join('');
lowerString=reverseString.toLowerCase();
if(lower==lowerString){
return true;
}
else {return false;}
}

palindrome("_eye");

lettda
@lettda
Aug 30 2016 00:33
Ok I give up why is this not working? It doesn't return the last values
function chunkyArray(arr, size) {
    var chunkArr = [];

    while (arr.length > size) {
        chunkArr.push(arr.splice(0, size));
    }

    if (arr.length <= size) 
      chunkArr.push(arr);

  return chunkArr;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2);
Jeffrowetull
@Jeffrowetull
Aug 30 2016 00:33
by the way, how do you show code here like it does on the main page i.e. black with colored digites?
Egoscio
@Egoscio
Aug 30 2016 00:33
'''
CamperBot
@camperbot
Aug 30 2016 00:33
:bulb: to format code use backticks! ``` more info
Elizabeth Crummy
@lizzyac
Aug 30 2016 00:33
@wearenotgroot the second for loop isn't needed to go through each word in the in the string? Is this because it is an array, so only the variable i is needed to change each word?
Egoscio
@Egoscio
Aug 30 2016 00:33
triple backticks
Stephen James
@sjames1958gm
Aug 30 2016 00:34
@lettda Your function has a different name than the test call?
greg
@wearenotgroot
Aug 30 2016 00:34
@lizzyac well you can use but not necessary. what you need to do is
  • var splitString = str.toLowerCase().split(" "); //lowercase everything then turn them into an array
  • loop through each item in the array
  • access the first letter and Uppercase it splitString[i][0].toUpperCase()
  • get the other part of the word using slice splitString[i].slice(1);
  • concatenate and make a new string
lettda
@lettda
Aug 30 2016 00:34
FAIL!
Jeffrowetull
@Jeffrowetull
Aug 30 2016 00:35
This message was deleted
This message was deleted
Egoscio
@Egoscio
Aug 30 2016 00:35
@Jeffrowetull You need a triple backtick at the end too
Jeffrowetull
@Jeffrowetull
Aug 30 2016 00:35
oh
Egoscio
@Egoscio
Aug 30 2016 00:35
Sorry :P
Stephen James
@sjames1958gm
Aug 30 2016 00:35
@lettda Also if your while loop is > 0 you wont need the extra code after the while loop
lettda
@lettda
Aug 30 2016 00:35
is there something wrong with the editor?
Jeffrowetull
@Jeffrowetull
Aug 30 2016 00:35

```function palindrome(str) {
// take the string, take out any spaces and special characters.
string=str.replace(/[\W_]/g,'');
array=string.split('');
lower= str.toLowerCase();
reverseArray=array.reverse();
reverseString=reverseArray.join('');
lowerString=reverseString.toLowerCase();
if(lower==lowerString){
return true;
}
else {return false;}
}

palindrome("_eye");
```

Egoscio
@Egoscio
Aug 30 2016 00:35
put an enter before the function
Jeffrowetull
@Jeffrowetull
Aug 30 2016 00:36

``` function palindrome(str) {
// take the string, take out any spaces and special characters.
string=str.replace(/[\W_]/g,'');
array=string.split('');
lower= str.toLowerCase();
reverseArray=array.reverse();
reverseString=reverseArray.join('');
lowerString=reverseString.toLowerCase();
if(lower==lowerString){
return true;
}
else {return false;}
}

palindrome("_eye");

Stephen James
@sjames1958gm
Aug 30 2016 00:36
@Jeffrowetull Your lower is from str not string
lettda
@lettda
Aug 30 2016 00:36
@sjames1958gm so this
function chunkyArray(arr, size) {
    var chunkArr = [];

    while (arr.length > size) {
        chunkArr.push(arr.splice(0, size));
    }
      chunkArr.push(arr);

      return chunkArr;
}

chunkyArray([0, 1, 2, 3, 4, 5, 6], 3);
Jeffrowetull
@Jeffrowetull
Aug 30 2016 00:36
@sjames1958gm oh right
Egoscio
@Egoscio
Aug 30 2016 00:36
Screen Shot 2016-08-29 at 5.01.54 PM.png
Stephen James
@sjames1958gm
Aug 30 2016 00:36
@lettda no extra push either.
Jeffrowetull
@Jeffrowetull
Aug 30 2016 00:37
hi
oh yeah!
Stephen James
@sjames1958gm
Aug 30 2016 00:37
@lettda while (arr.length > 0)
Jeffrowetull
@Jeffrowetull
Aug 30 2016 00:37
function palindrome(str) {
  // take the string, take out any spaces and special characters.
 string=str.replace(/[\W_]/g,'');
  array=string.split('');
  lower= str.toLowerCase();
  reverseArray=array.reverse();
  reverseString=reverseArray.join('');
  lowerString=reverseString.toLowerCase();
  if(lower==lowerString){
    return true;
  }
  else {return false;}
}



palindrome("_eye");
wow thats awesome
thanks so much guys
Johnny
@JohnnyBizzel
Aug 30 2016 00:38
@Jeffrowetull You can probably daisy chain those text functions.
lettda
@lettda
Aug 30 2016 00:38
@sjames1958gm so when it gets to those odd ball ending elements it just adds them to the array anyway?
Antonio Jovanovic
@supamerz
Aug 30 2016 00:38
hey - I seem to be stuck on something silly.
lettda
@lettda
Aug 30 2016 00:38
it makes sense i just want to understand what it's doing
Antonio Jovanovic
@supamerz
Aug 30 2016 00:38
function updateRecords(id, prop, value) {
  collection[id][prop] = value;
  return collection;
}
Stephen James
@sjames1958gm
Aug 30 2016 00:39
@lettda splice when the second parameter goes past the end just returns the whole array (all that's left)
Antonio Jovanovic
@supamerz
Aug 30 2016 00:39
When I test my code it does exactly what's expected of the "test" results.
CODiaz17
@CODiaz17
Aug 30 2016 00:39
Can someone please help me with converting celsius to fahrenheit
lettda
@lettda
Aug 30 2016 00:40
@sjames1958gm so to break it down, the array will always be greater than 0, but if there aren't '2' elements to push its just pushes what's left
Stephen James
@sjames1958gm
Aug 30 2016 00:40
@lettda After the splice when array.length is < size it will be empty
lettda
@lettda
Aug 30 2016 00:40
@sjames1958gm then there's nothing to push and the loop ends
giving me my array
Stephen James
@sjames1958gm
Aug 30 2016 00:41
@lettda Bingo
lettda
@lettda
Aug 30 2016 00:41
@sjames1958gm thanks bro, that was a headache
CamperBot
@camperbot
Aug 30 2016 00:41
lettda sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2956 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Moisés Man
@moigithub
Aug 30 2016 00:41
@supamerz dont understand.. whats ur question ?
Egoscio
@Egoscio
Aug 30 2016 00:45
@supamerz If I recall correctly, there's much more to do than just that. You need one case where there is no value and one case where the prop is track. Where are those?
Antonio Jovanovic
@supamerz
Aug 30 2016 00:47
got ya ok
Rudrangshu Nandi
@Rud156
Aug 30 2016 01:07
How do I check what the function the case of a function call within a function:
dropElements([1,2,3], function(n){return n < 3;});
Elizabeth Crummy
@lizzyac
Aug 30 2016 01:08

I'm not sure why my return function is not recognized as a function.

'''

CamperBot
@camperbot
Aug 30 2016 01:09
:bulb: to format code use backticks! ``` more info
Rudrangshu Nandi
@Rud156
Aug 30 2016 01:09
how do I know what the function is in the call??
Elizabeth Crummy
@lizzyac
Aug 30 2016 01:09
function titleCase(str) {
 str = str.toLowerCase().split(" ");
 // for loop to each word
 for (var i =0; i < str.length; i++)
    {
   string = str[i][0].toUpperCase().concat(str[i].slice(1));

     }

 return string.join(" ");
}

titleCase("I'm a little tea pot");
greg
@wearenotgroot
Aug 30 2016 01:10
@lizzyac
well string isnt declare anywhere and .join() only work on array

@lizzyac what you can do is reassign the str[i] to the new string you made

str[i] = str[i][0].toUpperCase().concat(str[i].slice(1));

then return str

return str.join(" ");
Elizabeth Crummy
@lizzyac
Aug 30 2016 01:11
@wearenotgroot I thought by splitting it the string should be an array?
greg
@wearenotgroot
Aug 30 2016 01:11
@lizzyac string isnt an array, str is
str = str.toLowerCase().split(" "); //<-----assigned the array from split to str
Elizabeth Crummy
@lizzyac
Aug 30 2016 01:12
Oh, got it, thanks @wearenotgroot!
CamperBot
@camperbot
Aug 30 2016 01:12
lizzyac sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:warning: lizzyac already gave wearenotgroot points
Rudrangshu Nandi
@Rud156
Aug 30 2016 01:12
@wearenotgroot could you help me out?
greg
@wearenotgroot
Aug 30 2016 01:12
@lizzyac oh check your pm when you finished the challenged
@Rud156 post your entire code and ask specific question?
Rudrangshu Nandi
@Rud156
Aug 30 2016 01:14
How do I know the function in the function call in this case:
dropElements([1,2,3], func(n){ return n < 3;});
dropElements is the function I have to complete
I have to return all values that are less than 3 in this case. But the function in the call keeps on changing
How do I know what the function is
Also how to post code here?
Rudrangshu Nandi
@Rud156
Aug 30 2016 01:17

'''js
function dropElements(arr, func) {
console.log(func);
// Drop them elements.
return arr;
}

dropElements([1, 2, 3], function(n) {return n < 3; });
'''

CamperBot
@camperbot
Aug 30 2016 01:17
:bulb: to format code use backticks! ``` more info
Cage Echarte
@CageEcharte
Aug 30 2016 01:18
whats wrong with my code here?
switch (val === "bob") {
answer = "Marley";
break;
case 1: (val === 42)
answer = "The Answer";
break;
case 2: (val === 1)
answer = "There is no #1";
break;
case 3: (val === 99)
answer = "Missed me by this much!";
break;
case 4: (val === 7)
answer = "Ate Nine";
}
greg
@wearenotgroot
Aug 30 2016 01:19
@Rud156 you can try and use filter and use it on arr and feed func as the argument
  • filter docs
    filter will give you an array with elements that are kept depending on what your callback function does. since your callback function return true or false depending if a number is less than 3, this is perfect for filter as callback. (if the callback function returns true the item is kept else the item is tossed)
Margaret
@Margaret2
Aug 30 2016 01:21
@CageEcharte need a break after the last case. Another tip: you can just use case 42, case 1, etc.
Sitys
@Sitys
Aug 30 2016 01:21
i need help with PREVENTDEFAULT
Rudrangshu Nandi
@Rud156
Aug 30 2016 01:21
Ok I'll see
Thanks
Margaret
@Margaret2
Aug 30 2016 01:22
@CageEcharte also, you should have a case for bob and just switch (val) at the top
Sitys
@Sitys
Aug 30 2016 01:22
preventdefault??? nothing????
Rudrangshu Nandi
@Rud156
Aug 30 2016 01:22
@Sitys use event.preventDefault()
Sitys
@Sitys
Aug 30 2016 01:23
i tried to use in razor and dont work as the example in documentation
Rudrangshu Nandi
@Rud156
Aug 30 2016 01:23
@Sitys It overrides all but the Esc key function
Sitys
@Sitys
Aug 30 2016 01:25
i use this on an EDITORFOR (X => X.FIELDNAME, new { htmlAttributes = new { @class = "form-control", onchange = @"form.submit(e.preventdefault()); } })
i want to submit the form to check the model... but prevent submiting the for in the controller
David Coy
@obsidianspork
Aug 30 2016 01:26
Good evening/morning where ever you are! I am trying to figure out "Manipulating Complex Objects", here's what I have thus far
Rudrangshu Nandi
@Rud156
Aug 30 2016 01:26
Its capital 'D'
@Sitys
Cage Echarte
@CageEcharte
Aug 30 2016 01:26
@Margaret2 what about now?case 1: (val === "bob") {
answer = "Marley";
break;
case 2: (val === 42)
answer = "The Answer";
break;
case 3: (val === 1)
answer = "There is no #1";
break;
case 4: (val === 99)
answer = "Missed me by this much!";
break;
case 5: (val === 7)
answer = "Ate Nine";
break;
David Coy
@obsidianspork
Aug 30 2016 01:26
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here
];

myMusic.push( 
  {
    "artist": "Bruce Sprintsteen",
    "title":  "Murica",
    "release_year": 1981,
    "formats": [
      "CD",
      "8-track(probably)",
      "Radio",
      "LP",
      "Laser-disc"
    ],
})
greg
@wearenotgroot
Aug 30 2016 01:27

@CageEcharte change

switch (val === "bob")

to

switch (val)

val will be compare to what the cases are

Margaret
@Margaret2
Aug 30 2016 01:28
@CageEcharte should start with:
 switch (val) {
    case "bob":
      answer = "Marley";
      break;
you don't use case 1:(val === bob) syntax in a switch statement
not as this challenge teaches anyway
greg
@wearenotgroot
Aug 30 2016 01:29

@obsidianspork no need to push just do

var myMusic = [object1, object2, ...]

add the object directly and separate them with a comma(,)

David Coy
@obsidianspork
Aug 30 2016 01:31
You're awesome @wearenotgroot, thank you
CamperBot
@camperbot
Aug 30 2016 01:31
obsidianspork sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1505 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Aug 30 2016 01:31
@obsidianspork :+1:
Adrian Kopytko
@adriankopytko
Aug 30 2016 01:33
Hello, I seach an alternative of eval(). Is there an another good solution? I have string like this:
3434+545-232
(yep, js calculator) but i'm not sure if eval will be adequate for this.
Joseph
@revisualize
Aug 30 2016 01:36
... Hello.
Margaret
@Margaret2
Aug 30 2016 01:36
:wave:
Joseph
@revisualize
Aug 30 2016 01:37
:wave:
Cage Echarte
@CageEcharte
Aug 30 2016 01:38

now what?
switch (val) {
case "bob":
answer = "Marley";
break;
case 2: (val === 42)
answer = "The Answer";
break;

case 3: (val === 1)
answer = "There is no #1";
break;

case 4: (val === 99)
answer = "Missed me by this much!";
break;

case 5: (val === 7)
answer = "Ate Nine";
break;

Joseph
@revisualize
Aug 30 2016 01:39
@CageEcharte Name of the lesson?
Margaret
@Margaret2
Aug 30 2016 01:39
@CageEcharte fix the rest of the cases... case 42, not case 2; case 1, not case 3 and so on
greg
@wearenotgroot
Aug 30 2016 01:40
@revisualize this one-->Replacing If Else Chains with Switch
Joseph
@revisualize
Aug 30 2016 01:41
Ahh.
I did that one before it changed.
I'm going to do it again.
:)
Cage Echarte
@CageEcharte
Aug 30 2016 01:41
@revisualize name of the exercise...Replacing If Else Chains with Switch
greg
@wearenotgroot
Aug 30 2016 01:45

@CageEcharte just remove the ----> (val === 1) on the cases also update the value for the cases
exmaple

case 3: (val === 1)
answer = "There is no #1";

should be

case 1:  //that value is compared to val
  answer = "There is no #1";
  break;
Joseph
@revisualize
Aug 30 2016 01:45
@CageEcharte Done.
Thanks.
Switches generally don't have evaluations in them.
Antonio Jovanovic
@supamerz
Aug 30 2016 01:48

@Egoscio Imagine when you try to solve problems you don't yet have :) Thanks again. Here's what I came up with: ```js
function updateRecords(id, prop, value) {

if(prop != "tracks" && value != ''){
    collection[id][prop] = value;
}
else if (prop === "tracks" && collection[id][prop] === undefined) {
    collection[id][prop] = [];
    collection[id][prop].push(value);
} else if (prop === "tracks" && value != ""){
    collection[id][prop].push(value);
} else if (value === ''){
    delete collection[id][prop];
}

    return collection;

}
```

CamperBot
@camperbot
Aug 30 2016 01:48
supamerz sends brownie points to @egoscio :sparkles: :thumbsup: :sparkles:
:cookie: 37 | @egoscio |http://www.freecodecamp.com/egoscio
Margaret
@Margaret2
Aug 30 2016 01:48
@revisualize so have you completed all the front-end challenges?
Mike
@SaxManMike
Aug 30 2016 01:51
Hey all, I'm running into some interesting issues with the weather app challenge. Apparently you have to use https to use location services for latitude and longitude, but OpenWeatherAPI can only be called on an unsecured http protocol
Has anyone else run into this issue?
Kevin Su
@barberkevinsu
Aug 30 2016 01:51
Hey guys! Can someone tell me how to compare the value of a property in two Objects?
greg
@wearenotgroot
Aug 30 2016 01:52
@SaxManMike you can use other api to get location of the user
Alejandro Perez
@alejitopm90
Aug 30 2016 01:52
Hi @SaxManMike I already have some code with the openweather
Kevin Su
@barberkevinsu
Aug 30 2016 01:52
if(collection[i].hasOwnProperty(arr[j])===true){
if(collection[i].arr[j]!==source.arr[j]){
check=false;
break;
}
}
Joseph Halvarson
@joehalvarson
Aug 30 2016 01:53
Good evening from where I am, I'm continuing to have some trouble with Profile Lookup. I can't get my for loop to try each [i] before exiting the function.
Alejandro Perez
@alejitopm90
Aug 30 2016 01:53
You can go through the official website and with your api key you will find the JSON information. @SaxManMike
Kevin Su
@barberkevinsu
Aug 30 2016 01:54
Here, my arr[j] is the property name, but my two objects(collection[i], source) can not be compared, why is that?
Joseph Halvarson
@joehalvarson
Aug 30 2016 01:54
  for (i = 0; i <= contacts.length; i++) {
    if (firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop) === true) {
      return contacts[i][prop];
    }  else if (firstName !== contacts[i].firstName) {
    return "No such contact";
  } else if (contacts[i].hasOwnProperty(prop) === false) {
    return "No such property";
  }
}
greg
@wearenotgroot
Aug 30 2016 01:54
@joehalvarson that depends on where you place your return statements(return "No such contact" is the most common culprit)
Mike
@SaxManMike
Aug 30 2016 01:54
@alejitopm90 How would I do that? I'm finding instruction on API calls lacking...
Joseph Halvarson
@joehalvarson
Aug 30 2016 01:55
Yeah, I know I have it incorrect. I've tried moving things around, and tried some more complex arrangements of for loops, but I just can't seem to break through on what I'm doing incorrectly.
Alejandro Perez
@alejitopm90
Aug 30 2016 01:55
First you have to creat an account in the official website
Mike
@SaxManMike
Aug 30 2016 01:55
Done
Alejandro Perez
@alejitopm90
Aug 30 2016 01:55
Then go to the api key
Mike
@SaxManMike
Aug 30 2016 01:56
Acquired
Alejandro Perez
@alejitopm90
Aug 30 2016 01:56
Copy it and then paste it at the final of your url ... @SaxManMike
Haseeb Qureshi
@Haseeb-Qureshi
Aug 30 2016 01:56
@joehalvarson the first thing you can do to make this simpler is to assign contacts[i] to a variable
Mike
@SaxManMike
Aug 30 2016 01:56
Done
Haseeb Qureshi
@Haseeb-Qureshi
Aug 30 2016 01:56
so, say contact = contacts[i]
Alejandro Perez
@alejitopm90
Aug 30 2016 01:57
@SaxManMike finally include it in your .ajax function.
Mike
@SaxManMike
Aug 30 2016 01:57
I don't have a .ajax function or knowledge on how to build one
greg
@wearenotgroot
Aug 30 2016 01:57
@joehalvarson the easiest solution to the problem cause by return "No such contact" is to not have it inside the loop
Joseph Halvarson
@joehalvarson
Aug 30 2016 01:57
@wearenotgroot I also tried to add an additional condition to my else if statements to hopefully make it crawl through the rest of the for loop before deciding we hit an end, but no dice.
Alejandro Perez
@alejitopm90
Aug 30 2016 01:58
Let me search a good tutorial.
Haseeb Qureshi
@Haseeb-Qureshi
Aug 30 2016 01:58
@joehalvarson it's not about adding more code, but rather taking some away. :)
Lokendra Puri
@lokenpuri
Aug 30 2016 01:58
hello guys
i'm stuck here at
Adding a default option in Switch statements
plz help
Haseeb Qureshi
@Haseeb-Qureshi
Aug 30 2016 01:58
presumably you want to look over all of the contacts before you decide that no such contact exists, right?
Lokendra Puri
@lokenpuri
Aug 30 2016 01:58

this is my code
switch(val){
case "a":
answer="apple";
break;

case "b":
  answer="bird";
  break;

case "c":
  answer="cat";
  break;

default:
  answer="stuff";
  break;

}

Haseeb Qureshi
@Haseeb-Qureshi
Aug 30 2016 01:59
so you should never make that decision inside of the for loop
right now your decision making is inside of the for loop, but it should be after the for loop
Lokendra Puri
@lokenpuri
Aug 30 2016 01:59
anyone therere??
Alejandro Perez
@alejitopm90
Aug 30 2016 01:59
Haseeb Qureshi
@Haseeb-Qureshi
Aug 30 2016 02:00
@lokenpuri your code is correct
there's no problem with it. it works correctly.
Alejandro Perez
@alejitopm90
Aug 30 2016 02:01
I recommend you, just learn the ajax part. Then try to solve the challenge with your knowledge.. @SaxManMike
Lokendra Puri
@lokenpuri
Aug 30 2016 02:01
but it's not showing correct
Joseph Halvarson
@joehalvarson
Aug 30 2016 02:01
@Haseeb-Qureshi I appreciate the advice on adding a variable. Also @wearenotgroot that makes sense to move the check outside the loop (and Haseeb). Let me see if I can figure that out.
Margaret
@Margaret2
Aug 30 2016 02:02
@lokenpuri do not need break after default
Lokendra Puri
@lokenpuri
Aug 30 2016 02:02
still not happening @Margaret2
Mike
@SaxManMike
Aug 30 2016 02:03
Thanks @alejitopm90
CamperBot
@camperbot
Aug 30 2016 02:03
saxmanmike sends brownie points to @alejitopm90 :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @alejitopm90 |http://www.freecodecamp.com/alejitopm90
Alejandro Perez
@alejitopm90
Aug 30 2016 02:03
@SaxManMike you're welcome.
Margaret
@Margaret2
Aug 30 2016 02:03
@lokenpuri do you still have the return statement at the bottom and the var statement at the top?
Stephen James
@sjames1958gm
Aug 30 2016 02:04
@lokenpuri Post the entire function
Joban Kang
@kingkang17
Aug 30 2016 02:05

var myVar = 87;

// Only change code below this line
myVar = myVar++;

greg
@wearenotgroot
Aug 30 2016 02:05
@lokenpuri are these still there

function switchOfStuff(val) {
  var answer = "";        //<-----needed
  // Only change code below this line
  switch(val)
  {
   ....
  }
  // Only change code above this line  
  return answer;  //<----needed
}
Joban Kang
@kingkang17
Aug 30 2016 02:05
it says its wrong
greg
@wearenotgroot
Aug 30 2016 02:06

@kingkang17 try

myVar++;

docs on operators
operators

Margaret
@Margaret2
Aug 30 2016 02:06
@kingkang17 just myVar++;
don't need the first part of the expression
Joban Kang
@kingkang17
Aug 30 2016 02:07
@wearenotgroot thanks I got it
CamperBot
@camperbot
Aug 30 2016 02:07
kingkang17 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1507 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Joban Kang
@kingkang17
Aug 30 2016 02:07
@Margaret2 thanks
CamperBot
@camperbot
Aug 30 2016 02:07
kingkang17 sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 356 | @margaret2 |http://www.freecodecamp.com/margaret2
Egoscio
@Egoscio
Aug 30 2016 02:07
@supamerz Génial! Is that working for you?
greg
@wearenotgroot
Aug 30 2016 02:08
@kingkang17 read the docs operators
Lokendra Puri
@lokenpuri
Aug 30 2016 02:08
wy these black area is not coming
Margaret
@Margaret2
Aug 30 2016 02:09
@lokenpuri ``` before and after your code
Bianca Morris
@Bianca-Morris
Aug 30 2016 02:10
Hey all, does anyone know a good way to hide or secure an api key? I'm building a website, and I wanted to use an api that requires a key. But if I just put the key in the javascript (like in the Front End Dev api projects), it's basically usable by anyone with developer tools, which seems unsafe... any ideas?
Norvin Burrus
@ndburrus
Aug 30 2016 02:10
@lokenpuri '''
CamperBot
@camperbot
Aug 30 2016 02:10
:bulb: to format code use backticks! ``` more info
Joseph
@revisualize
Aug 30 2016 02:10
@Margaret2 I have not completed all of the Front End Challenges. I do not have my Front End Cert.
Margaret
@Margaret2
Aug 30 2016 02:11
@revisualize me neither... yet
Austin Law
@alaw989
Aug 30 2016 02:11
anyone willing to help me with 'Slasher Flick' Basic Algoritithm?
Bianca Morris
@Bianca-Morris
Aug 30 2016 02:11
Thanks a lot @ndburrus, I'll take a look at that!
CamperBot
@camperbot
Aug 30 2016 02:11
bianca-morris sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star2: 1967 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Aug 30 2016 02:12
@Bianca-Morris you're welcome! enjoy! :palm_tree:
Joseph
@revisualize
Aug 30 2016 02:12
@alaw989 What is your current function?
greg
@wearenotgroot
Aug 30 2016 02:13
goin to catch some :zzz: Good luck and Happy coding everyone!!
Austin Law
@alaw989
Aug 30 2016 02:13
@revisualize
```
Joseph
@revisualize
Aug 30 2016 02:13
Sweet function.
Austin Law
@alaw989
Aug 30 2016 02:13

@revisualize

function slasher(arr, howMany) {
 var newArr =  arr.slice(0, howMany);
  return newArr;
}

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

this is all i have so far

Lokendra Puri
@lokenpuri
Aug 30 2016 02:13

'''
function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch(val){
case "a":
answer="apple";
break;

case "b":
  answer="bird";
  break;

case "c":
  answer="cat";
  break;

default:
  answer="stuff";

}

// Only change code above this line
return answer;
}

// Change this value to test
switchOfStuff(a);'''

CamperBot
@camperbot
Aug 30 2016 02:13
:bulb: to format code use backticks! ``` more info
Austin Law
@alaw989
Aug 30 2016 02:14
i've slashed the howMany off the head of the array but not sure how to return the remaining characters in the array
Anthony Drane
@Antiaccess
Aug 30 2016 02:14
I'm having trouble seeing why this isn't working (building the basic functionality of the random quote generator):
var quote = [];
var tweet = ""
var quotes = [["quote1", "author1"], ["quote2", "author2"], ["quote3", "author3"], ["quote4", "author4"], ["quote5", "author5"], ["quote6", "author6"], ["quote7", "author7"], ["quote8", "author8"], ["quote9", "author9"], ["quote10", "author10"]];

function generateQuote(){
  var number = Math.floor((Math.random()*10) + 1);
  quote = [quotes[number[0]], quotes[number[1]]];
}

$(document).ready(function() {
  $("#genQuote").on("click", function() {
    generateQuote();
      $(".quote").html(quote[0]);
      $(".author").html(quote[1]);
  });
});
can anyone help?
Joseph
@revisualize
Aug 30 2016 02:15
@alaw989 Oh, That one.. You realize that the answer is on the Slice documentation.
Norvin Burrus
@ndburrus
Aug 30 2016 02:15
@Bianca-Morris :point_up: comment/s updated! :+1:
greg
@wearenotgroot
Aug 30 2016 02:15

@lokenpuri

switchOfStuff(a);//<-------a should be in quote otherwise js will think its a variable

anywys cyas

Margaret
@Margaret2
Aug 30 2016 02:15
@alaw989 arr.splice(), not slice
Austin Law
@alaw989
Aug 30 2016 02:15
@revisualize no i do not realize that
Joseph
@revisualize
Aug 30 2016 02:16
@Margaret2 .slice()
Lokendra Puri
@lokenpuri
Aug 30 2016 02:17
@wearenotgroot thanx
CamperBot
@camperbot
Aug 30 2016 02:17
lokenpuri sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1508 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Joseph
@revisualize
Aug 30 2016 02:17
@alaw989 In fact, it is in the Parameters documentation.
Margaret
@Margaret2
Aug 30 2016 02:17
@revisualize seriously i solved it with splice, very simple
Lokendra Puri
@lokenpuri
Aug 30 2016 02:17
and thanks to everyone
Joseph
@revisualize
Aug 30 2016 02:18
@Margaret2 I solved it with slice. ... Really simple.
Margaret
@Margaret2
Aug 30 2016 02:18
:D
ah well, i guess he needs slice since he is using a var
Stephen James
@sjames1958gm
Aug 30 2016 02:20
@Antiaccess number is a number but you are accessing it like an array
quote = [quotes[number][0], quotes[number][1]];
Anthony Drane
@Antiaccess
Aug 30 2016 02:22

@sjames1958gm okay if I changed it to .push like this:

  quote = [];
  quote.push[quotes[num]];

would that work, or is it the same problem?

Stephen James
@sjames1958gm
Aug 30 2016 02:22
@Antiaccess That should work
@Antiaccess Just have to watch that each click you are not growing your quote array, looks like you mean to reset to [] which is good
Milan
@bigboyprojects
Aug 30 2016 02:23
Hi everybody! I learned HTML/CSS last night and completed the track. Been doing some work and trying to get the fundamentals of programming of Javascript in. Where do you suggest I start? Do you think that FreeCodeCamp is a better option compared to TeamTreeHouse, Lynda, CodeAcademy or Learn.co (Flatiron School)? Thanks to my school I have access to all of those and I would really like your opinions!
Vishon
@Symbolistic
Aug 30 2016 02:26
guys i got a problem with the algorithm challenge. "Where do I belong", I got everything working good, except the .sort, its not sorting the array so the 2 things i got wrong are due to it not being sorted. Here is my code

function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  arr = arr.sort();
  var lowestNum = 0;

  for(i=0;i<arr.length;i++){
    var highestNum = arr[i];

    if(num > lowestNum && num <= highestNum){
      return arr.indexOf(highestNum);
    }

    else if(num == lowestNum){
      return arr.indexOf(lowestNum);
    }

    else{
      lowestNum = arr[i];
    }


  }
  return arr;
}

getIndexToIns([5, 3, 20, 3], 5);
Margaret
@Margaret2
Aug 30 2016 02:26
@bigboyprojects Codecademy covers more languages, but quality is not as good. I don't know about the others. also check out codewars.com if you like a good challenge
Austin Law
@alaw989
Aug 30 2016 02:27
function slasher(arr, howMany) {
 var newArr =  arr.slice(howMany);
  return newArr;
}

slasher([1, 2, 3], 2);
wow, it was so easy
@revisualize thanks for nudging me in the right direction, but not really
CamperBot
@camperbot
Aug 30 2016 02:27
alaw989 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1764 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 30 2016 02:28
@alaw989 You know.. You don't need to create a new variable. You can just return the thing.
Milan
@bigboyprojects
Aug 30 2016 02:29
Ok. I’m getting the fundamentals of JavaScript in at the moment. I’m applying for a scholarship at a Web Dev bootcamp in California soon and they’ll send me a coding challenge for javascript. So I’m learning it and polishing it right now. So you’re saying that FreeCodeCamp is good for JavaScript? Is there anything I should move to after that? A friend of mine told me that the challenge he had at his tech interview was about “recursion” (im still not there yet) @Margaret2 @everybodyelse
Austin Law
@alaw989
Aug 30 2016 02:29
@revisualize ok thx
CamperBot
@camperbot
Aug 30 2016 02:29
alaw989 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: alaw989 already gave revisualize points
Margaret
@Margaret2
Aug 30 2016 02:30
@Symbolistic you have to use a function to sort the array: arr.sort(function(...){ .... })
Austin Law
@alaw989
Aug 30 2016 02:30
@bigboyprojects to understand recursion, you have to understand recursion
Margaret
@Margaret2
Aug 30 2016 02:30
@alaw989 lol
Gang Zhao
@crumpx
Aug 30 2016 02:31
lol
Milan
@bigboyprojects
Aug 30 2016 02:31
@alaw989 that’s an inside joke i don’t get yet. any actual advice?
Vishon
@Symbolistic
Aug 30 2016 02:32
@Margaret2 thank you.
CamperBot
@camperbot
Aug 30 2016 02:32
symbolistic sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 358 | @margaret2 |http://www.freecodecamp.com/margaret2
Milan
@bigboyprojects
Aug 30 2016 02:33
@Margaret2 thank you for the advice for codewars. i’ll check it out
CamperBot
@camperbot
Aug 30 2016 02:33
bigboyprojects sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 359 | @margaret2 |http://www.freecodecamp.com/margaret2
Gang Zhao
@crumpx
Aug 30 2016 02:33
keep calling itself until the world ends
Egoscio
@Egoscio
Aug 30 2016 02:34
@crumpx With a good setup, it would kill the process before spawning in a blackhole ;)
Jeanine Schoessler
@virtual
Aug 30 2016 02:35
@bigboyprojects My teacher printed out the same function on a bunch of pieces of paper and since it called itself, you kept adding another "paper function" on top until it was able to start returning, then we'd take the paper function off and do the next return; I felt it got the point across although a bit of a waste of paper lol
Gang Zhao
@crumpx
Aug 30 2016 02:36
@bigboyprojects it's basically a algorithm question he got. you'll get to it it's pretty popular in any examples learning any languages
Margaret
@Margaret2
Aug 30 2016 02:36
@bigboyprojects i would give you more advice, but I haven't really tried other programs besides FCC. I recommend reading as much as you can (books, blogs...) and practicing by building your own projects as much as you can. I still don't understand recursion very well myself... but enough to get the joke :)
Milan
@bigboyprojects
Aug 30 2016 02:39
@crumpx @Margaret2 @virtual hahaha ok. I wasn’t looking to understand recursion, just to be pointed in the right direction so I can learn it. I wasn’t sure if it was a concept from javascript or something else. I’m about to do the javascript track but after that (because gang told me it’s an algorithm q) I’ll maybe check out the basic algorithm scripting track on FCC too. Thank you guys :)
CamperBot
@camperbot
Aug 30 2016 02:39
bigboyprojects sends brownie points to @crumpx and @margaret2 and @virtual :sparkles: :thumbsup: :sparkles:
:cookie: 319 | @virtual |http://www.freecodecamp.com/virtual
:warning: bigboyprojects already gave margaret2 points
:cookie: 272 | @crumpx |http://www.freecodecamp.com/crumpx
Vishon
@Symbolistic
Aug 30 2016 02:39
ok guys i got another issue.... with "where do i belong", i got literally everything working except 1 problem....
Milan
@bigboyprojects
Aug 30 2016 02:39
@Margaret2 Do you have any blogs/books to recommend btw?
Vishon
@Symbolistic
Aug 30 2016 02:39
getIndexToIns([2, 5, 10], 15) should return 3.

function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var answer;
  arr = arr.sort(function (a,b){
    return a-b;
  });
  var lowestNum = 0;

  for(i=0;i<arr.length;i++){
    var highestNum = arr[i];

    if(num > lowestNum && num <= highestNum){
      return arr.indexOf(highestNum);
    }

    else if(num == lowestNum){
      return arr.indexOf(lowestNum);
    }


    else{
      lowestNum = arr[i];
    }


  }
  return answer;
}

getIndexToIns([2, 5, 10], 15);
that is my code
i tried adding in
Gang Zhao
@crumpx
Aug 30 2016 02:40
@Symbolistic wow you made lot progress :D
Vishon
@Symbolistic
Aug 30 2016 02:40
    else if(num > lowestNum && num > highestNum){
      return arr.indexOf(highestNum);
    }
i tried to add that but it messes everything up sadly
@crumpx yeah lol ty. been working at it all day
CamperBot
@camperbot
Aug 30 2016 02:41
symbolistic sends brownie points to @crumpx :sparkles: :thumbsup: :sparkles:
:cookie: 273 | @crumpx |http://www.freecodecamp.com/crumpx
Vishon
@Symbolistic
Aug 30 2016 02:41
the reason that extra code messes everything up is because that code becomes true from the start of the loop...
i am not sure how to get around it
llamatarianism
@llamatarianism
Aug 30 2016 02:42
@Symbolistic you're waaaaaaaaaaaaay overcomplicating this
why not just check where num is
Vishon
@Symbolistic
Aug 30 2016 02:42
@llamatarianism i always over complicate everything =( lol its a bad habit....
Gang Zhao
@crumpx
Aug 30 2016 02:42
it's like that. so you have an array, and a number you try to put in. first thing first, you want to know if the number is already in your array . if not, ok, you can put that number in that array, and you sort it, and use indexOf(num) to find out where it is in the array..
so you don't need those highestNum and lowestNum
when you put that number in the array, it will automatically tell you where it is, of course after you sort it.
Vishon
@Symbolistic
Aug 30 2016 02:45
yeah i figured there would be a much easier way to do it. But my stupid mind works in such a weird way, i always over complicate everything i do. I think for every single algorithm i have done so far I started by making a huge mess of code that ended up working somehow.
llamatarianism
@llamatarianism
Aug 30 2016 02:45
@Symbolistic note: you can do this without sorting the array, which would make it faster. sorting is pretty slow (I think Array.prototype.sort is O(n×log(n))O(n \times log(n)), whereas you can do this problem in O(n)O(n))
Margaret
@Margaret2
Aug 30 2016 02:45
@bigboyprojects i PM'ed you. let me know if you got it
Vishon
@Symbolistic
Aug 30 2016 02:46
whats sad is i got it working with this...

function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var answer=4;
  arr = arr.sort(function (a,b){
    return a-b;
  });
  var lowestNum = 0;

  for(i=0;i<arr.length;i++){
    var highestNum = arr[i];

    if(num > lowestNum && num <= highestNum){
      return arr.indexOf(highestNum);
    }

    else if(num == lowestNum){
      return arr.indexOf(lowestNum);
    }


    else{
      lowestNum = arr[i];
    }


  }

  answer = arr.length;
  return answer;
}

getIndexToIns([2, 5, 10], 15);
Behold, my huge mess of code!!!!
it works but its a mess!!!
Gang Zhao
@crumpx
Aug 30 2016 02:47
wanna see my code? :P
Vishon
@Symbolistic
Aug 30 2016 02:47
lol sure
Alexander Køpke
@alexanderkopke
Aug 30 2016 02:47
what is important is it works
Vishon
@Symbolistic
Aug 30 2016 02:47
im gonna redo the challenge and try to do the shorter version
Gang Zhao
@crumpx
Aug 30 2016 02:47
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.

 if (arr.indexOf(num) == -1){
    arr.push(num);
  }

  return arr.sort(function(a, b){
    return a - b;
  }).indexOf(num); 

}
getIndexToIns([3, 10, 5], 3);
Vishon
@Symbolistic
Aug 30 2016 02:47
bruh
Gang Zhao
@crumpx
Aug 30 2016 02:48
opps..
Vishon
@Symbolistic
Aug 30 2016 02:48
XDDDDD
i asked
xD
wow that is way smaller than my code
llamatarianism
@llamatarianism
Aug 30 2016 02:48
that's the O(n×log(n))O(n \times log(n)) solution though
Margaret
@Margaret2
Aug 30 2016 02:48
@crumpx yeah, that's basically mine
Alexander Køpke
@alexanderkopke
Aug 30 2016 02:48
so what is the purpose.. find the index in arr of num?
Gang Zhao
@crumpx
Aug 30 2016 02:48
i think someone can come up with something shorter
llamatarianism
@llamatarianism
Aug 30 2016 02:48
function getIndexToIns(arr, num) {
  return arr.filter(function(x) {
    return x < num;
  }).length;
}
shorter (esp with arrow functions) and O(n)O(n)
Gang Zhao
@crumpx
Aug 30 2016 02:49
i knew it :D
Vishon
@Symbolistic
Aug 30 2016 02:49
o____o
Margaret
@Margaret2
Aug 30 2016 02:49
@llamatarianism dude no way! :+1:
Vishon
@Symbolistic
Aug 30 2016 02:49
how do you guys even come up with this, there is no way you came up with that on your first run with the algorithms
llamatarianism
@llamatarianism
Aug 30 2016 02:49
not on the first run
my first try was like, exactly the same as @crumpx's :P
I came up with that earlier today
Vishon
@Symbolistic
Aug 30 2016 02:49
well good to know im behind you guys by a decade.
llamatarianism
@llamatarianism
Aug 30 2016 02:50
don't feel bad man
I used to suck too
Vishon
@Symbolistic
Aug 30 2016 02:50
xD
Margaret
@Margaret2
Aug 30 2016 02:50
@Symbolistic break it down into steps, think what is the most efficient way i can accomplish this first step...
llamatarianism
@llamatarianism
Aug 30 2016 02:50
I used to be all "duh what's a recursion"
Gang Zhao
@crumpx
Aug 30 2016 02:50
@llamatarianism haha i knew it is not the best one, i don't like the push part
Jeanine Schoessler
@virtual
Aug 30 2016 02:50
function updateInventory(arr1, arr2) {
  var holdem = [];
      function addCounts(inarray) {
      for (var i = 0; i < inarray.length; i++) {
        var h = 0;
        while (h < inarray[i][0]) {
          holdem.push(inarray[i][1]);
          h++;
        }
      }
    }

    // All inventory must be accounted for or you're fired!  
  addCounts(arr1);
  addCounts(arr2);
  //return holdem;
  var mew = countem(holdem);

 holdem = [];

  Object.getOwnPropertyNames(mew).forEach(function(val, idx, array) {
  holdem.push(new Array(mew[val], val));
});

  holdem.sort(function(a,b) {
    return a[1]> b[1];
  });

  return holdem;

}
function countem(allthethings) {
  //return allthethings;
  var temp = allthethings.reduce(function(acc, cur) {
    if (acc[cur]) {
      acc[cur] += 1;
    } else {
      acc[cur] = 1;
    }
    return acc;
  },{});
  return temp;
}
// Example inventory lists
updateInventory([[0, "Bowling Ball"], [0, "Dirty Sock"], [0, "Hair Pin"], [0, "Microphone"]], [[1, "Hair Pin"], [1, "Half-Eaten Apple"], [1, "Bowling Ball"], [1, "Toothpaste"]]);
Hi, I'm trying to do Inventory Update with Reduce; it passes everything except for the last criteria which requires arrays with 0 values. Does anyone know if this is possible using the reduce function?
llamatarianism
@llamatarianism
Aug 30 2016 02:50
@crumpx you could use concat
arr.concat(num).sort(...
would also avoid mutating arr with sort
Vishon
@Symbolistic
Aug 30 2016 02:51
crumpx's way seemed easy as heck, i am surprised I didn't do it that way on the first try.
but everytime i see a problem, i automatically think (if/else statements and loops)
those are the first things that pop into my head
@Margaret2 i've been trying that but i guess i need more experience till i can make more efficient code.
Gang Zhao
@crumpx
Aug 30 2016 02:53
@llamatarianism thanks, good to know, i actually never used concat before...
CamperBot
@camperbot
Aug 30 2016 02:53
crumpx sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1305 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Margaret
@Margaret2
Aug 30 2016 02:53
keep practicing and you will get better and better!!! @Symbolistic
Gang Zhao
@crumpx
Aug 30 2016 02:53
gonna save your answer :D
Margaret
@Margaret2
Aug 30 2016 02:54
@Symbolistic also stack overflow can help you find cool new ways to write functions
Alexander Køpke
@alexanderkopke
Aug 30 2016 02:54
I don't like push either. It seems so pushy ;) On the other hand, when you use concat everything really comes together.
Vishon
@Symbolistic
Aug 30 2016 02:54
@Margaret2 I gotta start looking at stack overflow more.
Margaret
@Margaret2
Aug 30 2016 02:55
I actually asked my first question on SO today. I would like to start answering questions, but I feel like such a noob it's hard to do
Vishon
@Symbolistic
Aug 30 2016 02:56
i've been asking questions all day today probably annoying everyone.
lol
but i didnt on SO yet
Margaret
@Margaret2
Aug 30 2016 02:57
haha
Vishon
@Symbolistic
Aug 30 2016 02:57
does anyone here work a web development job?
Egoscio
@Egoscio
Aug 30 2016 02:57
Just make sure nobody asked your question before on SO. They get salty if it's already there :P
Margaret
@Margaret2
Aug 30 2016 02:57
be careful about annoying the people on stack overflow, they don't like duplicate questions, that's why i never asked one until today
Egoscio
@Egoscio
Aug 30 2016 02:58
lol
Margaret
@Margaret2
Aug 30 2016 02:58
@Egoscio great minds think alike
Vishon
@Symbolistic
Aug 30 2016 02:58
i always google before i ask, youtube also
Egoscio
@Egoscio
Aug 30 2016 02:58
:D
Vishon
@Symbolistic
Aug 30 2016 02:58
and then ill come here and ask lol
llamatarianism
@llamatarianism
Aug 30 2016 02:58
and make sure nobody asked a remotely similar question
even one that is unrelated but just happened to use similar words
Vishon
@Symbolistic
Aug 30 2016 02:58
lmao
llamatarianism
@llamatarianism
Aug 30 2016 02:58
else you're s### outta luck
Margaret
@Margaret2
Aug 30 2016 02:59
I guess just make sure its very specific to your situation
Joseph Parkton
@hippybear
Aug 30 2016 03:01
@Egoscio Im gonna downvote your comment
Egoscio
@Egoscio
Aug 30 2016 03:01
One skill that I find useful is to stretch your understanding of programming languages, because algorithms are pretty generic sometimes. If you have a Javascript algo question, chances are a C-type or java answer can help effectively.
wusup yos?
Gang Zhao
@crumpx
Aug 30 2016 03:01
function getIndexToIns(arr, num) {
  return arr.filter(function(x) {
    return x < num;
  });
}
so pretty lol I would never thought of this
Joseph Parkton
@hippybear
Aug 30 2016 03:01
Plus Js is a C based language so the code snippets translate pretty easily
Margaret
@Margaret2
Aug 30 2016 03:01
have to say though re: SO, I actually got a really good answer from someone. I'm impressed with the people who can somehow sit around all day and rewrite other people's functions
for free
Egoscio
@Egoscio
Aug 30 2016 03:02
Could pretty much copy/paste sometimes from one language to another if you're lucky
But don't depend on it
Joseph Parkton
@hippybear
Aug 30 2016 03:02
Or google a code translator!
Egoscio
@Egoscio
Aug 30 2016 03:02
:O
Margaret
@Margaret2
Aug 30 2016 03:03
have any you recommend @hippybear
Egoscio
@Egoscio
Aug 30 2016 03:03
Well, Google likes to javify everything. Maybe it might not be the most efficient implementation if it's fully automatic.
I heard someone say they like to write their JS and C++ like Java too.
Joseph Parkton
@hippybear
Aug 30 2016 03:07
eventually you can write it pretty close to C
once you get into Classes and public v private it starts to look exactly like C again
llamatarianism
@llamatarianism
Aug 30 2016 03:07
C don't have classes yo
you mean C++?
Egoscio
@Egoscio
Aug 30 2016 03:07
^
Joseph Parkton
@hippybear
Aug 30 2016 03:12
maybe?
I mean more the way the OOP
er.. you know? it is but it isnt?
Objective oriented C, credits to stackoverflow (they posted the link)
llamatarianism
@llamatarianism
Aug 30 2016 03:20
@hippybear that's C++
aside from the fact it has classes, which C doesn't
it would be #include <stdio.h> in C
not #include <iostream>
Angel J Piscola
@Redmega
Aug 30 2016 03:21
function spinalCase(str) {
  return str.replace(/([a-z])(?=[A-Z])|(?:[_ -])/g,'$1-').toLowerCase();
}
Can't think of a way to make that regex cleaner
llamatarianism
@llamatarianism
Aug 30 2016 03:22
meh it's regex
they're not exactly known for cleanliness
Angel J Piscola
@Redmega
Aug 30 2016 03:22
I"m sure I'm missing an easier way to check for the character before/after a camelcase
llamatarianism
@llamatarianism
Aug 30 2016 03:22
nah, ([a-z])(?=[A-Z]) is pretty much the easiest way
@hippybear std::cout << "this is a private method" << std::endl; is pure C++
in C it'd be printf("this is a private method");
Angel J Piscola
@Redmega
Aug 30 2016 03:24
Why are we talking about c++ in the HelpJavascript room? xD
Joseph Parkton
@hippybear
Aug 30 2016 03:24
I have much to learn
I have to take C and Java this coming semester, I dont think im ready lol
llamatarianism
@llamatarianism
Aug 30 2016 03:24
java ain't too hard
kinda annoying but not that bad
C is kinda egh but also kinda nice
Joseph Parkton
@hippybear
Aug 30 2016 03:25
Im only looking forward to it cause after that I can help on some good projects like some irc daemons and i2p
Angel J Piscola
@Redmega
Aug 30 2016 03:25
Java can get annoying but I find it so easy to use and master..
Joseph Parkton
@hippybear
Aug 30 2016 03:25
although i2p has a python port sorta?
Angel J Piscola
@Redmega
Aug 30 2016 03:25
Almost anything you want to do, there's a library or core functionality for it
llamatarianism
@llamatarianism
Aug 30 2016 03:25
@Redmega I reeeeally just don't like how verbose it is
Egoscio
@Egoscio
Aug 30 2016 03:25
Guys. The savior has come. Convert to Swift and save lives today
llamatarianism
@llamatarianism
Aug 30 2016 03:25
also the type system is kinda egh
Joseph Parkton
@hippybear
Aug 30 2016 03:26
Yeah but it isnt installed standard on most nix platforms
llamatarianism
@llamatarianism
Aug 30 2016 03:26
@Egoscio meh. apple.
Angel J Piscola
@Redmega
Aug 30 2016 03:26
Yeah thats the only thing. Java 8 helps with that somewhat, though, and intellisense.. xD
Joseph Parkton
@hippybear
Aug 30 2016 03:26
Java is still the top language in the industry even though its poop
Egoscio
@Egoscio
Aug 30 2016 03:27
@llamatarianism Bruh it's serverside now on linux. don't even need apple
Joseph Parkton
@hippybear
Aug 30 2016 03:27
just like IE is the default browser in every single company ever and its garbage
Angel J Piscola
@Redmega
Aug 30 2016 03:27
It's code once, run and debug everywhere @hippybear
llamatarianism
@llamatarianism
Aug 30 2016 03:27
@Egoscio well yeah you do need apple
cuz it's made by apple
Egoscio
@Egoscio
Aug 30 2016 03:27
nerp.
llamatarianism
@llamatarianism
Aug 30 2016 03:27
yarp.
Angel J Piscola
@Redmega
Aug 30 2016 03:27
They have server side swift now
Egoscio
@Egoscio
Aug 30 2016 03:27
^
llamatarianism
@llamatarianism
Aug 30 2016 03:27
and?
Egoscio
@Egoscio
Aug 30 2016 03:27
It's open sourced.
llamatarianism
@llamatarianism
Aug 30 2016 03:27
the language is still made by apple
Angel J Piscola
@Redmega
Aug 30 2016 03:27
Joseph Parkton
@hippybear
Aug 30 2016 03:27
ehrmehgerd?
llamatarianism
@llamatarianism
Aug 30 2016 03:27
without apple, the language would not exist
Egoscio
@Egoscio
Aug 30 2016 03:27
Joseph Parkton
@hippybear
Aug 30 2016 03:27
I get to take ios development and android development too
llamatarianism
@llamatarianism
Aug 30 2016 03:27
I know it's open source, I know it's available on linux
Joseph Parkton
@hippybear
Aug 30 2016 03:27
kinda stocked for those
Egoscio
@Egoscio
Aug 30 2016 03:27
perfect is so so
llamatarianism
@llamatarianism
Aug 30 2016 03:28
but it was still made by apple, and it's still mainly used for ios dev
Joseph Parkton
@hippybear
Aug 30 2016 03:28
make stupid time sucker games and collect monies
Angel J Piscola
@Redmega
Aug 30 2016 03:28
Yeah theres no questioning that
@Egoscio That website is beautiful
Joseph Parkton
@hippybear
Aug 30 2016 03:28
plus apple is like Linuxs younger "special" little brother
move away
Egoscio
@Egoscio
Aug 30 2016 03:29
I know right. The code is even better. It's like writing code for Express (node.js)
Angel J Piscola
@Redmega
Aug 30 2016 03:29
Gotta disagree with you there, apple's not going anywhere for a long while
Yeah I can see that. But... Droplet? Did they look at digital ocean? lol
Joseph Parkton
@hippybear
Aug 30 2016 03:29
just because people like him doesnt mean he isnt special
Its just stolen code from a printer
Egoscio
@Egoscio
Aug 30 2016 03:29
Well it's deriving from the idea of Vapor, it's not related to DO though lol
Joseph Parkton
@hippybear
Aug 30 2016 03:30
rebranded and sold for 10k times the cost
Angel J Piscola
@Redmega
Aug 30 2016 03:30
drop.get("hello", String) { request, name in 
    return "Nice to meet you, \(name)."
}
I don't like that at all
the { request, name in
llamatarianism
@llamatarianism
Aug 30 2016 03:30
what a weird lambda syntax
Joseph Parkton
@hippybear
Aug 30 2016 03:30
kinda firebasey
lol
llamatarianism
@llamatarianism
Aug 30 2016 03:30
basically just the same as scala's
except in instead of =>
Angel J Piscola
@Redmega
Aug 30 2016 03:30
the { feels naked
Joseph Parkton
@hippybear
Aug 30 2016 03:31
rawr
Egoscio
@Egoscio
Aug 30 2016 03:31
app.get('hello/:name', (req, res) => {
    res.send(`Nice to meet you, \(req.params.name)`)
})
Joseph Parkton
@hippybear
Aug 30 2016 03:31
code nekkid!
Egoscio
@Egoscio
Aug 30 2016 03:31
^ that is node
(express specifically)
Angel J Piscola
@Redmega
Aug 30 2016 03:31
Yes but () => {} makes sense
Joseph Parkton
@hippybear
Aug 30 2016 03:31
yeah
express is baws
super simple
Egoscio
@Egoscio
Aug 30 2016 03:31
You don't understand Swift closures.
Angel J Piscola
@Redmega
Aug 30 2016 03:31
{ x,y in
}
doesn't
Egoscio
@Egoscio
Aug 30 2016 03:31
That's just one way of writing them
Joseph Parkton
@hippybear
Aug 30 2016 03:31
and then add in jade or hogan or some jazz and bam
Angel J Piscola
@Redmega
Aug 30 2016 03:31
That's true, I've never touched the language
llamatarianism
@llamatarianism
Aug 30 2016 03:31
List(1, 2, 3).foldLeft(0) { (acc, x) =>
  acc + x
}
pretty standard scala
Angel J Piscola
@Redmega
Aug 30 2016 03:31
Just saying from my inexperienced point of view
llamatarianism
@llamatarianism
Aug 30 2016 03:32
although for short funs like that, you'd just write (_ + _)
Angel J Piscola
@Redmega
Aug 30 2016 03:32
{() =>} is also foreign to me
Egoscio
@Egoscio
Aug 30 2016 03:32
It didn't to me at first, but when you understand how it infers types, you start to follow the philosophy.
Joseph Parkton
@hippybear
Aug 30 2016 03:32
ohawd
Angel J Piscola
@Redmega
Aug 30 2016 03:32
and this whole (){} is throwing me off too
llamatarianism
@llamatarianism
Aug 30 2016 03:32
meh. it can get weirder.
haskell looks like this:
Angel J Piscola
@Redmega
Aug 30 2016 03:32
No pls
runs away
llamatarianism
@llamatarianism
Aug 30 2016 03:32
\acc x -> acc + x
Egoscio
@Egoscio
Aug 30 2016 03:33
Personally, when I look at stuff like Haskell or Elixir, I scratch my head. But that's because I don't have experience with it.
llamatarianism
@llamatarianism
Aug 30 2016 03:33
the \ is supposed to look like a lambda
of course, taking this to its logical conclusion means writing this
,\ acc . ,\ x . acc + x
cuz it's gotta look like lambda calculus!
:P
Angel J Piscola
@Redmega
Aug 30 2016 03:33
Shoot me now
Is haskell/elixer used in the industry?
llamatarianism
@llamatarianism
Aug 30 2016 03:34
don't worry, I made up that last one
Angel J Piscola
@Redmega
Aug 30 2016 03:34
I've never seen job postings for them
llamatarianism
@llamatarianism
Aug 30 2016 03:34
@Redmega pinterest uses elixir
facebook uses haskell for fighting spam
Angel J Piscola
@Redmega
Aug 30 2016 03:34
For fighting spam..
llamatarianism
@llamatarianism
Aug 30 2016 03:34
and erlang is really commonly used
and that's what elixir's based on
facebook's chat thingy, whatsapp, and I think the servers to some games (I know one of the cod games used it)
all those use erlang
Angel J Piscola
@Redmega
Aug 30 2016 03:35
Huh.
TIL Facebook used to have its own language, FXL
Egoscio
@Egoscio
Aug 30 2016 03:35
I'm 100% sure whatsapp does. I saw a blog post about it
Angel J Piscola
@Redmega
Aug 30 2016 03:35
Facebook owns whatsapp now
This is an older post talking about their setup.
Angel J Piscola
@Redmega
Aug 30 2016 03:36
0.0% nice
Well that's not nice! :laughing:
llamatarianism
@llamatarianism
Aug 30 2016 03:36
NOT
ENOUGH
NINES
Joseph Parkton
@hippybear
Aug 30 2016 03:36
whatsapp is for dandies
and hipsters in steampunk
Angel J Piscola
@Redmega
Aug 30 2016 03:37
Of which you look like the latter... :tongue:
llamatarianism
@llamatarianism
Aug 30 2016 03:37
for real @Redmega elixir is just really pleasant
Angel J Piscola
@Redmega
Aug 30 2016 03:37
I'll check it out
Egoscio
@Egoscio
Aug 30 2016 03:37
Elixir and Erlang both run in the same VM
llamatarianism
@llamatarianism
Aug 30 2016 03:37
if you're used to JS's concurrency
or its weird attempt at it
erlang's concurrency is gonna be like a breath of fresh air
Egoscio
@Egoscio
Aug 30 2016 03:37
You can technically run code with equal efficiency. But Elixir is much more appealing syntactically imho
llamatarianism
@llamatarianism
Aug 30 2016 03:37
elixir takes that and removes all the grossness around the actual language
like . , ;
Angel J Piscola
@Redmega
Aug 30 2016 03:38
What does that statement mean...
llamatarianism
@llamatarianism
Aug 30 2016 03:38
and the problem of this:
X1 = some_fun(X0),
X2 = other_fun(X1),
X3 = another_fun(X2),
...
Angel J Piscola
@Redmega
Aug 30 2016 03:38
Or are you saying elixer removes all the punctuation
llamatarianism
@llamatarianism
Aug 30 2016 03:38
@Redmega elixir removes the punctuation
erlang has 3 different statement separators
foo(X) when is_integer(X) ->
  io:fwrite("heyo!\n"),
  X + 1;

foo(X) ->
  X ++ "foo".
Joseph Parkton
@hippybear
Aug 30 2016 03:40
but...
Angel J Piscola
@Redmega
Aug 30 2016 03:40
The . I don't get
llamatarianism
@llamatarianism
Aug 30 2016 03:40
it makes sense in prolog, which erlang is based off of. , is used for logical conjunction (andalso), ; is used for logical disjunction (orelse), and . is used to end statements
in erlang it's just kinda annoying.
Egoscio
@Egoscio
Aug 30 2016 03:40
eww. prolog
Angel J Piscola
@Redmega
Aug 30 2016 03:40
Oh
llamatarianism
@llamatarianism
Aug 30 2016 03:40
, sticks statements together, ; sticks clauses together, and . ends statements
Angel J Piscola
@Redmega
Aug 30 2016 03:40
It's just a period
Egoscio
@Egoscio
Aug 30 2016 03:40
It's a meme of a language from what I've searched.
llamatarianism
@llamatarianism
Aug 30 2016 03:41
@Egoscio prolog's neat!
Joseph Parkton
@hippybear
Aug 30 2016 03:41
pay attention to me damn you!!
llamatarianism
@llamatarianism
Aug 30 2016 03:41
@hippybear looks nice
Joseph Parkton
@hippybear
Aug 30 2016 03:41
Its jekyll, its fancy?
Angel J Piscola
@Redmega
Aug 30 2016 03:41
@hippybear I don't like that I need to hit "Read More" just to see Written on August 29, 2016
Joseph Parkton
@hippybear
Aug 30 2016 03:41
ikr?
Kinda dumb
Angel J Piscola
@Redmega
Aug 30 2016 03:41
That information should be visible by default
maybe in a <small> next to the title
Joseph Parkton
@hippybear
Aug 30 2016 03:42
pfft
Egoscio
@Egoscio
Aug 30 2016 03:42
@hippybear I personally either write my own CMS or roll with Ghost.
Ghost FTW
Joseph Parkton
@hippybear
Aug 30 2016 03:42
thats some core function I will have to relogic
Ghost can suck my nizzles
he broke from Wordpress to make a more expensive blog
lol
Egoscio
@Egoscio
Aug 30 2016 03:43
Bruh I just selfhost dat stuff. UI is beautiful, and the markdown posts... zomg
Joseph Parkton
@hippybear
Aug 30 2016 03:43
@Egoscio I just installed HTMLy today, I kinda like it!
I agree, its really stripped down I like it
I just havent used it but im stocked its node
llamatarianism
@llamatarianism
Aug 30 2016 03:44

elixir also solves this:

X1 = some_fun(X0),
X2 = other_fun(X1),
X3 = another_fun(X2).

or alternatively

another_fun(other_fun(some_fun(X0))).

by making it into

x0 |> some_fun |> other_fun |> another_fun
Egoscio
@Egoscio
Aug 30 2016 03:44
But the reason why I don't go that path is because I don't like Static... just personal pref
Joseph Parkton
@hippybear
Aug 30 2016 03:44
:O
Egoscio
@Egoscio
Aug 30 2016 03:44
Dynamic server code pls
Joseph Parkton
@hippybear
Aug 30 2016 03:44
r00d
that is htmly
Super easy, I assume really insecure too so im gonna open up all chinese ip blocks
Vishon
@Symbolistic
Aug 30 2016 03:45
welp i am completely lost right now with this "Caesars Cipher" challenge.
Angel J Piscola
@Redmega
Aug 30 2016 03:45
Hit us @Symbolistic
What's your issue
Vishon
@Symbolistic
Aug 30 2016 03:46
not even sure where to start with it man lol
Egoscio
@Egoscio
Aug 30 2016 03:46
@hippybear Your theme only has a couple dozen lined Js file? link to file
Angel J Piscola
@Redmega
Aug 30 2016 03:46
Did you read the recommended functions? charCodeAt, charCodeFrom, etc
Vishon
@Symbolistic
Aug 30 2016 03:46
i did
and i know i gotta convert to a real set of words, but ehhhh
Joseph Parkton
@hippybear
Aug 30 2016 03:46
@Egoscio fancy no?
Vishon
@Symbolistic
Aug 30 2016 03:46
not sure if i need to use loops in this or what
or if its another problem that can easily be solved in a few lines of code
Angel J Piscola
@Redmega
Aug 30 2016 03:47
Since you're perofrming some action on each letter, you will probably need a for loop, yes
Vishon
@Symbolistic
Aug 30 2016 03:47
the main issue is i read the documents, but i see they only take in the text and change it to unicode. but i saw you need to decode it to make it appear as real words
i have no idea how that works
Angel J Piscola
@Redmega
Aug 30 2016 03:48
Don't focus on how much code you write (unless you start feeling like you're writing an essay)
Just focus on solving the problem
Joseph Parkton
@hippybear
Aug 30 2016 03:48
DRY
Vishon
@Symbolistic
Aug 30 2016 03:48
mmmk
Egoscio
@Egoscio
Aug 30 2016 03:48
Don't repeat yoshelf
Vishon
@Symbolistic
Aug 30 2016 03:48
yeah i wont repeat myself
Joseph Parkton
@hippybear
Aug 30 2016 03:48
fo sho
Angel J Piscola
@Redmega
Aug 30 2016 03:48
Look at the problem from a distance and see what you might need to do
Joseph Parkton
@hippybear
Aug 30 2016 03:49
Also watch Penny Dreadful on Netflix its kinda wild
Egoscio
@Egoscio
Aug 30 2016 03:49
One thing I like seeing though is more efficient code. Sometimes there's one way of doing something, but another, much easier and faster way.
Angel J Piscola
@Redmega
Aug 30 2016 03:49
You know you need to convert each letter, so you'll need a for loop and probably a split('');, yeah?
Egoscio
@Egoscio
Aug 30 2016 03:49
You just have to think about refactoring into a more condensed/efficient.
Vishon
@Symbolistic
Aug 30 2016 03:49
yeah i figured it might have to be turned into an array
to target each letter specifically
Angel J Piscola
@Redmega
Aug 30 2016 03:50
Yep
I think you've learned previously about .map() too, right?
Vishon
@Symbolistic
Aug 30 2016 03:50
yeah
Angel J Piscola
@Redmega
Aug 30 2016 03:50
That will do something on each element in an array
So that's a good start
After that its just figuring out the algorithm you need to use
@Egoscio Do you like seeing code golf too?
Vishon
@Symbolistic
Aug 30 2016 03:51
mmmk thanks that pointed me in the right direction @Redmega
CamperBot
@camperbot
Aug 30 2016 03:51
symbolistic sends brownie points to @redmega :sparkles: :thumbsup: :sparkles:
:cookie: 107 | @redmega |http://www.freecodecamp.com/redmega
Egoscio
@Egoscio
Aug 30 2016 03:51
Yeah!
On stack overflow, it's a fun sight.
Angel J Piscola
@Redmega
Aug 30 2016 03:51
I've been golfing with my challenges a bit
Egoscio
@Egoscio
Aug 30 2016 03:52
I usually don't see typical languages though. Usually matlab or Mathematica
Angel J Piscola
@Redmega
Aug 30 2016 03:52
Though @rphares and @llamatarianism have shown me I have a ways to go
My favorite answers are written in brainf*ck
llamatarianism
@llamatarianism
Aug 30 2016 03:52
meh
mathematica has a lot of builtins, which is useful
Egoscio
@Egoscio
Aug 30 2016 03:52
lol, how can that be efficient doe
Angel J Piscola
@Redmega
Aug 30 2016 03:52
It isn't, it's just fun to look at
llamatarianism
@llamatarianism
Aug 30 2016 03:52
but usually the names of those mathematica builtins are longer than the equivalent code in a true golfing language
like jelly or pyth
Angel J Piscola
@Redmega
Aug 30 2016 03:53
>>>>>>+++/><.<++<<.<..+=+===++.+..<
llamatarianism
@llamatarianism
Aug 30 2016 03:53
like for example
Egoscio
@Egoscio
Aug 30 2016 03:53
Mathematica spoils you. Once I tried writing something that solves a math equation for math class. Took me about 100 lines fully "optimized", but then my friend who does Mathematica just invoked ONE function.
I was like bruh this sucks. where da fun doe?
llamatarianism
@llamatarianism
Aug 30 2016 03:53
I assume the mathematica builtin for finding a number factorial is Factorial
in a decent golfing language you could prob just do
2R*F where R = range and F = fold
so that'd pretty much be product [2..n]
and is 5 chars shorter than Factorial
looked it up. in APL, factorial is ×/∘⍳.
Egoscio
@Egoscio
Aug 30 2016 03:55
those symbols tho
llamatarianism
@llamatarianism
Aug 30 2016 03:55
pretty much the same thing.
essentially means "multiply fold compose range"
so ×/∘⍳5 finds ⍳5, which is 1 2 3 4 5, then ×/ finds the product of that, which is 120, or 5!5!
Angel J Piscola
@Redmega
Aug 30 2016 03:56
I've mainly just got Java and java/ecmascript in my arsenal, so I can't really code golf right. I just try for the shortest js I can make.
Egoscio
@Egoscio
Aug 30 2016 03:57
Same
Angel J Piscola
@Redmega
Aug 30 2016 03:57
It also must hurt that I have no official algorithms training
It's a college course at every college except mine, apparently
Egoscio
@Egoscio
Aug 30 2016 03:59
I taught myself at 12 years old, but with a terrible "language". BASH... Screwed up my understanding of certain common programming aspects.
llamatarianism
@llamatarianism
Aug 30 2016 03:59
bash is so mlugh.
Angel J Piscola
@Redmega
Aug 30 2016 04:01
BASH is a language?
Egoscio
@Egoscio
Aug 30 2016 04:01
Hardly. Scripting
Angel J Piscola
@Redmega
Aug 30 2016 04:01
Insomuch as powershell is a language?
Batch, rather
llamatarianism
@llamatarianism
Aug 30 2016 04:01
I don't get the obsession with powershell
Egoscio
@Egoscio
Aug 30 2016 04:01
Well, you can make it do stuff, but not elegantly
llamatarianism
@llamatarianism
Aug 30 2016 04:01
people say it's really nice to be able to deal with objects
but like
Egoscio
@Egoscio
Aug 30 2016 04:02
I really wish someone told me to choose C Java when I started off.
llamatarianism
@llamatarianism
Aug 30 2016 04:02
something being a good scripting language doesn't make it a good shell language
I hate actually using bash, but working with text is pretty convenient for a shell language
Egoscio
@Egoscio
Aug 30 2016 04:02
I don't recall the existence of objects at all in bash.
Angel J Piscola
@Redmega
Aug 30 2016 04:02
They're talking about powershell
I believe
llamatarianism
@llamatarianism
Aug 30 2016 04:02
powershell just seems needlessly complex for a shell language
Angel J Piscola
@Redmega
Aug 30 2016 04:03
I haven't used much of either
llamatarianism
@llamatarianism
Aug 30 2016 04:03
why not just use a full-on scripting language at that point
Angel J Piscola
@Redmega
Aug 30 2016 04:03
I've written a few BAT files of course, who hasn't...
Nothing fancy though
Egoscio
@Egoscio
Aug 30 2016 04:03
Well, I'm talking a freaking social network. Imagine writing that in a scripting language like that.
Terrible, right?
llamatarianism
@llamatarianism
Aug 30 2016 04:03
man, I think bash is terrible even for tiny little one-off scripts
I just write em in python
Xavier Artot
@xavierartot
Aug 30 2016 04:04
hi
Altaryum
@Altaryum
Aug 30 2016 04:04
Anyone can help with Stand in line challenge?
Egoscio
@Egoscio
Aug 30 2016 04:04
Funny you should say.. My first and only Stack overflow post
Xavier Artot
@xavierartot
Aug 30 2016 04:04
I need some help with Grunt and Babel?
someone can help me
?
Egoscio
@Egoscio
Aug 30 2016 04:05
Don't grunt and babel kind of my classify as part of the nodejs channel?
Xavier Artot
@xavierartot
Aug 30 2016 04:05
no
Egoscio
@Egoscio
Aug 30 2016 04:05
Here they really emphasize on frontend, but that's just my though. Go ahead
Xavier Artot
@xavierartot
Aug 30 2016 04:05
it's front end developement
I want to do my challenge in es15
Egoscio
@Egoscio
Aug 30 2016 04:05
Oh right lol. I'll shush now, my implementation was different.
Xavier Artot
@xavierartot
Aug 30 2016 04:06
so I need a transcompiller
@Egoscio what did you do?
which implementation?
Jonah Erlich
@jerlich97
Aug 30 2016 04:06
Hey I'm having trouble with the Profile Lookup in basic javascript. Any suggestions on how to check if the firstName property is in a certain profile?
Egoscio
@Egoscio
Aug 30 2016 04:07
Server side dynamic generation, here's something that might be relevant to you, but I used gulp
llamatarianism
@llamatarianism
Aug 30 2016 04:07
@jerlich97 Object.prototype.hasOwnProperty
Boris
@boris-in-london
Aug 30 2016 04:07
@xavierartot off topic question but my curiosity is peaked, how did you get American citizenship in just two years?
Xavier Artot
@xavierartot
Aug 30 2016 04:07
let's me look
llamatarianism
@llamatarianism
Aug 30 2016 04:07
var obj = {a: 1};
console.log(obj.hasOwnProperty('a')); // true
console.log(obj.hasOwnProperty('b')); // false
Xavier Artot
@xavierartot
Aug 30 2016 04:08
@boris-in-london
Jonah Erlich
@jerlich97
Aug 30 2016 04:08
@llamatarianism They all have the firstName property, I'm checking whether they have the specific first name inputed into the function
Xavier Artot
@xavierartot
Aug 30 2016 04:08
How do you know that?
Boris
@boris-in-london
Aug 30 2016 04:08
i checked your webpage
Egoscio
@Egoscio
Aug 30 2016 04:08
I think he saw your blog lol.
Boris
@boris-in-london
Aug 30 2016 04:08
nice work btw
llamatarianism
@llamatarianism
Aug 30 2016 04:08
@jerlich97 then just access the property and check what it is
Boris
@boris-in-london
Aug 30 2016 04:08
looks very cool and clean
Egoscio
@Egoscio
Aug 30 2016 04:08
Et salut, je suis français aussi o/
Xavier Artot
@xavierartot
Aug 30 2016 04:08
yes I did 2 years
llamatarianism
@llamatarianism
Aug 30 2016 04:08
console.log(obj.a); // 1
console.log(obj.a === 1); // true
Angel J Piscola
@Redmega
Aug 30 2016 04:08
@xavierartot That's the thing about putting your info out there m8
Jonah Erlich
@jerlich97
Aug 30 2016 04:09
@llamatarianism Can I iterate through the object treating it like an array?
Boris
@boris-in-london
Aug 30 2016 04:09
how in only TWO years? amazing
Xavier Artot
@xavierartot
Aug 30 2016 04:09
:)
@Egoscio j'au créé un groupe pour francophone sur facebook
Angel J Piscola
@Redmega
Aug 30 2016 04:10
function findElement(arr, func) {
  return arr.filter((x)=>func(x))[0];
}
There's got to be a way to do this with .some()
llamatarianism
@llamatarianism
Aug 30 2016 04:10
@jerlich97 use a for in loop
Egoscio
@Egoscio
Aug 30 2016 04:10
@xavierartot Génial, malheureusement j'ai pas de Facebook :P
Xavier Artot
@xavierartot
Aug 30 2016 04:10
ok
j'aime bien ton repo
llamatarianism
@llamatarianism
Aug 30 2016 04:10
var obj = {a: 1, b: 2, c: 3}

for (var key in obj) {
  console.log(key + ': ' + obj[key]);
}

// a: 1
// b: 2
// c: 3
Xavier Artot
@xavierartot
Aug 30 2016 04:11
babel looks good :)
Egoscio
@Egoscio
Aug 30 2016 04:11
Merci! I personally prefer Gulp
Angel J Piscola
@Redmega
Aug 30 2016 04:11
find() works actually
CamperBot
@camperbot
Aug 30 2016 04:11
find works actually
nothing found
Xavier Artot
@xavierartot
Aug 30 2016 04:11
je connais pas
llamatarianism
@llamatarianism
Aug 30 2016 04:11
but I really don't think you need to in this case.
Xavier Artot
@xavierartot
Aug 30 2016 04:11
mais par contre il y a moins de code
je vais me laisser tenter
Egoscio
@Egoscio
Aug 30 2016 04:11
It's like Grunt but less config based, more like a real node script.
ah, d'accord
Xavier Artot
@xavierartot
Aug 30 2016 04:12
I'll see 2 methods pipe()
oui surtout que j'ai besoin de pratiquer de l'es6
it's really cool repo thanks @Egoscio
CamperBot
@camperbot
Aug 30 2016 04:13
xavierartot sends brownie points to @egoscio :sparkles: :thumbsup: :sparkles:
:cookie: 38 | @egoscio |http://www.freecodecamp.com/egoscio
Xavier Artot
@xavierartot
Aug 30 2016 04:13
did you see mine?
Egoscio
@Egoscio
Aug 30 2016 04:13
No prob! Dab around the other source files if you find them useful ;)
Sure I'll have a look
Xavier Artot
@xavierartot
Aug 30 2016 04:14
you save my day if Babel works
:)
Egoscio
@Egoscio
Aug 30 2016 04:14
The key to babel es6 in a gulp config is line 28
Xavier Artot
@xavierartot
Aug 30 2016 04:15
oui I saw it
Egoscio
@Egoscio
Aug 30 2016 04:15
(at least when I wrote it)
Xavier Artot
@xavierartot
Aug 30 2016 04:15
it's like Grunt
but I used a dot file .babelrc
but Grunt doesn't work?
babel/grunt-babel#72
I left my issue on the plugin page
je suis dégouté
Egoscio
@Egoscio
Aug 30 2016 04:17
Did you install the babel grunt plugin?
Xavier Artot
@xavierartot
Aug 30 2016 04:18
oui
j'ai même un post sur FCC
j'accroche personne
ou alors plus personne n'utilise Grunt
Egoscio
@Egoscio
Aug 30 2016 04:19
Really appreciate you using babel btw, I feel like FCC should emphasize on implementing it ;)
Xavier Artot
@xavierartot
Aug 30 2016 04:19
They don't want discourage people
Aabjeet Grewal
@Jeetman
Aug 30 2016 04:19
need some help with quoting strings with single quotes
Xavier Artot
@xavierartot
Aug 30 2016 04:19
it can be tricky
Egoscio
@Egoscio
Aug 30 2016 04:20
@Jeetman Ask away!
Aabjeet Grewal
@Jeetman
Aug 30 2016 04:20
they task wants me to Change the provided string from double to single quotes and remove the escaping.
the*
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Xavier Artot
@xavierartot
Aug 30 2016 04:20
je t'ai starifié sur Github
:)
Egoscio
@Egoscio
Aug 30 2016 04:21
@xavierartot Si tu peut, se serait génial que t'essaie Gulp, c'est mis-à-jour plus souvent que Grunt et en development constant à mon avis
Xavier Artot
@xavierartot
Aug 30 2016 04:21
var myStr = "<a href='http://www.example.com' target='_blank\">Link</a>";
Egoscio
@Egoscio
Aug 30 2016 04:21
@Jeetman When you use single quotes to contain it, you don't need to escape double quotes at all.
Xavier Artot
@xavierartot
Aug 30 2016 04:22
oup's I send the solution without finished it
:(
Egoscio
@Egoscio
Aug 30 2016 04:22
You could either do what Xavier did or replace single quotes with doubles and vise versa, as they don't conflict with eachother
Xavier Artot
@xavierartot
Aug 30 2016 04:22
right
tu as vu mon repo
Aabjeet Grewal
@Jeetman
Aug 30 2016 04:23
so the surrounding quotes need to be single so that the inside double quotes do not need a backslash?
Xavier Artot
@xavierartot
Aug 30 2016 04:23
je crois que tu as raison sur Gulp
Egoscio
@Egoscio
Aug 30 2016 04:23
@Jeetman Correct
Aabjeet Grewal
@Jeetman
Aug 30 2016 04:23
thank you
Egoscio
@Egoscio
Aug 30 2016 04:24
My pleasure! Just double check the instructions to make sure which one you should use for the actual string vs quoting the html attribues
Xavier Artot
@xavierartot
Aug 30 2016 04:24
I'm using the quote in the html attribute
Egoscio
@Egoscio
Aug 30 2016 04:24
I think FCC is sensitive on regard to that aspect.
Yeah so var html = '<a hreg="http://something.com">' instead of vice versa
Xavier Artot
@xavierartot
Aug 30 2016 04:25
the simple quote are faster to write
Xavier Artot
@xavierartot
Aug 30 2016 04:26
ha oui
tu es en France?
Egoscio
@Egoscio
Aug 30 2016 04:27
Non, USA, Cali
Xavier Artot
@xavierartot
Aug 30 2016 04:29
moi aussi, Austin
TX
George
@cha0sphere
Aug 30 2016 04:31
hi there is anybody willing to help with the word blanks challenge? for some reason i don't understand what code i need to put
Xavier Artot
@xavierartot
Aug 30 2016 04:32
maybe
Egoscio
@Egoscio
Aug 30 2016 04:32
Here's the place to ask!
George
@cha0sphere
Aug 30 2016 04:34

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result = myNoun + myAdjective + myVerb + myAdverb;

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

is there anything i missed?
Egoscio
@Egoscio
Aug 30 2016 04:34
Could you please format your code? '''
CamperBot
@camperbot
Aug 30 2016 04:34
:bulb: to format code use backticks! ``` more info
Vishon
@Symbolistic
Aug 30 2016 04:35
i am dyingggggggg
this Caesars Cipher algorithm is making me so crazy
George
@cha0sphere
Aug 30 2016 04:36

`function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";

result = myNoun + myAdjective + myVerb + myAdverb;

return result;
}

wordBlanks("dog", "big", "ran", "quickly");`

Xavier Artot
@xavierartot
Aug 30 2016 04:36
:)
Vishon
@Symbolistic
Aug 30 2016 04:36
this is all i got so far and its pissing me off.

function rot13(str) { // LBH QVQ VG!
  str = str.split('');

  for(var i=0; i<str.length;i++){
    str[i] = str[i].charCodeAt(i);
  }

  return str;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Xavier Artot
@xavierartot
Aug 30 2016 04:37
you have to declare you variable str
var str
Egoscio
@Egoscio
Aug 30 2016 04:37
@cha0sphere For the test to pass, you need non-word characters separating each.
Xavier Artot
@xavierartot
Aug 30 2016 04:37
I will do a regex for that
George
@cha0sphere
Aug 30 2016 04:38
@Egoscio yeah ok that's why i'm confused, how do i go about it?
Vishon
@Symbolistic
Aug 30 2016 04:38
@xavierartot i tried but i still get the first unicode, then null null null null null null
Egoscio
@Egoscio
Aug 30 2016 04:38
@cha0sphere The way you have it, all the strings are stitched together without any separators. Do something that will make it end up like a sentence.
George
@cha0sphere
Aug 30 2016 04:38
@Egoscio ok thanks i'll give it a try
CamperBot
@camperbot
Aug 30 2016 04:38
cha0sphere sends brownie points to @egoscio :sparkles: :thumbsup: :sparkles:
:cookie: 39 | @egoscio |http://www.freecodecamp.com/egoscio
Gang Zhao
@crumpx
Aug 30 2016 04:39
you do challenges backward?
Egoscio
@Egoscio
Aug 30 2016 04:39
Whom?
Gang Zhao
@crumpx
Aug 30 2016 04:39
oh i meant @Symbolistic
Vishon
@Symbolistic
Aug 30 2016 04:40
@crumpx im just so lost with that algorithm i dont even know
i cant even paint a picture on where i am supposed to start
Gang Zhao
@crumpx
Aug 30 2016 04:40
get a rest :D
Egoscio
@Egoscio
Aug 30 2016 04:41
Lol, sleep over it. When I have a big problem, I debug it in my sleep. Would recommend :+1:
Xavier Artot
@xavierartot
Aug 30 2016 04:41
for the Caesar cipher you can't use a regex
Vishon
@Symbolistic
Aug 30 2016 04:41
alright guess im done for the day
Xavier Artot
@xavierartot
Aug 30 2016 04:41
but is not that I was using
but is not easy for sure
@Symbolistic
Gang Zhao
@crumpx
Aug 30 2016 04:42
this one limits to only use uppercase characters.
Xavier Artot
@xavierartot
Aug 30 2016 04:42
I can give you my idea but I don't know if is the best result
?
Vishon
@Symbolistic
Aug 30 2016 04:43
ill take whatever at this point
Xavier Artot
@xavierartot
Aug 30 2016 04:43
ok
Egoscio
@Egoscio
Aug 30 2016 04:43
Here's what I did:
function rot13(str) { // LBH QVQ VG!
  return str.split('').map(function (a) {
    var char = a.charCodeAt();
    if (char >= 65 && char <= 158) {
      return String.fromCharCode(a.charCodeAt() - 13);
    } else {
      return a;
    }
  }).join('');
}
I just drafted this when someone asked
it doesn't work, but...
Xavier Artot
@xavierartot
Aug 30 2016 04:44
I was using charCodeAt() + 13
Egoscio
@Egoscio
Aug 30 2016 04:44
This message was deleted
oops
Gang Zhao
@crumpx
Aug 30 2016 04:44
look at the picture and count :P
Xavier Artot
@xavierartot
Aug 30 2016 04:44
if(charcode < 65){
Egoscio
@Egoscio
Aug 30 2016 04:44
My code does gives this: F8EE C5DE CAM6
Xavier Artot
@xavierartot
Aug 30 2016 04:44
so my solution with a map
Angel J Piscola
@Redmega
Aug 30 2016 04:45
@Egoscio %26
Egoscio
@Egoscio
Aug 30 2016 04:45
Spaces, ah
Gang Zhao
@crumpx
Aug 30 2016 04:45
you're almost there.
Egoscio
@Egoscio
Aug 30 2016 04:45
wait %26 is a space right? I just remember seeing that in URLs...
Xavier Artot
@xavierartot
Aug 30 2016 04:45
mine

``` function rot13(str) { // LBH QVQ VG!
var r, t=0, total=0, charcode=0, charcode13=0, strTotal='', test='';
loopAlpha : for (var j = 0; j < str.length; j++) {
r = str[j];
charcode = r.charCodeAt();
charcode13 = charcode + 13;
if(charcode < 65){
// ne remplace les - par les signs ?!.,space
strTotal += str[j];

    }else if (charcode13 > 90) {
      t = charcode13 - 90;
      total = t+ 64;
      strTotal += String.fromCharCode(total);
    }else {
      strTotal += String.fromCharCode(charcode13);
    }
  }
  //return console.log(strTotal );
  return strTotal;
}

```

Gang Zhao
@crumpx
Aug 30 2016 04:45
remember this rot13 only uses uppercase letters
Angel J Piscola
@Redmega
Aug 30 2016 04:45
@Egoscio Nope. I'm telling you to modulus 26
Xavier Artot
@xavierartot
Aug 30 2016 04:46
@Egoscio I'd like yours
Vishon
@Symbolistic
Aug 30 2016 04:46
from what i've seen so far... this last basic algorithm challenge will be a..............challenge...
Angel J Piscola
@Redmega
Aug 30 2016 04:46
Anyone want to tell me why this works, but when I make the while infinite, it crashes my browser?
function dropElements(arr, func) {
  let i = 0;    
  while(i<10){
        if(func(arr[0]))
            break;
        else{
            arr.shift();
            i++;
        }
    }
  return arr;
}
Xavier Artot
@xavierartot
Aug 30 2016 04:46
function rot13(str) { // LBH QVQ VG! var r, t=0, total=0, charcode=0, charcode13=0, strTotal='', test=''; loopAlpha : for (var j = 0; j < str.length; j++) { r = str[j]; charcode = r.charCodeAt(); charcode13 = charcode + 13; if(charcode < 65){ // ne remplace les - par les signs ?!.,space strTotal += str[j]; }else if (charcode13 > 90) { t = charcode13 - 90; total = t+ 64; strTotal += String.fromCharCode(total); }else { strTotal += String.fromCharCode(charcode13); } } //return console.log(strTotal ); return strTotal; } //rot13("SERR PBQR PNZC"); //should decode to "FREE CODE CAMP" //rot13("SERR CVMMN!") //should decode to "FREE PIZZA!" rot13("SERR YBIR?") //should decode to "FREE LOVE?" //rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK.") //should decode to "THE QUICK BROWN DOG JUMPED OVER THE LAZY FOX."
oup'a
Egoscio
@Egoscio
Aug 30 2016 04:47
Try triple backticks @xavierartot :P
Xavier Artot
@xavierartot
Aug 30 2016 04:47
oup's
Egoscio
@Egoscio
Aug 30 2016 04:48
@Redmega What's func supposed to be?
Xavier Artot
@xavierartot
Aug 30 2016 04:48

I have a blind keyboard

but I did?

    function rot13(str) { // LBH QVQ VG!
      var r, t=0, total=0, charcode=0, charcode13=0, strTotal='', test='';
      loopAlpha : for (var j = 0; j < str.length; j++) {
        r = str[j];
        charcode = r.charCodeAt();
        charcode13 = charcode + 13;
        if(charcode  < 65){
          // ne remplace les - par les signs ?!.,space 
          strTotal += str[j];
        }else if (charcode13 > 90) {
          t = charcode13 - 90;
          total = t+ 64;
          strTotal += String.fromCharCode(total);
        }else {
          strTotal += String.fromCharCode(charcode13);
        }
      }
      //return console.log(strTotal );
      return strTotal;
    }
      //rot13("SERR PBQR PNZC"); //should decode to "FREE CODE CAMP"
      //rot13("SERR CVMMN!") //should decode to "FREE PIZZA!"
      rot13("SERR YBIR?") //should decode to "FREE LOVE?"
      //rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK.") //should decode to "THE QUICK BROWN DOG JUMPED OVER THE LAZY FOX."
Angel J Piscola
@Redmega
Aug 30 2016 04:48
@Egoscio A function which will evaluate the value and return true or false
ex: function(n) {return n > 5;}
Xavier Artot
@xavierartot
Aug 30 2016 04:49
I'm Vim user for the code
Angel J Piscola
@Redmega
Aug 30 2016 04:49
@Symbolistic I didnt find it that hard. Just need to find the algorithm which works for you
Gang Zhao
@crumpx
Aug 30 2016 04:50
@Symbolistic you should be able to crack rot13 by tomorrow :P
good night everyone.
Angel J Piscola
@Redmega
Aug 30 2016 04:50
Night
Xavier Artot
@xavierartot
Aug 30 2016 04:50
@Egoscio ta solution est vraiment plus élégante que la mienne
Egoscio
@Egoscio
Aug 30 2016 04:51
@Redmega Is this basically a custom .filter() implementation?
@xavierartot Merci!
Xavier Artot
@xavierartot
Aug 30 2016 04:51
10 lines dude :)
mine it have 20 lines
Angel J Piscola
@Redmega
Aug 30 2016 04:51
@Egoscio Not quite. It keeps dropping the first element until it evaluates to true.
I tried to make it work with .some() but I couldnt quite get my head around it
Anyway, I figured out the issue
For one of the tests it will keep trying to shift() an empty array, so its stuck in there.
        if(func(arr[0]) || arr.length === 0)
            break;
this solves it
Egoscio
@Egoscio
Aug 30 2016 04:52

Lol, I did:

function dropElements(arr, func) {
  // Drop them elements.
  return arr.filter(func);
}

and it gives me 4 out of the 6 checks

Angel J Piscola
@Redmega
Aug 30 2016 04:53
Need to stop once you hit true
You dont care about the rest
Egoscio
@Egoscio
Aug 30 2016 04:53
There's .some() and .every()
hmm
Angel J Piscola
@Redmega
Aug 30 2016 04:53
I tried some() at first, like i mentioned earlier
every() isnt the right pick
The issue with some() is that..
What was the issue...
Ah
When you shift the index messes up
Xavier Artot
@xavierartot
Aug 30 2016 04:54
I'm studiing your way @Egoscio
interrissing
Angel J Piscola
@Redmega
Aug 30 2016 04:54
you end up only evaluating every other element
Egoscio
@Egoscio
Aug 30 2016 04:55
@xavierartot Glad I could provide a nice set specimen ;)
Xavier Artot
@xavierartot
Aug 30 2016 04:56
I have tough time to use the method native js
je fais mon spaghetis d'habitude mais je vois bien que c'est bancal
ma maniere de faire
Egoscio
@Egoscio
Aug 30 2016 04:58
@xavierartot One of my favorite repos to work on was https://github.com/Egoscio/gelato , it gives you a general idea of a node project and the use of networking libraries and system wrappers to complete a desired task
Xavier Artot
@xavierartot
Aug 30 2016 04:58
map je croyais que c'était seulement pour les objets
et les tablaux sont objets justement
I will look at your repo
but node for me, no really
I m not there
btw I'm lost
:)
I'm learning React
and Redux
and FCC
luis4flames
@luis4flames
Aug 30 2016 05:01

function rot13(str) { // LBH QVQ VG!


  var strArr = str.split(" ");
  var newWord;
  var newArr = new Array(strArr.length);


  for (var i =0; i < strArr.length; i++){
    newArr[i] = new Array(str[i].length);


    for(var j=0; j< strArr[i].length; j++){  
      //Letter ASCCII
      var x = strArr[i].charCodeAt(j);


      if ( 65 <= x && x <= 77){
        x += 13;
      } else if (78 <= x && x <= 90){
        x -= 13;
      } else {
        x = x;
      }
      //CONVERT BACK TO CHARACTER
       x = String.fromCharCode(x);
      newArr[i][j] = x;

      }
    //ADD SPACE BETWEEN WORDS
     if ( i != strArr.length){
     newArr[i][j+1] = " "; 
     }

    }
  //CONVERT TO STRING AND REMOVE COMAS
    newWord = newArr.toString().replace(/,/g,"");

  return newWord;

}

// Change the inputs below to test
rot13("SERR CVMMN!");
Xavier Artot
@xavierartot
Aug 30 2016 05:01
@luis4flames the best solution it's from @Egoscio
He did with 10 lines
Egoscio
@Egoscio
Aug 30 2016 05:01
Mine isn't a solution though, I'm missing a part lol
luis4flames
@luis4flames
Aug 30 2016 05:01
so my code returns the correct output but it wont pass any of the checkpoint for the challange
Xavier Artot
@xavierartot
Aug 30 2016 05:02
???
luis4flames
@luis4flames
Aug 30 2016 05:02
wow 10 lines? lol
Angel J Piscola
@Redmega
Aug 30 2016 05:02
@luis4flames What does rot13("SERR CVMMN!"); give you?
:P
Xavier Artot
@xavierartot
Aug 30 2016 05:02
the best solution is the shorter one in algoritm?
luis4flames
@luis4flames
Aug 30 2016 05:02
FREE PIZZA!
Xavier Artot
@xavierartot
Aug 30 2016 05:02
:)
Kent Saeteurn
@sansae
Aug 30 2016 05:02
can anyone help me with my textfield issue? I'm trying to clear the textfield after user clicks on submit, but nothing i've tried works. here is my fiddle: https://jsfiddle.net/8zLdtece/1/
Egoscio
@Egoscio
Aug 30 2016 05:03
das bootiful
luis4flames
@luis4flames
Aug 30 2016 05:03
EVERYTHING MATCHES BUT IT WONT PASS THE CHALLENGE FOR SOME REASON
Xavier Artot
@xavierartot
Aug 30 2016 05:03
@Redmega but yours is tough to read
Angel J Piscola
@Redmega
Aug 30 2016 05:03
Pff
Egoscio
@Egoscio
Aug 30 2016 05:03
nah, he's using a ternary
Angel J Piscola
@Redmega
Aug 30 2016 05:03
Read schead
schmead
Xavier Artot
@xavierartot
Aug 30 2016 05:03
wep
Egoscio
@Egoscio
Aug 30 2016 05:03
Using an if would be the same but just "easier" to read for some
I would have used tern too
Xavier Artot
@xavierartot
Aug 30 2016 05:04
% the modulo 26
Angel J Piscola
@Redmega
Aug 30 2016 05:04
@luis4flames It doesn't look the same to me
Xavier Artot
@xavierartot
Aug 30 2016 05:04
:)
Angel J Piscola
@Redmega
Aug 30 2016 05:04
It is expecting FREE PIZZA! but it is getting FREE PIZZA!
Err
=> 'FREE PIZZA! '
Xavier Artot
@xavierartot
Aug 30 2016 05:04
nope
Angel J Piscola
@Redmega
Aug 30 2016 05:04
Notice the whitespace after the exclamation mark
Xavier Artot
@xavierartot
Aug 30 2016 05:05
the best it's the one have a less instruction for the computer
the best it's the fast
Angel J Piscola
@Redmega
Aug 30 2016 05:05
I just realized.. Why am I doing toUpperCase(), I can just put the alphabet in caps to begin with
Egoscio
@Egoscio
Aug 30 2016 05:05
I was confused because he said modulus or something lol
silly me
Xavier Artot
@xavierartot
Aug 30 2016 05:05
me too
Angel J Piscola
@Redmega
Aug 30 2016 05:06
26 letters in the english alphabet
Xavier Artot
@xavierartot
Aug 30 2016 05:06
wep
Egoscio
@Egoscio
Aug 30 2016 05:06
OH
luis4flames
@luis4flames
Aug 30 2016 05:06
ahh yea, but i made the statement to only add the space if it wasnt the last word. i being the word in the input. or did i do something wrong?
Xavier Artot
@xavierartot
Aug 30 2016 05:06
I'd like it
luis4flames
@luis4flames
Aug 30 2016 05:06
 //ADD SPACE BETWEEN WORDS
     if ( i != strArr.length){
     newArr[i][j+1] = " "; 
     }
Xavier Artot
@xavierartot
Aug 30 2016 05:06
you beat me, no way
I have 20 lines
Angel J Piscola
@Redmega
Aug 30 2016 05:06
Lol
I'm sure others have better rot13's than I do
Xavier Artot
@xavierartot
Aug 30 2016 05:07
but
....
I prefer the readybalities
Abhisek Pattnaik
@abhisekp
Aug 30 2016 05:07
@xavierartot The best solution is matter of perspective. But generally, people accept shorter as the better.
But considering the maintainability, easier to understand is usually maintainable too ;)
Egoscio
@Egoscio
Aug 30 2016 05:07
What goofed me up was the encoding of spaces as %20. Pls senpai gib anuder chans
Angel J Piscola
@Redmega
Aug 30 2016 05:08
@abhisekp Absolutely. My code is not very readable unless you're advanced, but to be fair a rot13 algorithm isn't likely to be maintained very often...
It's kind of a write once, stick it in utils.js, and forget about it kind of thing
Egoscio
@Egoscio
Aug 30 2016 05:09
Write once, stick it in your toolbox.js
Abhisek Pattnaik
@abhisekp
Aug 30 2016 05:09
yeah! just saying in general
Egoscio
@Egoscio
Aug 30 2016 05:09
lol
Angel J Piscola
@Redmega
Aug 30 2016 05:09
xD
Xavier Artot
@xavierartot
Aug 30 2016 05:09
wep
Egoscio
@Egoscio
Aug 30 2016 05:09
I actually always do the same thing :P Just... forget it. maybe in a year I might try to refactor if possible
Xavier Artot
@xavierartot
Aug 30 2016 05:09
funny
:)
I never remember where is my toolbox
too
Abhisek Pattnaik
@abhisekp
Aug 30 2016 05:10
:D
;P
Angel J Piscola
@Redmega
Aug 30 2016 05:10
And there you have it
Egoscio
@Egoscio
Aug 30 2016 05:10
thats technically 3
Angel J Piscola
@Redmega
Aug 30 2016 05:11
Pff
var rot31 = str => {{insert one liner here}};
Boom, one line
Xavier Artot
@xavierartot
Aug 30 2016 05:11
can you copy again this code
I don't see it
?
Egoscio
@Egoscio
Aug 30 2016 05:11
poof
Angel J Piscola
@Redmega
Aug 30 2016 05:11
It was edited
Abhisek Pattnaik
@abhisekp
Aug 30 2016 05:11
:dash:
Angel J Piscola
@Redmega
Aug 30 2016 05:11
I should go back and remove mine too
Egoscio
@Egoscio
Aug 30 2016 05:11
he used a regular expression
Xavier Artot
@xavierartot
Aug 30 2016 05:12
the regex I need it
Angel J Piscola
@Redmega
Aug 30 2016 05:12
lol
I think it was just [A-Z]
Xavier Artot
@xavierartot
Aug 30 2016 05:12
in js I lost
Abhisek Pattnaik
@abhisekp
Aug 30 2016 05:12
lol... literally
Angel J Piscola
@Redmega
Aug 30 2016 05:12
@Egoscio I read somewhere that 'use strict' should be confined to function scope
Egoscio
@Egoscio
Aug 30 2016 05:13
iuno, all my code was strict, unless that screws up modules i guess its fine?
Angel J Piscola
@Redmega
Aug 30 2016 05:13
(function(){
'use strict';
//strict code
})();
//not strict code
Xavier Artot
@xavierartot
Aug 30 2016 05:13
He's using Babel
Egoscio
@Egoscio
Aug 30 2016 05:13
jes
wait no
Xavier Artot
@xavierartot
Aug 30 2016 05:13
anyway
Egoscio
@Egoscio
Aug 30 2016 05:13
not for gelato
I typically use babel for client side stuff, because Node has way better ES+ support than browser
although for node it's equally useful
Angel J Piscola
@Redmega
Aug 30 2016 05:14
oh yeah. I'd never use ES in an actual production front-end
Xavier Artot
@xavierartot
Aug 30 2016 05:14
je note
I notice
Angel J Piscola
@Redmega
Aug 30 2016 05:14
ES6**
Egoscio
@Egoscio
Aug 30 2016 05:15
Is chrome still the only browser that supports arrow functions?
Abhisek Pattnaik
@abhisekp
Aug 30 2016 05:15
Use Babel and write ES2017 code :sunglasses:
Angel J Piscola
@Redmega
Aug 30 2016 05:15
Chrome, firefrox, and edge
Egoscio
@Egoscio
Aug 30 2016 05:16
hoi i guess they advanced since i last checked
Xavier Artot
@xavierartot
Aug 30 2016 05:16
@abhisekp give me back your one line solution
Abhisek Pattnaik
@abhisekp
Aug 30 2016 05:16
lol
Egoscio
@Egoscio
Aug 30 2016 05:16
PM it :P
Xavier Artot
@xavierartot
Aug 30 2016 05:16
I have to understand the regex in js
help me
CamperBot
@camperbot
Aug 30 2016 05:16

:point_right: readme [wiki]

Depecrated Wiki!

This repo serves as an archive for the wiki and a place to report issues for our current wiki located in our forum!

Our open source community's Wiki focuses on answering your questions about learning to code and getting a coding job. We also cover in detail our:

  • Curriculum
  • Other Programming Languages
  • Local Group Communities
  • Nonprofit Projects and much more

:pencil: read more about readme on the FCC Wiki

Angel J Piscola
@Redmega
Aug 30 2016 05:16
@xavierartot Same as regex anywhere else. Best resource i"ve ever found: regexr.com
Egoscio
@Egoscio
Aug 30 2016 05:16
There's help for ya
Abhisek Pattnaik
@abhisekp
Aug 30 2016 05:16
lol
Angel J Piscola
@Redmega
Aug 30 2016 05:16
JS has no negative lookbacks
Egoscio
@Egoscio
Aug 30 2016 05:17
Tots my first choice for regex. I typically spam it over here every 2-3 hours
Angel J Piscola
@Redmega
Aug 30 2016 05:17
lookbacks in general, rather
Xavier Artot
@xavierartot
Aug 30 2016 05:17
no I want to see his solution
Angel J Piscola
@Redmega
Aug 30 2016 05:17
Good luck \with that
lol
Egoscio
@Egoscio
Aug 30 2016 05:17
Here at FCC/HJS, we're really greedy about code...
Xavier Artot
@xavierartot
Aug 30 2016 05:18
:/
Abhisek Pattnaik
@abhisekp
Aug 30 2016 05:18

@xavierartot try to solve using

  • regex
  • String#replace
  • String#fromCharCode
  • String#charCodeAt
  • modulo operator

in one line ;)

Xavier Artot
@xavierartot
Aug 30 2016 05:18
ok
Egoscio
@Egoscio
Aug 30 2016 05:18
@abhisekp Just found the solution online, I doubt yours was original :P
Abhisek Pattnaik
@abhisekp
Aug 30 2016 05:19
lol.
Xavier Artot
@xavierartot
Aug 30 2016 05:19
we can be sure
but it doesn't matter the source