These are chat archives for FreeCodeCamp/HelpJavaScript

13th
May 2016
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:00
@Chrono79 let me try it one sec
Jin Choi
@JiniHendrix
May 13 2016 00:00
hello, im working on a to-do list project and for some reason my array keeps resetting when i want to populate it with push.
also my displayed stuff disappears randomly sometimes ??????
Loganust
@Loganust
May 13 2016 00:02
lost on this one
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
Diego Mayer
@Chrono79
May 13 2016 00:03
@Loganust translate that using the table provided
tab tab is "\t \t"
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:03
@Chrono79 I don't get what to do with the index... like this?
function chunkArrayInGroups(arr, size) {
  var array = [];

 for (var index = 0; index < size; index++) {
Thomas Dean
@ThomasDean80
May 13 2016 00:04
Can anyone help me with this, the card counting question? I feel there's a more elegant solution, but even this one doesn't work, and I don't know why...
fearlessinc
@fearlessinc
May 13 2016 00:04

Can not get the data from the api call ```if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var lat = position.coords.latitude;
var lon = position.coords.longitude;
var appId = "ca56d1509ae0802e89b004b0d4f56b7c";
var url = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&appid="+ appId;
$("#data").html("latitude: "+ lat + "<br>longitude: " + lon +"<br>"+ url);
$("#getMessage").on("click", function(){
$.getJSON(url, function(results) {
console.log(results);
});
});
});
}

```

Can not get the data from the api call
```if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var lat = position.coords.latitude;
var lon = position.coords.longitude;
var appId = "ca56d1509ae0802e89b004b0d4f56b7c";
var url = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&appid="+ appId;
$("#data").html("latitude: "+ lat + "<br>longitude: " + lon +"<br>"+ url);
$("#getMessage").on("click", function(){
$.getJSON(url, function(results) {
console.log(results);
});
});
});
}

```

Thomas Dean
@ThomasDean80
May 13 2016 00:04
I don't know what happened with that URL...
Diego Mayer
@Chrono79
May 13 2016 00:04
@ThomasDean80 copy and paste the code, not that url (my eyes!!!)
Thomas Dean
@ThomasDean80
May 13 2016 00:04
Yeah, I got it confused with the CodePen link from earier. It's late...

var count = 0;

function cc(card) {
// Only change code below this line
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 7:
case 8:
case 9:
break;

  case 10:
  case 'J':
  case 'Q':
  case 'K':
  case 'A':
    count--;
    break;
  }

var whatToDo ="";
switch (count) {
  case (count <= 0):
    whatToDo = count +" Hold";
    break;
  case (count > 1):
    whatToDo = count +" Bet";
    break;
}

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Does anybody know why only the middle displayed as code?
Diego Mayer
@Chrono79
May 13 2016 00:05
@IsaacAbrahamson you can use, let's say i as index, so you can use i*size and (i+1)*size as starting position and ending position
@ThomasDean80 you can edit/delete your own posts, near the top right, the ...
elminsterrr
@elminsterrr
May 13 2016 00:07
@Chrono79 Is that better?
function getIndexToIns(startingArray, num) {
  startingArray.push(num);              //Pushing "num" element to the end of the array.

  function sortMePlease(arr) {          //Sorting array.
    function compareFunction(a, b) {
      return a - b;
    }
    arr.sort(compareFunction);
    return arr;
  }

  var x = sortMePlease(startingArray);  //Sorts starting array and pass it to var x.


  for (var j = 0; j < x.length; j++) {  //Going through x array.
    if (x[j] >= num ) {
        return x.indexOf(x[j]);         //Returning indexOf the element which is greater or even to "num" (15 in this example).
    } 
  } 

}
getIndexToIns([2, 5, 10, 20], 15); // should return 3.
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:08
@Chrono79 Is this what you mean? It worked...
function chunkArrayInGroups(arr, size) {
var array = [];

  for (var i = 0; i < arr.length / size; i++) {   
    var tempArr = arr.slice(i*size, (i+1)*size);    
    array.push(tempArr);
  } 

  return array;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2);
Diego Mayer
@Chrono79
May 13 2016 00:08
@ThomasDean80 if it's 1?
case (count > 1):
@IsaacAbrahamson yes, something like that, there are also better ways of doing it, but refactor later
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:09
@Chrono79 Thanks man! (Now to figure out why it worked xD)
CamperBot
@camperbot
May 13 2016 00:09
isaacabrahamson sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 729 | @chrono79 |http://www.freecodecamp.com/chrono79
Thomas Dean
@ThomasDean80
May 13 2016 00:09
Thanks @Chrono79, still doesn't solve the problem though, fails all tests
CamperBot
@camperbot
May 13 2016 00:09
thomasdean80 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 730 | @chrono79 |http://www.freecodecamp.com/chrono79
Thomas Dean
@ThomasDean80
May 13 2016 00:09
I changed it to case (count > 0):
NEETWizardJanus
@NEETWizardJanus
May 13 2016 00:09
I'm such a failure. I can't even do an analog clock. why can't I write svg stuff with jQuery? I've been at this for like 18 hours. I'm fucking retarded.
richiedSIS
@richiedSIS
May 13 2016 00:10

Hi guys, I'm stuck on the record collection excercise.
function updateRecords(id, prop, value) {

if(value!=="" && prop!=="tracks")
id[prop]=value;
else if(prop==="tracks"&&value!=="")
id.tracks.push(value);
else if(value==="")
delete id[prop];

return collection;
}

// Alter values below to test your code
//updateRecords(2548, "artist", "");
updateRecords(5439, "artist", "ABBA");

how do I format the code so it sends correctly in the chat?
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:10
@richiedSIS put ``` before and after code
Diego Mayer
@Chrono79
May 13 2016 00:10

@ThomasDean80 use if/else

var whatToDo ="";
switch (count) {
  case (count <= 0):
    whatToDo = count +" Hold";
    break;
  case (count > 1):
    whatToDo = count +" Bet";
    break;
}

this won't work at all

richiedSIS
@richiedSIS
May 13 2016 00:11

```function updateRecords(id, prop, value) {

if(value!=="" && prop!=="tracks")
id[prop]=value;
else if(prop==="tracks"&&value!=="")
id.tracks.push(value);
else if(value==="")
delete id[prop];

return collection;
}

// Alter values below to test your code
//updateRecords(2548, "artist", "");
updateRecords(5439, "artist", "ABBA");
```

elminsterrr
@elminsterrr
May 13 2016 00:12
@Chrono79 can you please look if this solution is better? Or can I something improve:
function getIndexToIns(startingArray, num) {
  startingArray.push(num);              //Pushing "num" element to the end of the array.

  function sortMePlease(arr) {          //Sorting array.
    function compareFunction(a, b) {
      return a - b;
    }
    arr.sort(compareFunction);
    return arr;
  }

  var x = sortMePlease(startingArray);  //Sorts starting array and pass it to var x.


  for (var j = 0; j < x.length; j++) {  //Going through x array.
    if (x[j] >= num ) {
        return x.indexOf(x[j]);         //Returning indexOf the element which is greater or even to "num" (15 in this example).
    } 
  } 

}
getIndexToIns([2, 5, 10, 20], 15); // should return 3.
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:12
@richiedSIS you need to hit return (enter) after first ```
then its fine
ex: ENTER code ENTER
Thomas Dean
@ThomasDean80
May 13 2016 00:12
@Chrono79, is it because it's conditional?
richiedSIS
@richiedSIS
May 13 2016 00:12
function updateRecords(id, prop, value) {

  if(value!=="" && prop!=="tracks")
    id[prop]=value;
  else if(prop==="tracks"&&value!=="")
    id.tracks.push(value);
  else if(value==="")
    delete id[prop];




  return collection;
}

// Alter values below to test your code
//updateRecords(2548, "artist", "");
updateRecords(5439, "artist", "ABBA");
nostrahistoria
@nostrahistoria
May 13 2016 00:12

Hi. Can someone help me with Nesting For Loops. ```
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++) {
multiplyAll * arr[i];
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

```

richiedSIS
@richiedSIS
May 13 2016 00:13
there we go, thanks!
I'm getting the error
Cannot create property
NEETWizardJanus
@NEETWizardJanus
May 13 2016 00:13
is there somewhere retards can go to get their hand held through this? I know there's the freecodecamp but... ... whatever.
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:14
@NEETWizardJanus I think ObamaCare covers retardation, you should check your insurance policy...
NEETWizardJanus
@NEETWizardJanus
May 13 2016 00:15
I'm in Canada, but I'm not retarded enough to have a babysitter. I'm just a plain old stupid loser.
Thomas Dean
@ThomasDean80
May 13 2016 00:15
Anyway, it worked, thanks @Chrono79
CamperBot
@camperbot
May 13 2016 00:15
thomasdean80 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: thomasdean80 already gave chrono79 points
NEETWizardJanus
@NEETWizardJanus
May 13 2016 00:15
Who's almost 40 with no useful skills.
I'm on autismbux though, but I don't know how many more years I can tolerate being conscious in this miserable state.
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:16
@NEETWizardJanus calm down man, you'll get it lol
nostrahistoria
@nostrahistoria
May 13 2016 00:17
I apologize for interrupting, but can someone help with Nesting For Loops?
NEETWizardJanus
@NEETWizardJanus
May 13 2016 00:17
I've been at this for 18 hours today. This is the 2nd day I've gone at it for a whole day. and all I've accomplished is editing someone else's code, but it's messy as hell. huge walls of HTML and CSS.
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:17
@nostrahistoria Excersize name?
nostrahistoria
@nostrahistoria
May 13 2016 00:18
Nesting For Loops
@IsaacAbrahamson
elminsterrr
@elminsterrr
May 13 2016 00:18
@NEETWizardJanus be patient and persevering, you must be stubborn
NEETWizardJanus
@NEETWizardJanus
May 13 2016 00:18
this is what I managed to do. but I wanted to be able to scale it to window size and rotate stuff. http://codepen.io/NEETWizardJanus/pen/KzJNEq
elminsterrr
@elminsterrr
May 13 2016 00:18
@NEETWizardJanus Maybe it is enouth work for today?
nostrahistoria
@nostrahistoria
May 13 2016 00:18
@IsaacAbrahamson It is in JavaScript
NEETWizardJanus
@NEETWizardJanus
May 13 2016 00:19
yeah. I should probably cut my losses. T_T
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:19
@nostrahistoria you need to put another for loop inside your existing for loop
@nostrahistoria
nostrahistoria
@nostrahistoria
May 13 2016 00:20
Can you give me the code to learn from? I learn from studying examples. I never took a class on coding in my life.
NEETWizardJanus
@NEETWizardJanus
May 13 2016 00:20
I don't understand what the hell it's doing. drawing a circle shouldn't be complicated. Why do I have to understand borders and unit types so precisely? I draw a shape at 100% size and it puts it in a little box.
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:20
@nostrahistoria Welcome to FreeCodeCamp, your taking a corse now
nostrahistoria
@nostrahistoria
May 13 2016 00:20
Thanks! @IsaacAbrahamson
CamperBot
@camperbot
May 13 2016 00:20
nostrahistoria sends brownie points to @isaacabrahamson :sparkles: :thumbsup: :sparkles:
:cookie: 190 | @isaacabrahamson |http://www.freecodecamp.com/isaacabrahamson
nostrahistoria
@nostrahistoria
May 13 2016 00:21
@IsaacAbrahamson True
what is wrong with my code
Jonathan Schwob
@JonathanSchwob
May 13 2016 00:21
function multiplier(factor) {
  return function(number) {
    return number * factor;
  };
}

var twice = multiplier(2);
console.log(twice(5));
// → 10
can someone please explain how this code returns 10. it seems the only function declared is multiplier, so how does passing a parameter on the end of twice work ?
nostrahistoria
@nostrahistoria
May 13 2016 00:21
```

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++) {
multiplyAll * arr[i];
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:21
@nostrahistoria
  // Example
  for (var index = 0; index < arr.length; index++) {
    for (var index2 = 0; index2 < arr[index].length; index2++) {

    }
  }
Diego Mayer
@Chrono79
May 13 2016 00:21

@elminsterrr

  for (var j = 0; j < x.length; j++) {  //Going through x array.
    if (x[j] >= num ) {
        return x.indexOf(x[j]);         //Returning indexOf the element which is greater or even to "num" (15 in this example).
    } 
  }

simply return x.indexOf(num) instead of using for loop

Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:22
@nostrahistoria you need a second for loop to iterate through nested arrays
then put your code in second for loop
nostrahistoria
@nostrahistoria
May 13 2016 00:23
I understand it theoretically, but I am not sure how to do it for the example.
Jacob Hodgins
@JacobHodg
May 13 2016 00:24
Hello all. I am trying to complete one of the checkpoints for the JavaScript section and I cannot figure out how to have space put between a string and variable
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:24
@nostrahistoria Try my example
nostrahistoria
@nostrahistoria
May 13 2016 00:24
@IsaacAbrahamson I did.
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:25
@nostrahistoria
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var index = 0; index < arr.length; index++) {
    for (var index2 = 0; index2 < arr[index].length; index2++) {
      product *= arr[index][index2];
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
nostrahistoria
@nostrahistoria
May 13 2016 00:25

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length; i++) {
    for (var i = 0; i <arr.length; i++) {
}
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Jacob Hodgins
@JacobHodg
May 13 2016 00:25
for example, if myNoun="big", and I write "the " + myNoun + "dog" and it comes out as - the bigdog.
nvm, I figured it out
nostrahistoria
@nostrahistoria
May 13 2016 00:26
Thanks @IsaacAbrahamson It worked! I will study your code now. have a super evening!
CamperBot
@camperbot
May 13 2016 00:26
nostrahistoria sends brownie points to @isaacabrahamson :sparkles: :thumbsup: :sparkles:
:warning: nostrahistoria already gave isaacabrahamson points
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:26
@nostrahistoria No problem, I'm not sure its exactly right, I just started JavaScript, but it worked for me.
nostrahistoria
@nostrahistoria
May 13 2016 00:26
You must be a pro.
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:27
@nostrahistoria I've a year and a half experience of C# and Java
nostrahistoria
@nostrahistoria
May 13 2016 00:27
@IsaacAbrahamson Cool. I never took a class on coding. However, I have made 57 web sites.
fijeko
@fijeko
May 13 2016 00:28
@JonathanSchwob here is a long and good explanation
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:28
@nostrahistoria 57 dude, wow,
how long you been coding?
nostrahistoria
@nostrahistoria
May 13 2016 00:29
@IsaacAbrahamson I learned HTML back in 2005 or 2006, but I have not used it much since
@IsaacAbrahamson How about you?
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:30
@nostrahistoria I started teaching myself C# a year and a half ago, then learned HTML, CSS, Java along the way. Started free code camp a week or two ago because I want to learn Javascript and web programming this summer vacation.
nostrahistoria
@nostrahistoria
May 13 2016 00:31
@IsaacAbrahamson Cool. What is your score so far?
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:32
@nostrahistoria 190 points, in about 7-8 days actual programming
nostrahistoria
@nostrahistoria
May 13 2016 00:32
Cool. @IsaacAbrahamson Good luck with it. You seem to know a lot.
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:32
@nostrahistoria I try to do about an hour a night after high school.
nostrahistoria
@nostrahistoria
May 13 2016 00:32
Oh, you are in HS. Wow.
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:34
@nostrahistoria I created a game server when i was 14, I've dreamed about being a web developer since I was 6
Aryan
@aryandua
May 13 2016 00:34
@coymeetsworld can you help me??
nostrahistoria
@nostrahistoria
May 13 2016 00:35
@IsaacAbrahamson Cool. My friend found a site with free CSS templates. Afterwards, I got the idea of making a web design company. It has not made a lot of money, but less than $10,000 probably
I just do it on the side.
Aryan
@aryandua
May 13 2016 00:36
Wow @IsaacAbrahamson 14?
I am 12 and i hope i can get something by 18
:)
nostrahistoria
@nostrahistoria
May 13 2016 00:36
Wow. I am thirty-four and I am starting to take pre-requisites to go into a computer science program.
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:36
Its never to late to learn xD
I read about an 80 year old who started his own company once
Aryan
@aryandua
May 13 2016 00:37
wow! 80
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:37
And just this last week some 10 year old prodigy hacked Facebook's test server.
Aryan
@aryandua
May 13 2016 00:37
@coymeetsworld are you there?
@IsaacAbrahamson can you help me?
I am stuck on the Random quotes
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:38
@aryandua haven't got there yet
@IsaacAbrahamson oh ok nvm
@IsaacAbrahamson you are in high school?
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:39
@aryandua Yeah, I'm 16
Aryan
@aryandua
May 13 2016 00:39
nice
I am in elementary lol
where do you live?
Aryan
@aryandua
May 13 2016 00:41
hahaha :)
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:41
lol, I'm in Eastern Iowa, hence the bears fan
John
@tertiaryidentifier
May 13 2016 00:41
I'm really really confused by the "stand in line" challenge ...

function nextInLine(arr, item) {
// Your code here

arr.push(item);
arr.shift();
return item; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

///
whoops
Gerard Dawson
@gerarddawson
May 13 2016 00:42
Have to share a small victory...just solved "confirm the ending" in about 1/10 of the time it took me to solve Return Largest Numbers in Array @sjames1958gm
John
@tertiaryidentifier
May 13 2016 00:42

function nextInLine(arr, item) {
  // Your code here

  arr.push(item);
  arr.shift();
  return item;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Suren VB
@surenz298
May 13 2016 00:42
@aryandua - You id on the button tweet is misspelled - also you are referring to a ID “tweet” which you have never declared in your html
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:42
@gerarddawson nice, that largest numbers was a bear
John
@tertiaryidentifier
May 13 2016 00:42
could someone help ~~~
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:42
@tertiaryidentifier I'll look at it here
qeurago
@qeurago
May 13 2016 00:43
function reverseString(str) {
  var strReverse = str.split('').reverse().join('');
  return str;
}

reverseString("hello");
why doesnt this work
Moisés Man
@moigithub
May 13 2016 00:43
@qeurago cuz u returning str.. but ur new string is on strReverse variable
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:43
@tertiaryidentifier your doing arr.shift() but your not assigning it to any array
qeurago
@qeurago
May 13 2016 00:44
right
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:44
This message was deleted
John
@tertiaryidentifier
May 13 2016 00:44
what array should i assign it to? @IsaacAbrahamson
qeurago
@qeurago
May 13 2016 00:44
whoops
Yomi
@Joll59
May 13 2016 00:44
guys i just want another set of eyes, I cant figure why this is almost working but not quite. Thank you
function rot13(str) {
  str = str.toUpperCase();
var code ="";
  for (var i=0; i<str.length;i++){

 if (str.charCodeAt(i) < 65 && str.charCodeAt(i) > 90){
      code += String.fromCharCode(str.charCodeAt(i));}

  else if (str.charCodeAt(i) >= 65 && str.charCodeAt(i) <=77){
        code += String.fromCharCode(str.charCodeAt(i) + 13);}

   else if (str.charCodeAt(i) >= 78 && str.charCodeAt(i) <=90){
          code += String.fromCharCode(str.charCodeAt(i) - 13);}

  }
  return code;

}

// Change the inputs below to test
  rot13("SERR PBQR PNZC");
Aryan
@aryandua
May 13 2016 00:44
@coymeetsworld are you therre?
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:45
@tertiaryidentifier Try
return arr.push(item).shift()
Moisés Man
@moigithub
May 13 2016 00:45
@tertiaryidentifier array.shift() remove AND return the removed element
ur funciton should give back (return) the element removed
Aryan
@aryandua
May 13 2016 00:45
@coymeetsworld are you there
Moisés Man
@moigithub
May 13 2016 00:45
@IsaacAbrahamson that wont work.. cuz.. push.. dont return an array.. but a number
shift on a number..error :)
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:46
screw it
let me see what i did
John
@tertiaryidentifier
May 13 2016 00:46
thank you for correcting him, @moigithub , but I have NO Idea what you are telling me to do lol
CamperBot
@camperbot
May 13 2016 00:46
tertiaryidentifier sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1128 | @moigithub |http://www.freecodecamp.com/moigithub
Daniel Parvin
@danielparvin
May 13 2016 00:47
Hello all!
Moisés Man
@moigithub
May 13 2016 00:47
@tertiaryidentifier shift() return a value.. u do something with that value
Yomi
@Joll59
May 13 2016 00:47
@danielparvin Hello Daniel!!!!
Welcome!
richiedSIS
@richiedSIS
May 13 2016 00:47
Can someone help me out with this? I'm not sure what the undefined is referring to
TypeError: Cannot set property 'artist' of undefined
function updateRecords(id, prop, value) {

  if(value!=="" && prop!=="tracks")
    id[prop]=value;
  else if(prop==="tracks"&&value!=="")
    id.tracks.push(value);
  else if(value==="")
    delete id[prop];

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Yomi
@Joll59
May 13 2016 00:48
shouldn't there be a space between ""....so its " "
i am guessing here
Moisés Man
@moigithub
May 13 2016 00:48
@richiedSIS all those key/properties belongs to an object named collection (check above ur code)
so.. u need to include collection variable on ur code
John
@tertiaryidentifier
May 13 2016 00:48
and thus commences my semi-daily "javascript has fried my brain"
Yomi
@Joll59
May 13 2016 00:49
@tertiaryidentifier ahh i suffer from that multiple times a day and come back for more, i am not the brightest
Chris Lacaille
@ChrisL108
May 13 2016 00:49
Had a question on jQuery animation
Daniel Parvin
@danielparvin
May 13 2016 00:49
@richiedSIS Yes, you should delete collection[id][prop], I think...
Moisés Man
@moigithub
May 13 2016 00:49
@tertiaryidentifier return arr.shift()
or store somewhere.. then return
var myElem = arr.shift();
return myElem;
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:49
@tertiaryidentifier
arr.push(item);
  var newArr = arr.shift();
  return newArr;  // Change this line
John
@tertiaryidentifier
May 13 2016 00:49
@Joll59 tbh the freecodecamp stuff on CSS and HTML was great. this javascript stuff is super confusing and not very helpful at identifying what I SHOULD be doing
Yomi
@Joll59
May 13 2016 00:49
This message was deleted
CamperBot
@camperbot
May 13 2016 00:49
no wiki entry for: ceaser cipher
Chris Lacaille
@ChrisL108
May 13 2016 00:50
$cir.on("click", function() {
  $(this).animate({
    width: "200px",
    borderRadius: "10px"
  });
  return false;
});
Why when I take out the return false; the animation fires then immediately reverts to orignial dimensions?
Yomi
@Joll59
May 13 2016 00:50
Help Caesars Cipher
CamperBot
@camperbot
May 13 2016 00:50

:point_right: algorithm caesars cipher [wiki]

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :memo:

:checkered_flag: Problem Explanation:

  • You need to write a function, which will take a string encoded with
    Caesar cipher as a parameter and decode it.
  • The one used here is ROT13 where the value of the letter is
    shifted by 13 places.
    e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
  • You have to shift it back 13 positions, such that 'N' ↔ 'A'.

:pencil: read more about algorithm caesars cipher on the FCC Wiki

Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:50

oh nvm

you beat me to it

Daniel Parvin
@danielparvin
May 13 2016 00:51
@ChrisL108 That's weird; I don't know.
Moisés Man
@moigithub
May 13 2016 00:51
@ChrisL108 probably cuz the element $cir have some default behavior.. like refreshing maybe ?..
whats $cir refering to ?
Chris Lacaille
@ChrisL108
May 13 2016 00:51
Someone else gave me the solution to put the return false in there but idk what it's doing
hmm
Daniel Parvin
@danielparvin
May 13 2016 00:51
@ChrisL108 Hmmm indeed.
Chris Lacaille
@ChrisL108
May 13 2016 00:52
does ret false do something like preventDefault()? maybe?
Moisés Man
@moigithub
May 13 2016 00:52
probably
if its a form..the default behavior when submit is refreshing
Chris Lacaille
@ChrisL108
May 13 2016 00:53
Oh sorry, the $cir is actually a <input type="text">
Yomi
@Joll59
May 13 2016 00:53
omg something as simple as changing a single item
Daniel Parvin
@danielparvin
May 13 2016 00:53
I'm trying to figure out the RegExp function in "No repeats please." Is there a shortcut to specifying each and every letter in the expression /a{2,}|b{2,}/ ?
Yomi
@Joll59
May 13 2016 00:53
i am not the smartest
thanks team
Daniel Parvin
@danielparvin
May 13 2016 00:54
@Joll59 You're welcome.
John
@tertiaryidentifier
May 13 2016 00:56
aaaaaaand one more javascript challenge down ... time to take a 24 hour break lol
Daniel Parvin
@danielparvin
May 13 2016 00:56
@tertiaryidentifier Congrats!
EricOber
@EricOber
May 13 2016 00:56
hey guys can anyone help me with a challenge?
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:56
@tertiaryidentifier lol
Daniel Parvin
@danielparvin
May 13 2016 00:56
@Am3ricanPaladin Sure.
EricOber
@EricOber
May 13 2016 00:56
thanks
im on the generate random fractions with javascript challenge. no understanding what to do/wite
write*

function randomFraction() {

  // Only change code below this line.
  var x = Math.random;

  return x;

  // Only change code above this line.
}
thats my code
John
@tertiaryidentifier
May 13 2016 00:57
is javascript the programming language they use on graphing calculators?
I remember writing a basic quadratic formula program with similar language
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:58
@Am3ricanPaladin you forgot () for method lol
EricOber
@EricOber
May 13 2016 00:58
like here

```js
function randomFraction() {

// Only change code below this line.
var x = Math.random();

return x;

// Only change code above this line.
}

Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:58
@Am3ricanPaladin
return Math.random();
EricOber
@EricOber
May 13 2016 00:59
like this?
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:59
yeah
EricOber
@EricOber
May 13 2016 00:59

function randomFraction() {

  // Only change code below this line.


  return Math.random();

  // Only change code above this line.
}
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 00:59
both ways you put should work
EricOber
@EricOber
May 13 2016 00:59
its not
Moisés Man
@moigithub
May 13 2016 00:59
refresh browser
EricOber
@EricOber
May 13 2016 01:00
ah ha!
thank you all
Daniel Parvin
@danielparvin
May 13 2016 01:01
I'm trying to figure out the RegExp function in "No repeats please." Is there a shortcut to specifying each and every letter in the expression /a{2,}|b{2,}/ ?
I need to identify repeating characters in a string.
Moisés Man
@moigithub
May 13 2016 01:02
like aa , bb
?
Daniel Parvin
@danielparvin
May 13 2016 01:02
@moigithub Yes.
Moisés Man
@moigithub
May 13 2016 01:02
u can use groups
lemme check
something like /(.)\1/ or was using $1.. i dont remembe
richiedSIS
@richiedSIS
May 13 2016 01:03
@moigithub When I added the collection variable to the code I still get the same undefined error. Do I need to pass in the collection as a parameter?
// Only change code below this line
function updateRecords(id, prop, value) {

  if(value!=="" && prop!=="tracks")
    collection.id[prop]=value;
  else if(prop==="tracks"&&value!=="")
    collection.id.tracks.push(value);

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
NEETWizardJanus
@NEETWizardJanus
May 13 2016 01:03
is there a better way to code jQuery code to set polygon points using variables without it looking like a mess like this? : $(".clocksvg").html('<circle cx=50% cy=50% r='+face+' stroke="red" stroke-width="4" fill="black" /><polygon points="'+(xcent-handsecwid)+','+ycent+' '+xcent+','+(ycent-handseclen)+' '(xcent+handsecwid)+','+ycent+' '+xcent+','+(ycent+handseclen)+'" fill='+handseccol+'/>');
I keep having to put in '+varname+' '+varname+'
and I think too many of them break it somehow.
Daniel Parvin
@danielparvin
May 13 2016 01:04
@moigithub Whoa! That's totally right.
@moigithub Thanks a million.
CamperBot
@camperbot
May 13 2016 01:04
danielparvin sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1129 | @moigithub |http://www.freecodecamp.com/moigithub
Daniel Parvin
@danielparvin
May 13 2016 01:04
@moigithub I thought that I had tried that.
Moisés Man
@moigithub
May 13 2016 01:06
@richiedSIS nope... collection is a global variable no need to pass...
id like a prop is a variable.. so u can NOT use dot notation
NEETWizardJanus
@NEETWizardJanus
May 13 2016 01:07
how do I make a CVS shape in jQuery using variables? My code keeps breaking. http://codepen.io/NEETWizardJanus/pen/YqMyjK?editors=1010
my circle just disappears when the polygon after it breaks.
coderCarlitos
@coderCarlitos
May 13 2016 01:09
Need some help on Basic Algorithm scripting Seek and Destroy https://www.freecodecamp.com/challenges/seek-and-destroy.
function doesNotContain(val) {
  return val !== this;
}

function destroyer(arr , arg) {
  var test = [];

  for (var i = 1; i < arguments.length; i+= 1) {
   arr = arr.filter(doesNotContain, arguments[i]);
   test = test.concat(arr[i]);
  }

  return arr;


  //returns [1,5,1] "destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3) should return [1, 5, 1]."
  //Why does [1,5,1] !== [1, 5, 1] and how do you make the first the same format as the latter?
  //both test true for Array.isArray()...
  //... :'(
  // the MOST frustrating part is that return arguments[0] == [1, 2, 3, 1, 2, 3] is FALSE....
}


destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Aryan
@aryandua
May 13 2016 01:09
@NEETWizardJanus looks nice :)
you are doing good!
NEETWizardJanus
@NEETWizardJanus
May 13 2016 01:10
I can't find any jQuery options to fix this, like append text in between tags. You can only rewrite it.
appendTo???
Satchmo37
@Satchmo37
May 13 2016 01:18
Smallest Common Multiple

Smallest Common Multiple

function smallestCommons(arr) {

  var max = Math.max.apply(null, arr);
  var min = Math.min.apply(null, arr);
  var test = createTestArray(max, min);

  //Create array filled with all number between the max and min
  function createTestArray(mx, mn) {
    var arr = [];
    for(var i = mx; i >= mn; i--) {
    arr.push(i);
    }
    return arr;
  }


  //Create function to test two numbers for their lowest common multiple  
  function expoTest(a, b) {
    var init = a;
    while(init % b !== 0){
      init += a;
    } return init;
  }


  //Test the first two number in the array to find their lowest common multiple
  var expo = expoTest(test[0], test[1]);


  //Create loop to inject each subsequent number in array into expoTest
  for(var i = 2; i <= test.length; i ++){
    expo = expoTest(expo, test[i]);
    console.log(expo);
  }

  return expo;

}

I feel like I'm really close with this, when I use my expoTest function, and manually insert the result in with the next number in the array I get the result I want. But when I run the function, I get numbers that are far to large. Any help with this would be amazing!

Andre Jensen
@andrejensen302
May 13 2016 01:23
blob
Hey everyone, my question on this is not "what do I do" so much as "I'm really confused at how this code worked". This is the code I used for Falsy Bouncer and it passed all the tests.
Anybody care to explain?
Justin Woodward
@jwoo92
May 13 2016 01:23
im currently working on the random quote machine. i 'believe' i am on the right track, but i have been struggling with grasping how to properly use an API. here is what i have currenty. http://codepen.io/jwoo/pen/yOwxXZ?editors=0010
Aryan
@aryandua
May 13 2016 01:28
@jwoo92 hey Justin whats up?
I made also working on a random Quote machin
look what i got
the tweet button doesnt work though
NEETWizardJanus
@NEETWizardJanus
May 13 2016 01:29
god damnit, why did IRC tell me to use jQuery to modify SVC shapes with variables? Too many variables just break it.
Aryan
@aryandua
May 13 2016 01:29
@NEETWizardJanus can you not use bad words when i am here?
NEETWizardJanus
@NEETWizardJanus
May 13 2016 01:29
sorry.
Aryan
@aryandua
May 13 2016 01:29
its fine
NEETWizardJanus
@NEETWizardJanus
May 13 2016 01:30
Naw, I get a bit toxic.
too much anger, blasted all over the place.
96street
@96street
May 13 2016 01:31

function truncateString(str, num) {

    str.slice(0, 5);

  return str;
}

truncateString("abcdefghij", 11);
how come this doesn't return 'abcde'? It returns the whole string
Aryan
@aryandua
May 13 2016 01:31
@NEETWizardJanus what challenge are you on?
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 01:31
Working on Mutations, can someone tell me whats wrong with code? 90% of tests works:
function mutation(arr) {
  var chars = arr[1].split('');

  for (var i = 0; i < arr.length; i++) {
    if (!arr[0].indexOf(chars[i])) {
      return false;
    }
  }

  return true;
}

mutation(["floor", "for"]);
NEETWizardJanus
@NEETWizardJanus
May 13 2016 01:32
@aryandua I jumped around. but I did look at the jQuery section. ... I'm not sure appendTo will really fix my problem though.
Aryan
@aryandua
May 13 2016 01:32
what are you trying to do?
Just follow everythin FCC gives you
Since you are skipping around you are getting frustrated
follow the whole thing
NEETWizardJanus
@NEETWizardJanus
May 13 2016 01:33
but I want to do more than that basic stuff.
Aryan
@aryandua
May 13 2016 01:34
but you are not getting the advanced stuff
NEETWizardJanus
@NEETWizardJanus
May 13 2016 01:34
none of it teaches me how to deal with variables or shapes or non-grid layouts.
Aryan
@aryandua
May 13 2016 01:34
why do you want to learn that?
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 01:34
@96street your not setting your slice to anything, try
str = str.slice....
96street
@96street
May 13 2016 01:35
ahh shit...thanks @IsaacAbrahamson
Aryan
@aryandua
May 13 2016 01:35
@96street language!!
dont use ^&(# in front of me
i am 12!
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 01:35
^
Carlos Antonio
@fulvi0
May 13 2016 01:36

Hi, i’m working still :worried: on the challenge of random quotes, and i think i’m getting problem with the api, i got this like for the JSON but the structure doesnt look like a JSON; do i have to do something to get this structure, do i missing somthing?

http://quotes.stormconsultancy.co.uk/random.json

NEETWizardJanus
@NEETWizardJanus
May 13 2016 01:36
@aryandua because I want to make a clock. because I made one 20 years ago in C++ easily and I want to do it again and I thought it would be easier but it's very very very very much not. and because maybe web coding would help for later projects like web databases and their GUI or graphs or something.
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 01:36
help mutations
CamperBot
@camperbot
May 13 2016 01:36

:point_right: algorithm mutations [wiki]

Problem Explanation:

  • Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..
:pencil: read more about algorithm mutations on the FCC Wiki
Aryan
@aryandua
May 13 2016 01:37
@NEETWizardJanus follow FCC and you will easily make one
hey @NEETWizardJanus why dont you make the same clock in C++
?
I am guessing you are very good at C++
so make it in C++ :)
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 01:47
nvm got it working
Stephen James
@sjames1958gm
May 13 2016 01:52
@gerarddawson :+1: some just come to you easier than others.
Wendy Medeiros
@wendyr21
May 13 2016 01:53
this is a stupid question and hate that im struggling with it but on the Stand in Line test. for the "nextInline" function i dont really understand what needs to be sent
nextInLine([5,6,7,8,9], 1) should return 5
96street
@96street
May 13 2016 01:53
what's the easiest way to remove all commas in a string?
Wendy Medeiros
@wendyr21
May 13 2016 01:53
portion that is confusing me
Stephen James
@sjames1958gm
May 13 2016 01:53
@96street .replace and regular expressions
96street
@96street
May 13 2016 01:54
so str.replace(/,);? @sjames1958gm
NEETWizardJanus
@NEETWizardJanus
May 13 2016 01:54
@aryandua sorry. was AFK. I get frustrated with stuff like compilers and libraries and now I'm in Ubuntu where I might be worse off than in Windows. and like I said, I wanted to find a project I was motivated to work on that would help me towards databases. one of my dreams was to display a database of my toy collection the way I had manually done it with HTML ages ago.
Aryan
@aryandua
May 13 2016 01:55
ok continue @NEETWizardJanus you will get it :)
I believe in you :)
Wendy Medeiros
@wendyr21
May 13 2016 01:55
nvr mind i think i got it
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 01:55
@96street no. str.replace(/,+/);
I believe
yours only finds first comma
96street
@96street
May 13 2016 01:55
what does '+' do there? @IsaacAbrahamson
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 01:56
it checks for all occurances of the ',' not just the first one

Matches the preceding expression 1 or more times. Equivalent to {1,}.

For example, /a+/ matches the 'a' in "candy" and all the a's in "caaaaaaandy", but nothing in "cndy".

NEETWizardJanus
@NEETWizardJanus
May 13 2016 01:56
@aryandua maybe if I yo-yo back and forth between my over-ambitious projects that seem like they shouldn't be hard, and some of the more advanced stuff from FCC, maybe they'll meet in the middle.
96street
@96street
May 13 2016 01:57
cndy has no a's so why would it match there?
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 01:58
it wouldn't match there. "it would find nothing in cndy"
Stephen James
@sjames1958gm
May 13 2016 01:58
@IsaacAbrahamson This /,+/ will find the first , or sequence of commas /,/g will find all commas
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 01:58
@sjames1958gm yes, ty
CamperBot
@camperbot
May 13 2016 01:58
isaacabrahamson sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1079 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 01:58
crap
i always forget about the global g
xD
96street
@96street
May 13 2016 02:00
for some reason replace() isn't working:

function truncateString(str, num) {

  var answer = [];
  var remove  = "";

  if(str.length > num) {
    remove = str.slice(num, str.length);
    str = str.substring(0, str.length - remove.length);
    answer.push(str);
    answer.push('...');
    answer = answer.join();
    answer.replace(/,/g);  
  }



  return answer;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
I's returning: A-tisket a-,...
Should be: A-tisket a-...
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 02:01
you forgot the + in regex
after all that...
96street
@96street
May 13 2016 02:02
answer.replace(/,+/g); ?
that's not working either
Stephen James
@sjames1958gm
May 13 2016 02:03
@96street Replace returns a value it doesn't change the string. all strings are immutable
newstring = answer.replace(/,/g);
96street
@96street
May 13 2016 02:04
ahh k cheers
Stephen James
@sjames1958gm
May 13 2016 02:04
@96street Also, answer = str + '...'; is much clearer than building an array and joining
96street
@96street
May 13 2016 02:05
Yeah my code is terrible
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 02:05
@sjames1958gm is it better to do that or str = str.concat("...");
is there any difference?
Wendy Medeiros
@wendyr21
May 13 2016 02:06
its the Stand In Line one. Thanks1
Stephen James
@sjames1958gm
May 13 2016 02:06
IMO the + rather than concat, likely the same result
Isaac Abrahamson
@IsaacAbrahamson
May 13 2016 02:06
@sjames1958gm ok thx
CamperBot
@camperbot
May 13 2016 02:06
isaacabrahamson sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: isaacabrahamson already gave sjames1958gm points
Stephen James
@sjames1958gm
May 13 2016 02:06
@wendyr21 General question about the challenge or something specific.
Wendy Medeiros
@wendyr21
May 13 2016 02:08
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
96street
@96street
May 13 2016 02:09
Ok so i've fixed it up abit but it's still abit off the answer, not sure why:

function truncateString(str, num) {

  var answer = [];
  var remove  = "";


  if(str.length > num) {
    remove = str.slice(num, str.length);
    str = str.substring(0, str.length - remove.length);
    answer.push(str);
    answer = str + '...';
  }



  return answer;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Truncate a String
It's returning 'A tisket a-...' but should be returning 'A tisket...'
Wendy Medeiros
@wendyr21
May 13 2016 02:09
i think i have the code part right but its the things i need to return that im having issues with
Stephen James
@sjames1958gm
May 13 2016 02:11
@96street the result is supposed to be a string. no reason to have an array. Is it failing any specific test?
@wendyr21 You are supposed to remove the first element in the passed in array and return it.
Wendy Medeiros
@wendyr21
May 13 2016 02:11
@96street how did you do a print screen into this?
Stephen James
@sjames1958gm
May 13 2016 02:11
help format
CamperBot
@camperbot
May 13 2016 02:11

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

96street
@96street
May 13 2016 02:12
@sjames1958gm answer isn't an array
well it is initially so I probably should of done it differently
Should I do toString();?
Stephen James
@sjames1958gm
May 13 2016 02:13
@96street Yes, but answer = [] and answer.push() confuses the issue.
Jacob Hodgins
@JacobHodg
May 13 2016 02:13
Inside function fun1, assign 5 to oopsGlobal without using the var keyword.
Jatto Abdulqahhar
@jattoabdul
May 13 2016 02:13
The answer is right because of the value of num u are passing through... 11
Stephen James
@sjames1958gm
May 13 2016 02:13
@96street No just var answer ="";
96street
@96street
May 13 2016 02:13
True i'll fix that up
Stephen James
@sjames1958gm
May 13 2016 02:14
@96street Are you handling the special case of string length < 3?
96street
@96street
May 13 2016 02:14

function truncateString(str, num) {

  var answer = "";
  var remove  = "";


  if(str.length > num) {
    remove = str.slice(num, str.length);
    str = str.substring(0, str.length - remove.length);
    answer = str + '...';
  }

  return answer;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Stephen James
@sjames1958gm
May 13 2016 02:14
@96street answer = answer.toString(); answer is already a string.
Iago Breno
@ibacaraujo
May 13 2016 02:15
@96street another point is the result, look the addition of the 3 in size with '...'
96street
@96street
May 13 2016 02:15
right
Wendy Medeiros
@wendyr21
May 13 2016 02:15
how do you guys paste the functions into the screen its not letting me
96street
@96street
May 13 2016 02:15
I don't get the < 3 instruction it's asking, what exactly is it?
Sean DiSanti
@badc0ded
May 13 2016 02:16
@wendyr21 it's just formatting, read this:
help format
CamperBot
@camperbot
May 13 2016 02:16

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Wendy Medeiros
@wendyr21
May 13 2016 02:17
@badc0ded @badc0ded thanks :)
CamperBot
@camperbot
May 13 2016 02:17
wendyr21 sends brownie points to @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 348 | @badc0ded |http://www.freecodecamp.com/badc0ded
Sean DiSanti
@badc0ded
May 13 2016 02:17
no problem
96street
@96street
May 13 2016 02:17
My answer is a couple of characters off, why is this?

function truncateString(str, num) {

  var answer = "";
  var remove  = "";


  if(str.length > num) {
    remove = str.slice(num, str.length);
    str = str.substring(0, str.length - remove.length);
    answer = str + '...';
  }

  return answer;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Iago Breno
@ibacaraujo
May 13 2016 02:19
@96street In this case, num is greater than 3, so you should take into account the addition of '...' in the answer
96street
@96street
May 13 2016 02:20
so should it be num - 3?
@ibacaraujo
ahh yep got it
thanks
Iago Breno
@ibacaraujo
May 13 2016 02:21
@96street for this case, yes
@96street great, you're welcome!
anthonyjl92
@anthonyjl92
May 13 2016 02:22

hey guys, Im trying to extract certain values from a string and was wondering how to do that?
For example:

var h = `Number = 1
Color=blue
Hand = right

how would i extract the value stored in color
96street
@96street
May 13 2016 02:25
My equation doesn't work on this string:
any idea?
Here's my code now:
function truncateString(str, num) {

  var answer = "";
  var remove  = "";


  if(str.length > num) {
    remove = str.slice(num - 3, str.length);
    str = str.substring(0, str.length - remove.length);
    answer = str + '...';
  }

  return answer;
}

truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2);
Stephen James
@sjames1958gm
May 13 2016 02:28
@96street It fails the if check and returns an empty string.
96street
@96street
May 13 2016 02:29
right
let me think
so if str.length !> num
return str? @sjames1958gm
or just else {return str}
Lemmy
@imnotlammy
May 13 2016 02:32

function rot13(str) { // LBH QVQ VG!
  var charCode = [];

  for (i = 0; i < str.length; i++) {
    charCode.push(str.charCodeAt(i));
  }

  charCode = charCode.join();

  var newStr = String.fromCharCode(charCode);

  return newStr;

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
can someone tell me why this returns a red dot?
96street
@96street
May 13 2016 02:32
yep got it @sjames1958gm
one more thing isn't wokring

function truncateString(str, num) {

  var answer = "";
  var remove  = "";


  if(str.length > num) {
    remove = str.slice(num - 3, str.length);
    str = str.substring(0, str.length - remove.length);
    answer = str + '...';
  }
  else {return str;}

  return answer;
}

truncateString("A-", 1);
@sjames1958gm
Lemmy
@imnotlammy
May 13 2016 02:34
@96street you have a to put an if statement for if num < 3
Iago Breno
@ibacaraujo
May 13 2016 02:34
@96street check if num is less than or equal to 3
Lemmy
@imnotlammy
May 13 2016 02:36
@all pls help

function rot13(str) { // LBH QVQ VG!
  var charCode = [];

  for (i = 0; i < str.length; i++) {
    charCode.push(str.charCodeAt(i));
  }

  charCode = charCode.join();

  var newStr = String.fromCharCode(charCode);

  return newStr;

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
why does it return red dot?
Iskya
@iskya
May 13 2016 02:36

Helpppp... I have a problem with the loop in Mutations, it returns the right answer but not at the same time '''function mutation(arr) {
var first = arr[0].toLowerCase();
var second = arr[1].toLowerCase();

for (i=0; i<first.length; i++){
if(second.indexOf(first[i]) < 0){
return false;
}
}
return true;
}'''

CamperBot
@camperbot
May 13 2016 02:36
:bulb: to format code use backticks! ``` more info
Lemmy
@imnotlammy
May 13 2016 02:36
what does that mean?
Iskya
@iskya
May 13 2016 02:37

Helpppp... I have a problem with the loop in Mutations, it returns the right answer but not at the same time ```function mutation(arr) {
var first = arr[0].toLowerCase();
var second = arr[1].toLowerCase();

for (i=0; i<first.length; i++){
if(second.indexOf(first[i]) < 0){
return false;
}
}
return true;
}```

Lemmy
@imnotlammy
May 13 2016 02:37
function mutation(arr) { var first = arr[0].toLowerCase(); var second = arr[1].toLowerCase(); for (i=0; i<first.length; i++){ if(second.indexOf(first[i]) < 0){ return false; } } return true; }
oops
96street
@96street
May 13 2016 02:38

function truncateString(str, num) {

  var answer = "";
  var remove  = "";


  if(str.length > num) {
    remove = str.slice(num - 3, str.length);
    str = str.substring(0, str.length - remove.length);
    answer = str + '...';
  }

  else if (num <= 3) {
    str = str + '...';
    return str;
  }

  else {return str;}

  return answer;
}

truncateString("A-", 1);
still not working?
Lemmy
@imnotlammy
May 13 2016 02:38
function mutation(arr) {
var first = arr[0].toLowerCase();
var second = arr[1].toLowerCase();
for (i=0; i<first.length; i++){
if(second.indexOf(first[i])  == -1){
return false;
}
}
return true;
}
try this
Wendy Medeiros
@wendyr21
May 13 2016 02:38

i think i am going to lose my brains in a minute..was flying through this till lol. "Stand In Line" this is my function nextInLine(arr, item) {
// Your code here
arr.push(item);
var rem = arr.splice(0,1);
return rem; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine([], 1)); // Modify this line to test
console.log(nextInLine([], 2));
console.log(nextInLine([5,6,7,8,9],1));
console.log(nextInLine(testArr,10));
console.log("After: " + JSON.stringify(testArr));

Lemmy
@imnotlammy
May 13 2016 02:38
@iskya
Wendy Medeiros
@wendyr21
May 13 2016 02:39
this is what is on the left with the x's and checks
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
Lemmy
@imnotlammy
May 13 2016 02:39
@iskya change the if condition to if(second.indexOf(first[i]) == -1)
Stephen James
@sjames1958gm
May 13 2016 02:40
@wendyr21 There is a different array function that removes an element and returns it.
Wendy Medeiros
@wendyr21
May 13 2016 02:40
@sjames1958gm i will google it.. maybe thats what im doing wrong
Iskya
@iskya
May 13 2016 02:40
@imnotlammy doesnt work
Stephen James
@sjames1958gm
May 13 2016 02:41
@wendyr21 They should suggest some functions 'shift' your eyes to the left :)
Lemmy
@imnotlammy
May 13 2016 02:42
@iskya maybe iterate through the second word instead?

function mutation(arr) {
  var first = arr[0].toLowerCase();
  var second = arr[1].toLowerCase();

  for (i = 0; i < second.length; i++) {
    if (first.indexOf(second[i]) == -1) {
      return false;
    }
  }
  return true;
}

mutation(["hello", "hey"]);
Stephen James
@sjames1958gm
May 13 2016 02:43
@96street Need the check for < 3 first because "A-", 1 passes the str.length > num test
Iskya
@iskya
May 13 2016 02:44
@imnotlammy the same :/ ... is something with the loop
Wendy Medeiros
@wendyr21
May 13 2016 02:44
@sjames1958gm that did it thanks!!!!!!
CamperBot
@camperbot
May 13 2016 02:44
wendyr21 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1080 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Iskya
@iskya
May 13 2016 02:45
@imnotlammy ready.. i've forgot to change the i iterator
Iago Breno
@ibacaraujo
May 13 2016 02:45
@iskya did you try to iterate with i < first.length?
Iskya
@iskya
May 13 2016 02:46
i dont know why it doesnt work with first :/
thanx @imnotlammy
CamperBot
@camperbot
May 13 2016 02:46
iskya sends brownie points to @imnotlammy :sparkles: :thumbsup: :sparkles:
:cookie: 61 | @imnotlammy |http://www.freecodecamp.com/imnotlammy
96street
@96street
May 13 2016 02:49

function truncateString(str, num) {

  var answer = "";
  var remove  = "";

  if (num <= 3) {
    str = str + '...';
    return str;
  }

  else if(str.length > num) {
    remove = str.slice(num - 3, str.length);
    str = str.substring(0, str.length - remove.length);
    answer = str + '...';
    return answer;
  }


  else {return str;}

}

truncateString("Absolutely Longer", 2);
@sjames1958gm
what's the easiest way to fix this last one?
Stephen James
@sjames1958gm
May 13 2016 02:51
@96street Read again what to do if num < 3 and look at the test results expected.
96street
@96street
May 13 2016 02:53
got it, thanks
@sjames1958gm

function truncateString(str, num) {

  var answer = "";
  var remove  = "";

  if (num <= 3) {
     remove = str.slice(num, str.length);
    str = str.substring(0, str.length - remove.length);
    answer = str + '...';
    return answer;
  }

  else if(str.length > num) {
    remove = str.slice(num - 3, str.length);
    str = str.substring(0, str.length - remove.length);
    answer = str + '...';
    return answer;
  }


  else {return str;}

}

truncateString("Absolutely Longer", 2);
code is terrible though..
buiphuking
@buiphuking
May 13 2016 02:53
@96street try to make it simple
96street
@96street
May 13 2016 02:54
Any suggestions.... @buiphuking
buiphuking
@buiphuking
May 13 2016 02:55
@96street if(num <= 3){
return str.slice(...., .....) + "....";
}else if{
}else
96street
@96street
May 13 2016 02:56
Damn
Much better
dontchaknow
@dontchaknow
May 13 2016 02:59
let's say you have 2 constructors and I want one to inherit the properties of the other. WorkerBee constructor inherits from Employee. I'm see two ways to set one as the prototype for the other. WorkerBee.prototype = Object.create(Employee.prototype) and simple WorkerBee.prototype = Employee.prototype. What's the difference?
in other words, what's the effect of usng Object.create() vs not using it.
sorry it should be WorkerBee.prototype = new Employee
buiphuking
@buiphuking
May 13 2016 03:07
give me advice to learn scss easy , guys, plz
Lemmy
@imnotlammy
May 13 2016 03:07
@all help pls

function rot13(str) { // LBH QVQ VG!
  var charCode = [];

  for (i = 0; i < str.length; i++) {
    charCode.push(str.charCodeAt(i));
  }

  charCode = charCode.join();

  var newStr = String.fromCharCode(charCode);

  return charCode;

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Why does this return a red dot?
buiphuking
@buiphuking
May 13 2016 03:08
var i @imnotlammy
Lemmy
@imnotlammy
May 13 2016 03:09
@buiphuking same result
buiphuking
@buiphuking
May 13 2016 03:09
@imnotlammy join("")
EricOber
@EricOber
May 13 2016 03:11
hey guys Im having trouble understanding a challenge, can someone help?
José
@josemvc11
May 13 2016 03:11
@Am3ricanPaladin yes, me
tell me
EricOber
@EricOber
May 13 2016 03:11
hey jose, its the Generate Random Whole Numbers with Javascript challenge
this is my code

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

  // Only change code below this line.

  return Math.random()*10;
}
i still get a decimal, i think i just dont understand the instructions
José
@josemvc11
May 13 2016 03:14
@Am3ricanPaladin try with this code

var randomNumberBetween0and19 = Math.floor(Math.random() * 10);

function randomWholeNum() {

// Only change code below this line.

return Math.floor(Math.random());
}

Elbert Cortez
@trip16661
May 13 2016 03:14
guys anyone sees anything wrong here?
im getting infinite foorloops D:
José
@josemvc11
May 13 2016 03:15

'var randomNumberBetween0and19 = Math.floor(Math.random() * 10);

function randomWholeNum() {

// Only change code below this line.

return Math.floor(Math.random());
}'

EricOber
@EricOber
May 13 2016 03:15
oooh ok i see
Elbert Cortez
@trip16661
May 13 2016 03:15
function timerCount() {
        while (userObj.sec !== 0) {
            console.log(userObj.min)
            if (userObj.sec == 0) {
                setInterval(function() {
                    userObj.min--;
                    userObj.sec = 59     
                }, 1000);
            }
            while(userObj.sec !== 0) {
                setInterval(function() {
                    console.log(userObj.sec)
                    userObj.sec--;  
                }, 1000);
            }
        }
    }
José
@josemvc11
May 13 2016 03:16
test
function test() {
EricOber
@EricOber
May 13 2016 03:17
thanks @josemvc11
CamperBot
@camperbot
May 13 2016 03:17
am3ricanpaladin sends brownie points to @josemvc11 :sparkles: :thumbsup: :sparkles:
:cookie: 134 | @josemvc11 |http://www.freecodecamp.com/josemvc11
José
@josemvc11
May 13 2016 03:17
@Am3ricanPaladin :D
EricOber
@EricOber
May 13 2016 03:17
i didnt see that i needed to put math.floor in front of math random
Maryna Nogtieva
@MarynaNogtieva
May 13 2016 03:40

Hello everyone, need help with algorithms
https://www.freecodecamp.com/challenges/title-case-a-sentence

I wrote a function and it displays fine in the console, but for some reason all circles except the first one remain red. I tried to reload page and it still doesn't work.
Need your advice


function titleCase(str) {
  var stringArray = str.split(" ");
  var word = "";
  for( var i = 0; i<stringArray.length; i++){
    word += stringArray[i].charAt(0).toUpperCase()  +stringArray[i].slice(1).toLowerCase() + " ";
    //stringArray[i] = word;
   str = word.split(' ');
  }

//str=stringArray.join(' ');

  return str.join(' ');
}

titleCase("I'm a little tea pot");
Andre Jensen
@andrejensen302
May 13 2016 03:42
Hey guys, quick question. What's best practice for setting up an empty variable for a number?
should I set up as like var empty = ''?? or vary empty = [];? or neither of those.
buiphuking
@buiphuking
May 13 2016 03:46
@MarynaNogtieva every time loop run str = word.split(), overwrite again and again
Maryna Nogtieva
@MarynaNogtieva
May 13 2016 03:48
@buiphuking I put it out of loop ad it still the same....
Chandi
@jkchandra
May 13 2016 03:53

@jkchandra
hey can anyone help me wiith this getJSON script
$.getJSON('http://ipinfo.io', function(val) {
Location = val.city + ", " + val.country;

   });

cant seem to make it into a string

$.getJSON('http://ipinfo.io', function(val) {
Location = val.city + ", " + val.country;
});
Kurt Johnson
@pompan129
May 13 2016 04:00
@jkchandra what are you getting?
buiphuking
@buiphuking
May 13 2016 04:02
@MarynaNogtieva
i run your code and fix a bit
function titleCase(str) {
  var stringArray = str.split(" ");
  var word = "";
  for( var i = 0; i < stringArray.length; i++){
    word += stringArray[i].charAt(0).toUpperCase()  + stringArray[i].slice(1).toLowerCase() + " ";
    //stringArray[i] = word;

  }

//str=stringArray.join(' ');

  return word;
}

titleCase("sHoRt AnD sToUt");
Greg Duncan
@GregatGit
May 13 2016 04:02
@jkchandra you could try using this http://ip-api.com/json it already has lat and long seperated
buiphuking
@buiphuking
May 13 2016 04:03
run test will wrong because Short And Stout_ have blank space at the end
EricOber
@EricOber
May 13 2016 04:11
hey guys could anyone help me with a challenge?
Kurt Johnson
@pompan129
May 13 2016 04:12
@Am3ricanPaladin whats up?
Sean DiSanti
@badc0ded
May 13 2016 04:12
sure @Am3ricanPaladin what's up?
EricOber
@EricOber
May 13 2016 04:12
hey Im on the Generate Random Whole Numbers within a range, challenge
heres my code

// Example
function ourFunction(ourMin, ourMax) {

  return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}

ourFunction(1, 9);

// Only change code below this line.

function randomRange(myMin, myMax) {

  return Math.floor(Math.random() * (myMax - myMin)) + myMin; // Change this line

}

// Change these values to test your function
var myRandom = randomRange(5, 15);
Lallo Vigil
@lalov1
May 13 2016 04:12

`
function destroyer(a, args) {
var arr=arguments[0];

var output=arr.filter(function(value){

for(var i=1;i<arguments.length;i++){
 console.log(arguments[i]);
 return value!==arguments[i]; 
}

});

return output;
}

destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3);
`

Sean DiSanti
@badc0ded
May 13 2016 04:13
do you have a test failing @Am3ricanPaladin ?
EricOber
@EricOber
May 13 2016 04:13
ummm a what?
oh yes
the test failing is "The highest random number that can be generated by randomRange should be equal to your maximum number, myMax. "
Kurt Johnson
@pompan129
May 13 2016 04:14
@Am3ricanPaladin do you need +1
Sean DiSanti
@badc0ded
May 13 2016 04:14
yeah i think your +1 is redundant. may have come from an example where 1 was the min
kirbyedy
@kirbyedy
May 13 2016 04:14
This message was deleted
EricOber
@EricOber
May 13 2016 04:14
lmao, thats what I needed. thanks @badc0ded and @pompan129
CamperBot
@camperbot
May 13 2016 04:14
am3ricanpaladin sends brownie points to @badc0ded and @pompan129 :sparkles: :thumbsup: :sparkles:
:cookie: 474 | @pompan129 |http://www.freecodecamp.com/pompan129
:cookie: 352 | @badc0ded |http://www.freecodecamp.com/badc0ded
Sean DiSanti
@badc0ded
May 13 2016 04:15
no problem, glad to help
EricOber
@EricOber
May 13 2016 04:15
I still dont quite understand how that code works though... a little fuzzy
Kurt Johnson
@pompan129
May 13 2016 04:18
@Am3ricanPaladin Math.random() returns a number between 0 & 1.0. 1.0 is exclusive. so highest is .99999....... If you were to .floor() that it would actually be 1 less than you need. so you need to +1. Did that make sense?
Chandi
@jkchandra
May 13 2016 04:20
thanks @GregatGit ill take a look at it
CamperBot
@camperbot
May 13 2016 04:20
jkchandra sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 476 | @gregatgit |http://www.freecodecamp.com/gregatgit
Chandi
@jkchandra
May 13 2016 04:21
@pompan129 when i use $("#someLabel").html(Location) nothing shows
Lallo Vigil
@lalov1
May 13 2016 04:21
What am I doing wrong?
function destroyer(a, args) {
  // Remove all the values
  var arr=arguments[0];


  var output=arr.filter(function(value){

    for(var i=1;i<arguments.length;i++){
     console.log(arguments[i]);
     return value!==arguments[i]; 
    }
  });

  return output;
}

destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3);
Sean DiSanti
@badc0ded
May 13 2016 04:21
@jkchandra is 'Location' a variable?
Chandi
@jkchandra
May 13 2016 04:22
@badc0ded yep its declared outside as a string
Sean DiSanti
@badc0ded
May 13 2016 04:22
did you already post your code?
@lalov1 what tests are failing?
Kurt Johnson
@pompan129
May 13 2016 04:22
@jkchandra have you console.log() Location & val? are you sure your getting object back from ajax call?
Chandi
@jkchandra
May 13 2016 04:23
does console.log() work in codepen?
@pompan129
Kurt Johnson
@pompan129
May 13 2016 04:23
@jkchandra yes
@jkchandra just inspect & then look at console tab
Sean DiSanti
@badc0ded
May 13 2016 04:24
network tab is always helpful when working with ajax too
Lallo Vigil
@lalov1
May 13 2016 04:24
@badc0ded Pretty much all of them, but I thought it should be working
Kurt Johnson
@pompan129
May 13 2016 04:25
@jkchandra are you tracking the async stuff? are you calling $("#someLabel").html(Location) too early?
Sean DiSanti
@badc0ded
May 13 2016 04:27
@lalov1 is it in a pen? sorry if you've answered all this already i'm bouncing in a few rooms
Lallo Vigil
@lalov1
May 13 2016 04:28
@badc0ded It is "Seek and Destroy". Here is the code
function destroyer(a, args) {
  // Remove all the values
  var arr=arguments[0];


  var output=arr.filter(function(value){

    for(var i=1;i<arguments.length;i++){
     console.log(arguments[i]);
     return value!==arguments[i]; 
    }
  });

  return output;
}

destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3);
Kurt Johnson
@pompan129
May 13 2016 04:28
@lalov1 your for loop will return after only checking arguments[1]. you need to check both.
Chandi
@jkchandra
May 13 2016 04:29
@pompan129 i think i know the issue
codepen is under https but im calling values from a http source
is there a workaround from this?
Sean DiSanti
@badc0ded
May 13 2016 04:30
yes, just access it with http instead of https
yeah what @pompan129 said, @lalov1
you're filtering based on whether the element matches the first argument only
rather than making sure it doesn't match any
Chandi
@jkchandra
May 13 2016 04:31
@badc0ded right will try it out thanks
CamperBot
@camperbot
May 13 2016 04:31
jkchandra sends brownie points to @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 356 | @badc0ded |http://www.freecodecamp.com/badc0ded
Kurt Johnson
@pompan129
May 13 2016 04:34
@jkchandra are you getting CORS error?
genn
@gennkill
May 13 2016 04:37
Can someone help me?
Instructions
Change the provided string from double to single quotes and remove the escaping.
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Chandi
@jkchandra
May 13 2016 04:37
not too sure about that but i got the issue because i was running codepen under https. its resolved once i used.
thanks for your help! @pompan129
CamperBot
@camperbot
May 13 2016 04:38
jkchandra sends brownie points to @pompan129 :sparkles: :thumbsup: :sparkles:
:cookie: 475 | @pompan129 |http://www.freecodecamp.com/pompan129
Chandi
@jkchandra
May 13 2016 04:38
used http*
Kurt Johnson
@pompan129
May 13 2016 04:38
@jkchandra cool. congrats!
@gennkill sure. if you place dble quotes INSIDE of singles (or vice versa) you don't need to escape them. Make sense?
all your inner dbls are escaped now because they are inside dble quotes.
Lemmy
@imnotlammy
May 13 2016 04:42

function rot13(str) { // LBH QVQ VG!
  var charCode = [];

  for (i = 0; i < str.length; i++) {
    charCode.push(str.charCodeAt(i));
  }

  var rot13 = [];

  for (i = 0; i < charCode.length; i++) {
    var newCharCode = charCode[i] - 13;

    if (newCharCode < 65) {
      newCharCode = charCode[i] + 13;
    }
    if (newCharCode < 65 || newCharCode > 90) {
      newCharCode = charCode[i];
    }


    rot13.push(newCharCode);
  }

  var newStr = [];

  for (i = 0; i < rot13.length; i++) {
    newStr.push(String.fromCharCode(rot13[i]));
  }

  newStr = newStr.join('');

  return newStr;
}

// Change the inputs below to test
rot13("SERR YBIR?");
can someone help me with my ranges?
Kurt Johnson
@pompan129
May 13 2016 04:42
so ' I like "ham" for diner'. id the same as "I like \"ham\" for diner"
Lemmy
@imnotlammy
May 13 2016 04:43
I have trouble keeping the question mark at the end
genn
@gennkill
May 13 2016 04:43
@pompan129 th
@pompan129 Thank you so much for that explanation...
CamperBot
@camperbot
May 13 2016 04:44
gennkill sends brownie points to @pompan129 :sparkles: :thumbsup: :sparkles:
:cookie: 476 | @pompan129 |http://www.freecodecamp.com/pompan129
Kurt Johnson
@pompan129
May 13 2016 04:44
@gennkill :)
Donatien
@dloret
May 13 2016 04:46
hello guys, i'm stuck with the Steamroller algorithm. It looks like I return the expected result for each test but the grader doesn't validate the answer. I can't see what I'm missing without any error message: http://codepen.io/dloret/pen/EKQjEL
please use the console to see what's returned
Markus Kiili
@Masd925
May 13 2016 05:00
@dloret You are using a global variable. Messes up FCC tests.
Donatien
@dloret
May 13 2016 05:02
@Masd925 thanks, that's what I supposed... That was the easy way out. I'll try to declare and call the helper function within the first one, then.
CamperBot
@camperbot
May 13 2016 05:02
dloret sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1471 | @masd925 |http://www.freecodecamp.com/masd925
buiphuking
@buiphuking
May 13 2016 05:18
@imnotlammy
do something around 65 and 97
Rudolf Carl Pablico
@rudolfpablico
May 13 2016 05:18
can someone tell me why's my code not displaying the wikipedia api response on html?
buiphuking
@buiphuking
May 13 2016 05:18
is anyone good at flexbox
kushhal
@kushhal
May 13 2016 05:21
Screenshot (5).png
how to check this ...Help
Screenshot (5).png
Rudolf Carl Pablico
@rudolfpablico
May 13 2016 05:24
@kushhal I think you've added some string that the task is not asking.
kushhal
@kushhal
May 13 2016 05:24
I'm not able to understand the task.. @rudolfpablico
Rudolf Carl Pablico
@rudolfpablico
May 13 2016 05:26
@kushhal what again is the name of the challenge?
kushhal
@kushhal
May 13 2016 05:26
Word Blanks @rudolfpablico
rphares
@rphares
May 13 2016 05:27
@kushhal , cant see the images,
if you paste the code, we can talk through it?
kushhal
@kushhal
May 13 2016 05:28
no idea how to do it. totally new to all this @rphares
Rudolf Carl Pablico
@rudolfpablico
May 13 2016 05:28
@kushhal make result = myNoun + " " + myAdjective + " " + myVerb + " " + myAdverb
rphares
@rphares
May 13 2016 05:28
explain format
CamperBot
@camperbot
May 13 2016 05:28

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

rphares
@rphares
May 13 2016 05:29
ah-- even though you got the answer, i'd still practice pasting formatted code-- much easier to get help when you paste it that way :blush: @kushhal :point_up:
Rudolf Carl Pablico
@rudolfpablico
May 13 2016 05:31
Hi @rphares , can you help me on Wikipedia Viewer project
rphares
@rphares
May 13 2016 05:31
sorry, I haven't done that one/am not very advanced... :pensive:
you might paste your pen and explain the problem in the main chat, there are some good people on atm
Thomas Nguyen
@thomasnguyen
May 13 2016 05:32
anyone good with the random quote?
Eldar Tinjić
@EldarT90
May 13 2016 05:33
@EldarT90
hey guys, anyone here online to help me step by step with updating hero app and git repository; i finished first challenge and i would rather have it 100% saved the right way and not experiment on my own
and through these steps i will hopefully learn the procedure myself
刘增辉
@liuzenghui2007
May 13 2016 05:50
Hi, all! I encountered an interesting problem when I'm solving this problem https://www.freecodecamp.com/challenges/no-repeats-please. I write these codes to find the string that have repeated consecutive letters. but a "abb" was missing. Can some one tell me why?
var arrList=["abb", "abb", "bab", "bba", "bab", "bba"];
var re=/([a-zA-Z])\1/g;
var reg=new RegExp(re);
arr2=arrList.filter(function(e){
  return reg.test(e);
});
console.log(arr2);
the output is ["abb", "bba", "bba"]
but i think it should be ["abb", "abb","bba", "bba"]
Trenton Stiles
@blzre
May 13 2016 06:03
Hey all, how do I access the different properties of objects that are nested in an array?
"""
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
}"""

"""
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
}

"""

ahh sorry I thought that would post the code properly
EricOber
@EricOber
May 13 2016 06:03
you need to use ``` next to the # 1 and then put js
like this
``` js
paste your code under that
Trenton Stiles
@blzre
May 13 2016 06:04
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
}
tyty
EricOber
@EricOber
May 13 2016 06:05
np
and when you thank someone, you go THANKS @blzre
CamperBot
@camperbot
May 13 2016 06:05
am3ricanpaladin sends brownie points to @blzre :sparkles: :thumbsup: :sparkles:
:cookie: 192 | @blzre |http://www.freecodecamp.com/blzre
EricOber
@EricOber
May 13 2016 06:05
and get points
Trenton Stiles
@blzre
May 13 2016 06:05
sweet
thanks @Am3ricanPaladin
CamperBot
@camperbot
May 13 2016 06:05
blzre sends brownie points to @am3ricanpaladin :sparkles: :thumbsup: :sparkles:
:cookie: 251 | @am3ricanpaladin |http://www.freecodecamp.com/am3ricanpaladin
EricOber
@EricOber
May 13 2016 06:05
yah!
Konstantinos Nikou
@knikou
May 13 2016 06:06
What is wrong with my code? how to get rid of the ""?

// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty(checkProp) === true){
return myObj.checkProp;
}
else {
return "Not Found";
}
return "Change Me!";
}

// Test your code by modifying these values
checkObj("gift");

EricOber
@EricOber
May 13 2016 06:06
i dont see a "?"
Trenton Stiles
@blzre
May 13 2016 06:07

I've tried accessing the objects by trying to do

console.log(contacts[0][firstName]["Akira"]);

but that doesn't work and I can't find the proper way of finding it on google

EricOber
@EricOber
May 13 2016 06:07
oh you are on a hard one, both of you are
Trenton Stiles
@blzre
May 13 2016 06:08
edit*
console.log(contacts[0][firstName]);
EricOber
@EricOber
May 13 2016 06:08
yeah you cant google it...
honestly i put it in and i still dont quite understand it
Konstantinos Nikou
@knikou
May 13 2016 06:08
checkProp test is "gift", with "", but in myObj.checkProp should not have the ""
Trenton Stiles
@blzre
May 13 2016 06:09

Ive tried just printing the first object in contacts

console.log(contacts[0]);

and that doesnt even return anything! It should return something if I select the first object in the array right?

Kyle W Pilkinton
@tadake
May 13 2016 06:10

hey guys for some reason on ceaser cipher spaces keep getting replaced with dashes and i cant find a fix `function rot13(str) { // LBH QVQ VG!
var start = [];
var mid = [];
var final = [];
var last = null;

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

start[i] = str.charCodeAt(i);

mid[i] = ((((start[i] - 65 )+ 13) %26) +65);

final[i] = String.fromCharCode(mid[i]);
last = final.join("");
}
return last;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
`

Spencer Kuzara
@kodaxx
May 13 2016 06:15
Anyone feel like helping me with a project outside of FCC?
This should be really simple, but for some reason I'm pulling my hair out lol
Daniel
@profoundhub
May 13 2016 06:20
@kodaxx what kind of project is it?
Markus Kiili
@Masd925
May 13 2016 06:20
@knikou The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
So .checkProp doesn't work. It looks for property key "checkProp", not the key inside the variable checkProp.
Steph
@tcapre01
May 13 2016 06:26
morning everybody
Luis
@zdrifted
May 13 2016 06:29

I'm having trouble with the Spinal Tap Case algorithm. How would I target capital letters and add a - before them?

spinalCase("thisIsSpinalTap") should return "this-is-spinal-tap"

Spencer Kuzara
@kodaxx
May 13 2016 06:29
@profoundhub It's a curriculum type project (like FCC) using Mozilla Thimble
Daniel
@profoundhub
May 13 2016 06:32
I am no familiar with that, what's the URL?
EricOber
@EricOber
May 13 2016 06:33
can anyone help me with my code?
Im on the "Make Instances of objects with a constructor function"
Steph
@tcapre01
May 13 2016 06:37
@Am3ricanPaladin I probably don't know enough but post it and maybe someone can help?
EricOber
@EricOber
May 13 2016 06:37

var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 1;
};

// Only change code below this line.

var myCar.nickname  = new Car();
it says THE property nickname of myCar should be a string
Markus Kiili
@Masd925
May 13 2016 06:39
@Am3ricanPaladin First make the car. Then add the property.
EricOber
@EricOber
May 13 2016 06:39
ooh
Steph
@tcapre01
May 13 2016 06:40
could someone help me as well? I'm working on caesar's cipher and it seems my code is looping through twice or something because it returns each letter twice
EricOber
@EricOber
May 13 2016 06:40
like this?
Frank XC
@tenkdayz
May 13 2016 06:40
can figure out a regex pattern that will match -123 but not --123 I have this so far /[^-]-\d+/g .. doesnt work
EricOber
@EricOber
May 13 2016 06:40

var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 1;
};

// Only change code below this line.

var myCar = new Car() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 5;
}
Steph
@tcapre01
May 13 2016 06:40
function rot13(str) { // LBH QVQ VG!
  var result ="";
  var cracked = "";
  var broken = "";
  for (i=0; i<str.length; i++){ 
    cracked = str.charCodeAt(i);

    if (78 >cracked && cracked>64) {
    result = String.fromCharCode(cracked+13);
    broken = broken.concat(result);
    }

    else if (77<cracked && cracked<91) {
    result = String.fromCharCode(cracked-13);
    broken =  broken.concat(result);
    }

    else result = i;
    broken = broken.concat(result);
  }

  return broken;

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Spencer Kuzara
@kodaxx
May 13 2016 06:40
There, I think it finally sent that time - my internet is going bonkers
Markus Kiili
@Masd925
May 13 2016 06:41
@Am3ricanPaladin Just: var myCar = new Car(); Then use myCar...
Daniel
@profoundhub
May 13 2016 06:42
@kodaxx it looks pretty cool, what do you need help with?
EricOber
@EricOber
May 13 2016 06:42
how do i "use" it?
Markus Kiili
@Masd925
May 13 2016 06:43
@Am3ricanPaladin Make a new property with syntax myCar.propertyname=...
EricOber
@EricOber
May 13 2016 06:43
ooh
Daniel
@profoundhub
May 13 2016 06:43
@Rushh that spinal tap challenge is one of the harder ones in my opinion
EricOber
@EricOber
May 13 2016 06:44
hmmm hows this

var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 1;
};

// Only change code below this line.

var myCar = new Car();

  myCar.corvette = fast;
Frank XC
@tenkdayz
May 13 2016 06:46
can figure out a regex pattern that will match -123 but not --123 I have this so far /[^-]-\d+/g .. doesnt work
Markus Kiili
@Masd925
May 13 2016 06:46
@Am3ricanPaladin What was the property key you were supposed to use?
EricOber
@EricOber
May 13 2016 06:46
its saying: The property nickname of myCar should be a string
so i put
The property nickname of myCar should be a string

var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 1;
};

// Only change code below this line.

var myCar = new Car();

  myCar.corvette = "fast";
Markus Kiili
@Masd925
May 13 2016 06:47
Use nickname instead of corvette.
EricOber
@EricOber
May 13 2016 06:47
oh gee we got it! thanks @Masd925
CamperBot
@camperbot
May 13 2016 06:47
am3ricanpaladin sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1472 | @masd925 |http://www.freecodecamp.com/masd925
Steph
@tcapre01
May 13 2016 06:48
could someone help me?
EricOber
@EricOber
May 13 2016 06:48
so i guess that just adds another property onto the first declared variable "Car"
?
Markus Kiili
@Masd925
May 13 2016 06:55
@Am3ricanPaladin It adds a new property nickname to the object (stored in variable) myCar.
Spencer Kuzara
@kodaxx
May 13 2016 06:59
@profoundhub I'd like to make the "Check Answers" button refresh the tutorial pane. The problem is, it won't refresh without refreshing the whole page OR once you click on "tutorial.html" it will auto-refresh - no need to click the button
This should be simple, shouldn't it?
Brijrajsinh Gohil
@brijrajgohil
May 13 2016 07:00
I'm having problems with Profile Lookup challenge
Daniel
@profoundhub
May 13 2016 07:00
Are you building that site? Or is that one of the challenges @kodaxx
@tcapre01 good morning
Spencer Kuzara
@kodaxx
May 13 2016 07:01
@profoundhub Building it, just for fun - once I get it to work, I may come up with some challenges of my own lol
Pujan Harsha Bajracharya
@Pujann
May 13 2016 07:01
I need help with Record Collection
Alex
@Alex-HL780
May 13 2016 07:01
@tcapre01 remove the else (result) and tested
Brijrajsinh Gohil
@brijrajgohil
May 13 2016 07:02
This message was deleted
Alex
@Alex-HL780
May 13 2016 07:02
else result = i;
broken = broken.concat();
}
Brijrajsinh Gohil
@brijrajgohil
May 13 2016 07:03
function lookUpProfile(firstName, prop){
// Only change code below this line
  var i = 0;
  while(i < contacts.length) {
    if(contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    }
    else if(contacts[i].firstName !== firstName) {
      return "No such contact";
    }
    else if(contacts[i].prop !== prop) {
      return "No such property";
    }
    i++;
  }
// Only change code above this line
}
Steph
@tcapre01
May 13 2016 07:03
@Alex-HL780 got it! thanks
CamperBot
@camperbot
May 13 2016 07:03
tcapre01 sends brownie points to @alex-hl780 :sparkles: :thumbsup: :sparkles:
:cookie: 229 | @alex-hl780 |http://www.freecodecamp.com/alex-hl780
Brijrajsinh Gohil
@brijrajgohil
May 13 2016 07:04
@Pujann where the problem?
Markus Kiili
@Masd925
May 13 2016 07:04
@brijrajgohil You should return no such contact after checking all the contacts.
Alex
@Alex-HL780
May 13 2016 07:04
you welcome!
Daniel
@profoundhub
May 13 2016 07:04
@kodaxx I'll check it out tomorrow , it is almost 3am here
Spencer Kuzara
@kodaxx
May 13 2016 07:05
Ahh okay, thanks
Brijrajsinh Gohil
@brijrajgohil
May 13 2016 07:05
@Masd925 I don't understand?
Markus Kiili
@Masd925
May 13 2016 07:06
@brijrajgohil You are returning no such contact based on one contact. Move the return after the loop block.
96street
@96street
May 13 2016 07:06
Need help with Chunky Monkey

function chunkArrayInGroups(arr, size) {

  var bigArr = [];
  var eq = arr.length/size;

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

    bigArr.push([i]);

 }

  return bigArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
/* Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.*/
Markus Kiili
@Masd925
May 13 2016 07:09
@96street You could increment i by +=size and make slices of arr with .slice() and push them into result array.
96street
@96street
May 13 2016 07:10
So what would this be saying?
for(var i = 0; i < arr.length; i+= size)
@Masd925
刘增辉
@liuzenghui2007
May 13 2016 07:11
Hello, everyone! I'm using RegExp() to find the string that have the same letter. but the output is strange. Can some one help me find the problem? http://codepen.io/liuzenghui2007/pen/zqXBKW
Please see the last output
Brijrajsinh Gohil
@brijrajgohil
May 13 2016 07:12
@Masd925 Still there are problems.
something wrong with the if statement
Markus Kiili
@Masd925
May 13 2016 07:14
@brijrajgohil The i is then the start index of slice.
96street
@96street
May 13 2016 07:16
But how do I split it into the length of var size? @Masd925
Brijrajsinh Gohil
@brijrajgohil
May 13 2016 07:18
function lookUpProfile(firstName, prop){
// Only change code below this line
  var i = 0;
  while(i < contacts.length) {
    if(contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    }
    i++;
  }
  if(contacts[i].firstName !== firstName) {
      return "No such contact";
    }
  else if(contacts[i].prop !== prop) {
      return "No such property";
  }
// Only change code above this line
}
Markus Kiili
@Masd925
May 13 2016 07:18
@brijrajgohil Simplest structure is two nested if's inside the contact loop. First for firstname check and the second for property existence. Then only add the returns.
@brijrajgohil The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
So .prop doesn't work there.
@96street Use .slice() to make arrays to push. Figure out start and end indices.
Elbert Cortez
@trip16661
May 13 2016 07:21

guys if i have something like this


function upDown(id, time) {
        if($(id).hasClass("up")) {
            if(time == 60) {
                return;
            }
            time++
            return 

        }
        if($(id).hasClass("down")) {
            if(time == 0) {
                return;
            }
            time--;
            return 
        }
    }

shouldnt this function change the value of the variant that i put as argument?

Brijrajsinh Gohil
@brijrajgohil
May 13 2016 07:24
function lookUpProfile(firstName, prop){
// Only change code below this line
  var i = 0;
  while(i < contacts.length) {
    if(contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    }
    i++;
  }
  if(contacts[i - 1][firstName] !== firstName) {
      return "No such contact";
    }
  else if(contacts[i - 1].hasOwnProperty(prop)) {
      return "No such property";
  }
// Only change code above this line
}
Markus Kiili
@Masd925
May 13 2016 07:24
@trip16661 If you pass a primitive value like a number to time parameter, the function gets a copy of the number. Changing it will not change anything outside the function.
Brijrajsinh Gohil
@brijrajgohil
May 13 2016 07:25
This message was deleted
Markus Kiili
@Masd925
May 13 2016 07:25
@brijrajgohil Returning no such contact should be after the loop block.
Brijrajsinh Gohil
@brijrajgohil
May 13 2016 07:27
That's what I did
But still there's an error
Dmitry
@Sahadov
May 13 2016 07:30
Hello there. I completed "Where art thou" exercise, but wonder if someone has more elegant code for this exercise.
function whereAreYou(collection, source) {

  var result = [];
  var prop = Object.keys(source);
  var propNumber = prop.length;

  for (var i=0; i<collection.length; i++) {
    var suit = 0;

    for (var j=0; j<propNumber; j++) {
      if (collection[i].hasOwnProperty(prop[j])) {

        if(collection[i][prop[j]]==source[prop[j]]) suit+=1;  
      }
      else {

      }
    }

    if (suit==propNumber) result.push(collection[i]);
  }

  return result;
}

whereAreYou([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
Elbert Cortez
@trip16661
May 13 2016 07:30
@Masd925 I see thanks
CamperBot
@camperbot
May 13 2016 07:30
trip16661 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1473 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
May 13 2016 07:33
@Sahadov There is a very short solution using .filter() and .every() methods.
Dmitry
@Sahadov
May 13 2016 07:34
@Masd925 ok, I'll try rewrite it
96street
@96street
May 13 2016 07:35

function chunkArrayInGroups(arr, size) {

  var bigArr = [];

  do {

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

     for(var j = 0; j < size.length; j++) {
       bigArr.push([j]);
     }

   }
  }
while (arr != []); 

  return bigArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
@Masd925 i took a different route, can you tell me why this is wrong
Brijrajsinh Gohil
@brijrajgohil
May 13 2016 07:36
@Masd925
function lookUpProfile(firstName, prop){
// Only change code below this line
  var i = 0;
  while(i < contacts.length) {
    if(contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    }
    i++;
  }

  if(!(contacts[i - 1].hasOwnProperty(prop))) {
      return "No such property";
    }
  if(contacts[i - 1][firstName] !== firstName) {
      return "No such contact";
  }
// Only change code above this line
}
刘增辉
@liuzenghui2007
May 13 2016 07:36
I wrote a regular expression to find strings that have the same letters repeating. but the output if different in two calls.
Can some one help me?
Brijrajsinh Gohil
@brijrajgohil
May 13 2016 07:37
@Masd925 Works!
刘增辉
@liuzenghui2007
May 13 2016 07:37
var re=/(\w)\1/g;
var reg=new RegExp(re);
arr2=arrList.filter(function(e){
  return reg.test(e);
});
console.log(reg.test('abb'));
console.log(reg.test('abb'));
Pujan Harsha Bajracharya
@Pujann
May 13 2016 07:37
I have no idea what needs to be done in Record Collection challenge
Brijrajsinh Gohil
@brijrajgohil
May 13 2016 07:38
You have to manipulate the records based on different conditions.
Markus Kiili
@Masd925
May 13 2016 07:39
@liuzenghui2007 It is because you use the same regexp object twice with test. Try to google about the subject.
Joseph Giray
@josephgiray
May 13 2016 07:40
Hi :D
Markus Kiili
@Masd925
May 13 2016 07:43
@96street Everything :)
96street
@96street
May 13 2016 07:43
:(
I'm trying to push 2 letters to bigArr every loop
Joseph Giray
@josephgiray
May 13 2016 07:44
where's the activity ?
Markus Kiili
@Masd925
May 13 2016 07:45
@96street Elements of result array should be arrays. So you should be pushing arrays to bigArr.
刘增辉
@liuzenghui2007
May 13 2016 07:46
@Masd925 , Thank you for guidance!
CamperBot
@camperbot
May 13 2016 07:46
liuzenghui2007 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1474 | @masd925 |http://www.freecodecamp.com/masd925
96street
@96street
May 13 2016 07:46
bigArr.push([j]); is pushing an array to bigArr? @Masd925
by surrounding j in [] that makes it an arrary no?
ALMY91
@ALMY91
May 13 2016 07:47
var token=1;

mainloop:while (token!=null){

{console.log(token); token++;} 
continue mainloop;}
Hi guys just wondering
did my browser crash?
cos the page keeps appearing to be nonresponsive
Joseph Giray
@josephgiray
May 13 2016 07:48
how it works ?
Markus Kiili
@Masd925
May 13 2016 07:48
@96street Yes sorry, but you are pushing arrays with only one number in each.
m90alg
@m90alg
May 13 2016 07:49
Hi guys, i'm working with angularjs, who can help me with some questions?
96street
@96street
May 13 2016 07:49
j < size.length is 2 each isn't it? @Masd925
Markus Kiili
@Masd925
May 13 2016 07:49
@96street And size.length doesn't make much sense because size is a number.
96street
@96street
May 13 2016 07:50
that gets sizes number @Masd925
oh wait yeah
shit
I'll fix it up now
when I say j < size that means 1 not 2? Or does 2 become an index in that situation? @Masd925
SimonCred
@SimonCred
May 13 2016 08:18
@Masd925 hey Markus, can I ask you a quick best practice question while its fresh in my head (may not be v important)?
Parveen Sharma
@username-parveen
May 13 2016 08:23
This message was deleted
Dmitry
@Sahadov
May 13 2016 08:25
@Masd925 ```
Parveen Sharma
@username-parveen
May 13 2016 08:25
var count = 0;

function cc(card) {
  // Only change code below this line
if (card==2||card==3||card==4||card==5||card==6){
  count++;

}else if(card==10||card=='J'||card=='Q'||card=='K'||card=='A'){
  count--;
}else if (card==7||card==8||card==9){
  return count+" Hold";
}

  if (count>=1){
    return count+" Bet";
  }else if(count<=0){
    return count+" Hold";
  }


  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
is there is any thing wrong in the code???
Dmitry
@Sahadov
May 13 2016 08:26
@Masd925 it works for obects with one property. How to make it for any amount of properties?

function whereAreYou(collection, source) {

  var result = [];
  var prop = Object.keys(source);
  var propNumber = prop.length;


  var theArr = collection.filter(function(val){
      return (val.hasOwnProperty(prop) && val[prop]==source[prop]);


  });

  return theArr;

}

whereAreYou([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
Fayheim
@Fayheim
May 13 2016 08:28
function testLogicalOr(val) {
  // Only change code below this line

 if (val > 10 || val < 20) {
    return "Outside";
  }

 {
    return "Outside";
  }

  // Only change code above this line
  return "Inside";
}

// Change this value to test
testLogicalOr(15);
can someone check if im doing this right
im stuck at this
Combine the two if statements into one statement which returns "Outside" if val is not between 10 and 20, inclusive. Otherwise, return "Inside".
Dmitry
@Sahadov
May 13 2016 08:29
@username-parveen return count+" Hold" ? what does it mean& maybe count="Hold"
@Fayheim if (val >= 10 && val <= 20) {
return "Inside";
}
Maria J
@oheymaria
May 13 2016 08:31
Skjermbilde 2016-05-13 kl. 10.24.02.png
// myVar is not defined outside of myLocalScope
I can get this : ((
can't
**
Fayheim
@Fayheim
May 13 2016 08:32
@Sahadov You should use the || operator once
its the logical and operator waypoint
I believe im doing it right
yes?
but im still stuck
Dmitry
@Sahadov
May 13 2016 08:33
@Fayheim || it OR operator and you should use AND && operator
@Fayheim but in this way it's ok
@Fayheim you should use else statement with return "inside"
if (val > 20 || val < 10) {
return "Outside";
} else
{
return "Inside";
}
Fayheim
@Fayheim
May 13 2016 08:36
hey it worked
but why
the instruction doesn't asked me to do so
T_T
im a newbie, cant expect me to figure to use else statement
but thanks @Sahadov
CamperBot
@camperbot
May 13 2016 08:37
fayheim sends brownie points to @sahadov :sparkles: :thumbsup: :sparkles:
:cookie: 243 | @sahadov |http://www.freecodecamp.com/sahadov
Dmitry
@Sahadov
May 13 2016 08:37
@Fayheim you could use two if statement so
Fayheim
@Fayheim
May 13 2016 08:38
I cant
the instruction says "You should only have one if statement "
its just that
I believe the waypoints sometimes aren't very clear to beginner like me
Dmitry
@Sahadov
May 13 2016 08:40
@Fayheim ))) so you always can ask help here
Fayheim
@Fayheim
May 13 2016 08:40
even the instruction can get pretty confusing
yeah man
thanks
qeurago
@qeurago
May 13 2016 08:41
This message was deleted
function palindrome(str) {
  var strReplace = str.toLowerCase().replace(/\W/g, '');
  var strReverse = strReplace.split('').reverse().join('');
  if (strReverse === strReplace) {
    return true;
  }
  return false;
}
i just need to have "palindrome("0_0 (: /-\ :) 0-0") should return true." evaluate correctly but i'm not really sure how to go about doing that
can anyone help?
Marty
@martyav
May 13 2016 08:42
i had a similar problem yesterday when going through that project
you need to explicitly add underscore to the regular expression
qeurago
@qeurago
May 13 2016 08:43
ah ok
so now i have to figure out how to do that lol
Marty
@martyav
May 13 2016 08:43
and it needs to be added with a |
qeurago
@qeurago
May 13 2016 08:44
ah
Marty
@martyav
May 13 2016 08:44
like /\W|_/
qeurago
@qeurago
May 13 2016 08:44
ah yea i got it
thx @martyav
CamperBot
@camperbot
May 13 2016 08:44
qeurago sends brownie points to @martyav :sparkles: :thumbsup: :sparkles:
:cookie: 257 | @martyav |http://www.freecodecamp.com/martyav
Keith
@7KAG7
May 13 2016 08:44
How does arr[3]0; // equals 11var arr = [
[1,2,3],
[4,5,6],
[7,8,9],
[[10,11,12], 13, 14]
];
arr[0]; // equals [1,2,3]
arr[1][2]; // equals 6
arr[3]0; // equals 11
Sorry, how does arr[3]0; // equals 11 in that scenario
rphares
@rphares
May 13 2016 08:46
do you understand the first two? @dudeguykid
Keith
@7KAG7
May 13 2016 08:46
One last try, its not cutting and pasting correctly on this device arr[3][0][1]; // equals 11
I do
rphares
@rphares
May 13 2016 08:46
okay, so-- which is arr[3]
Keith
@7KAG7
May 13 2016 08:47
7,8,9
rphares
@rphares
May 13 2016 08:47
( understand what it is doing when it copies wrong, you can just copy and paste, ill get it :blush: )
no,
indexing starts at 0
so arr[3] is [[10,11,12], 13, 14]
then, the [0] part is the first part, [10,11,12],
Markus Kiili
@Masd925
May 13 2016 08:48
@Sahadov You could use .every() method to test for all the source keys.
rphares
@rphares
May 13 2016 08:48
and the [1] is the second one in there, which is 11 :blush: @dudeguykid
Dmitry
@Sahadov
May 13 2016 08:48
@Masd925 trying to do it know
Anusha
@anushavicky
May 13 2016 08:48
im stucked pls help me :(
rphares
@rphares
May 13 2016 08:49
does that make sense, @dudeguykid ?
Anusha
@anushavicky
May 13 2016 08:49

Instructions
Use backslashes to assign a string to the myStr variable so that if you were to print it to the console, you would see:

I am a "double quoted" string inside "double quotes"

var myStr = "I am a\"double quoted\" string inside \"double quotes\""; // Change this line

Keith
@7KAG7
May 13 2016 08:49
Ahh its the 0 im hung up on
rphares
@rphares
May 13 2016 08:50
looks like you are missing a space, @anushavicky -- after a before \"double quoted\"
Keith
@7KAG7
May 13 2016 08:50
Thx @rphares
CamperBot
@camperbot
May 13 2016 08:50
dudeguykid sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4521 | @rphares |http://www.freecodecamp.com/rphares
rphares
@rphares
May 13 2016 08:50
anytime`
Anusha
@anushavicky
May 13 2016 08:51
oh thank you so much @rphares
CamperBot
@camperbot
May 13 2016 08:51
anushavicky sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4522 | @rphares |http://www.freecodecamp.com/rphares
rphares
@rphares
May 13 2016 08:51
Anytime~
Anusha
@anushavicky
May 13 2016 08:51
<3
CamperBot
@camperbot
May 13 2016 08:51

:point_right: challenge add your javascript slot machine slots [wiki]

Add your JavaScript Slot Machine Slots

For this part we should notify if they same number is returned three times or return null otherwise.

if(slotOne !== slotTwo || slotTwo !== slotThree){
      return (null);
    }

If slot one and two are different, or slot two and three are not the same, then return null.

:pencil: read more about challenge add your javascript slot machine slots on the FCC Wiki

rphares
@rphares
May 13 2016 08:51
@Masd925 :wave: :blush:
Dmitry
@Sahadov
May 13 2016 08:54
function whereAreYou(collection, source) {

  var result = [];


  var theArr = collection.filter(function(val){
      return source.every(function(element){
        var prop = Object.keys(element);
        return (val.hasOwnProperty(prop) && val[prop]==source[prop]);
      }); 


  });

  return theArr;

}

whereAreYou([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
@Masd925 i'm stuck (
Markus Kiili
@Masd925
May 13 2016 08:54
All follow @rphares 's shoe. She is the one!
rphares
@rphares
May 13 2016 08:55
lol, not at all~ Im no good on bonfires, all you :blush:
Markus Kiili
@Masd925
May 13 2016 08:55
@Sahadov Use every on array of source's keys.
@Sahadov Then just check that property values are the same for val and source.
You can just return collection.filter(...);
Dmitry
@Sahadov
May 13 2016 08:59
@Masd925 done )))))
@Masd925 thx man
CamperBot
@camperbot
May 13 2016 08:59
sahadov sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1475 | @masd925 |http://www.freecodecamp.com/masd925
Anant Choudahri
@AnantChoudhari
May 13 2016 09:26
Hi help me out with factorialize prog
Karthi Keyan
@mskarthi95
May 13 2016 09:27
This message was deleted
stuck in -> Return a Value from a Function with Return program any one
Return a Value from a Function with Return @/all
V Arun Kumar
@arunvkumr
May 13 2016 09:30
@mskarthi95 share you code.. let's have a look how close you are :smile:
Stephen James
@sjames1958gm
May 13 2016 09:55
@AnantChoudhari What is your issue. Post your code
help ormat
CamperBot
@camperbot
May 13 2016 09:55

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Irina Predescu
@irinapredescu
May 13 2016 10:01

Hi guys! For the "Build a Wikipedia Viewer", I have this bit of code:

var toSearch = encodeURI($("#search-box").blur().val());

    $.ajax({
      url: 'https://en.wikipedia.org/w/api.php',
      dataType: 'json',
      data: {
        action: 'query',
        format: 'json',
        generator: 'search',
        gsrsearch: toSearch,
        gsrlimit: '10'
      },
      success: function(data) {

But in console.log I get

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access.

And I can't find where to put the origin header and what to type in. I've tried putting it in the ajax request like

origin:  'http://s.codepen.io/'

And I've tried other online suggestions too, or putting it in the URL with the search and everything... (my toSearch variable), nothing worked

Alex Karofilakis
@juice9090
May 13 2016 10:01
Can someone help me with DNA Pairing?
I cant figure out why it doesnt work.

function pairElement(str) {
  var arr = [];
  var arr2 = [];
  var pair = [];
  var splitted = [];
  var strlen = str.length;

  splitted = str.split('');
  for (var j=0;j<strlen;j++){
    if (splitted[j]=='C'){
      pair[j]='G';}
    else if (splitted[j]=='G'){
      pair[j]='C';}
    else if (splitted[j]=='A'){
      pair[j]='T';}
    else if (splitted[j]=='T'){
      pair[j]='A';}
  }


  for (var i=0;i<strlen;i++){
      arr2[0]=splitted[i];
      arr2[1]=pair[i];
      arr[i]=arr2;
  }
  return arr;
}

pairElement("GCG");
kirbyedy
@kirbyedy
May 13 2016 10:03
@irinapredescu I think data type should be jsonp
Markus Kiili
@Masd925
May 13 2016 10:03
@juice9090 The code gets much cleaner if you just use a lookup object: var pairs = {A:'T', T: 'A', C: 'G', G: 'C'}; No need for if-hell then.
Irina Predescu
@irinapredescu
May 13 2016 10:05
@kirbyedy thanks! that did it -_-
CamperBot
@camperbot
May 13 2016 10:05
irinapredescu sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:cookie: 987 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
Irina Predescu
@irinapredescu
May 13 2016 10:06
weird though, the Wiki API insists data can be XML / JSON / JSONFM or something like this
sheeba-d
@sheeba-d
May 13 2016 10:06
This message was deleted

var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if(collection.hasOwnProperty(id)){
if(value!==""){
if(prop=="tracks"){
if(collection.id.hasOwnProperty("tracks")){
collection.id.prop.push(value);
}
else{
collection.id.prop=[value];
}
}
else {
collection.id.prop=value;
}
}
else{
delete collection.id.prop;
}
}

return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

Markus Kiili
@Masd925
May 13 2016 10:07
@sheeba-d The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
No no .id .prop. Those look for property keys "id" and "prop".
@sheeba-d You only need two or three if's that test value and prop. On if blocks, do things to collection.
Anusha
@anushavicky
May 13 2016 10:11

hi friends please help me with this..i dont understand :worried:

Instructions
Change the provided string from double to single quotes and remove the escaping.

Instructions
Change the provided string from double to single quotes and remove the escaping.
var myStr = "\'<a href=http://www.example.com target=_blank>Link</a>\'";
rphares
@rphares
May 13 2016 10:13
so, you need to make the quotes that were inside the string double quotes, @anushavicky
and the ones on the outside should be single--
Stephen James
@sjames1958gm
May 13 2016 10:14
@anushavicky By replacing the two outside double quotes with single quotes, you don't have to escape the inside double quotes. "Instead of \"this\"" -> 'Instead of "this"'
rphares
@rphares
May 13 2016 10:15
example:
var example= '<a href="http://www.myexamplehere.com" target = "_blank">Something</a>';
@anushavicky
so... you may want to reset the challenge, it looks like you deleted some of the quotes in the string... then just make the few changes :blush:
Alex Karofilakis
@juice9090
May 13 2016 10:18
@Masd925 I did it with a lookup object

function pairElement(str) {
  var splitted = [];
  var strlen = str.length;
  var arr2 = []; //arrays inside the base array
  var arr = [];  //base array

  var pairs = {
    A:'T',
    T:'A',
    C:'G',
    G:'C'
  };



  splitted = str.split('');

  for (var i=0;i<strlen;i++){
    arr2[0] = splitted[i];
    arr2[1] = pairs[splitted[i]];
    arr[i] = arr2;
  }


  return arr;
}

pairElement("GCG");
but it still doesnt work
Anusha
@anushavicky
May 13 2016 10:19
@rphares aww thank uuuuu <3
CamperBot
@camperbot
May 13 2016 10:19
anushavicky sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4524 | @rphares |http://www.freecodecamp.com/rphares
sheeba-d
@sheeba-d
May 13 2016 10:19
@Masd925 But id and prop the string values only. Can't i use it with dot operator;
Alex Karofilakis
@juice9090
May 13 2016 10:19
it seems like arr2 data doesnt get overwitten for some reason
Anusha
@anushavicky
May 13 2016 10:20
@sjames1958gm Thank u :)
CamperBot
@camperbot
May 13 2016 10:20
anushavicky sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1081 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
rphares
@rphares
May 13 2016 10:20
Anytime~ :blush:
Stephen James
@sjames1958gm
May 13 2016 10:20
:+1:
Markus Kiili
@Masd925
May 13 2016 10:23
@sheeba-d The id and prop are parameters. obj.id looks for the key "id". obj[id] looks for the key inside id parameter.
Stephen James
@sjames1958gm
May 13 2016 10:23
@juice9090 arr[i] = arr2 puts a reference to arr2 into arr so by the end they all refer to the last values in arr2
Alex Karofilakis
@juice9090
May 13 2016 10:23
@masd925 i fixed it i had to empty the array before each loop.but i cant understand why.
Markus Kiili
@Masd925
May 13 2016 10:23
@juice9090 I simplified it a bit:
function pairElement(str) {

  var arr = [];  //base array

  var pairs = {
    A:'T',
    T:'A',
    C:'G',
    G:'C'
  };

  for (var i=0;i<str.length;i++){
    arr.push([str.charAt(i),pairs[str.charAt(i)]]);
  }

  return arr;
}