These are chat archives for FreeCodeCamp/HelpJavaScript

21st
Mar 2016
scharla
@scharla
Mar 21 2016 00:01
@UnlimiWorks it didn't seem to work with the array within the function, but maybe it was just some bad syntax
Maddah Anass
@unlimiworks
Mar 21 2016 00:02
It most probably was
Erin Blaisdell
@iramarie23
Mar 21 2016 00:05
anyone do this assignment in javascript? I can't seem to get it:
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
It gives me var remainder;
and then I need to do the assigned part, but can't get it
Maddah Anass
@unlimiworks
Mar 21 2016 00:05
@iramarie23 a%b returns the remainder of a/b
Erin Blaisdell
@iramarie23
Mar 21 2016 00:06
Thanks!
Chelsea Egan
@level5esper
Mar 21 2016 00:16
Can someone please help me? all my tests work, but it's still not letting me pass the challenge
function palindrome(str) {
  // Good luck!
  var expression = /\s+/g;
  var character = /\W+/g;
  str = str.toLowerCase().replace(expression, '').replace(character, ''). replace('_', '');

  var reverse = '';

  for (i = str.length-1; i>=0; i--) {
    reverse += str[i];
  }

  if (reverse === str) {
    return "true";
  } else {
    return "false";
  }
}



palindrome("0_0 (: /-\ :) 0-0");
anyone??? :)
Rex Smith Jr.
@rsmith731
Mar 21 2016 00:20
function appendChildren() {
  var allDivs = document.getElementsByTagName("div");

  for (var i = 0; i < allDivs.length; i++) {
    var newDiv = document.createElement("div");
    decorateDiv(newDiv);
    allDivs[i].appendChild(newDiv);
  }
}
how do i appedChildren to a new div?
BRlau
@BRlau
Mar 21 2016 00:22
hi i dont understand how the word blanks works

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

// Your code above this line
return result;
}

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

Chelsea Egan
@level5esper
Mar 21 2016 00:22
hey @BRlau add ``` before and after your code to format it
BRlau
@BRlau
Mar 21 2016 00:22

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

// Your code above this line
return result;
}

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

CamperBot
@camperbot
Mar 21 2016 00:22
:bulb: to format code use backticks! ``` more info
BRlau
@BRlau
Mar 21 2016 00:23
?
'''
CamperBot
@camperbot
Mar 21 2016 00:23
:bulb: to format code use backticks! ``` more info
Chelsea Egan
@level5esper
Mar 21 2016 00:23
it's the one above the squiggly line at the top left corner of your keyboard
BRlau
@BRlau
Mar 21 2016 00:23

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

// Your code above this line
return result;
}

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

Chelsea Egan
@level5esper
Mar 21 2016 00:23
below the squiggly line *
BRlau
@BRlau
Mar 21 2016 00:23
@.@
Chelsea Egan
@level5esper
Mar 21 2016 00:23
haha
well I don't know why that didn't work
Sujit Karki
@Swoozeki
Mar 21 2016 00:24
Anyone that has done the smallest common multiple challenge from intermeddiate algorithms can help me?
Chelsea Egan
@level5esper
Mar 21 2016 00:24
what don't you understand about it @BRlau ?
Batieva Tamara
@TamaraBatieva
Mar 21 2016 00:24
@level5esper Are you sure every test return the right response? I've just tackled this challenge, but I did it in a different way.
Chelsea Egan
@level5esper
Mar 21 2016 00:24
@TamaraBatieva yup... I don't get it
the only thing I can figure out is that there's some sort of typo that isn't letting it run
but I don't know :/
BRlau
@BRlau
Mar 21 2016 00:25
@level5esper i dont know what to code under the line
Chelsea Egan
@level5esper
Mar 21 2016 00:26
@BRlau you need to concatenate a line that includes phrases you create and then the myNoun, myVerb, etc.
Trying again :) any help appreciated! Why isn't this code running?
function palindrome(str) {
  // Good luck!
  var expression = /\s+/g;
  var character = /\W+/g;
  str = str.toLowerCase().replace(expression, '').replace(character, ''). replace('_', '');

  var reverse = '';

  for (i = str.length-1; i>=0; i--) {
    reverse += str[i];
  }

  if (reverse === str) {
    return "true";
  } else {
    return "false";
  }
}



palindrome("A man, a plan, a canal. Panama");
BRlau
@BRlau
Mar 21 2016 00:31
@level5esper thanks!
CamperBot
@camperbot
Mar 21 2016 00:31
brlau sends brownie points to @level5esper :sparkles: :thumbsup: :sparkles:
:star: 256 | @level5esper | http://www.freecodecamp.com/level5esper
Batieva Tamara
@TamaraBatieva
Mar 21 2016 00:31
@level5esper you are returning a string "false" or "true", but you should return a boolean - without quotes.
Chelsea Egan
@level5esper
Mar 21 2016 00:31
@BRlau no problem!
@TamaraBatieva OHHH!@
That must be it
it worked! Thanks @TamaraBatieva
CamperBot
@camperbot
Mar 21 2016 00:32
level5esper sends brownie points to @tamarabatieva :sparkles: :thumbsup: :sparkles:
:star: 254 | @tamarabatieva | http://www.freecodecamp.com/tamarabatieva
Sujit Karki
@Swoozeki
Mar 21 2016 00:34
Can anyone help me with the Smallest Common Multiple exercise?
http://codepen.io/Swoozeki/pen/qZrWrX?editors=0011
scottyhons
@scottyhons
Mar 21 2016 00:35
hi. :) I'm SO confused by the "Stand in Line" problem. Can someone help?
Jin Choi
@JiniHendrix
Mar 21 2016 00:38
hello can anyone help me with the Map The Debris Bonfire?
function orbitalPeriod(arr) {
  var finalArr = [];
  for(var i = 0; i < arr.length; i++) {
    var a = 6367444.7 + arr[i].avgAlt*1000;

    var orbitalPeriod = Math.round(2 * Math.PI * Math.sqrt(Math.pow(a, 3) / 398600.4418));


    finalArr.push({name:arr[i].name, orbitalPeriod: orbitalPeriod});
  }
  return finalArr;
}

orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
not sure what im doing wrong
scharla
@scharla
Mar 21 2016 00:38
Hey, could someone help with the random quote machine?
Jin Choi
@JiniHendrix
Mar 21 2016 00:38
i converted the altitude and radius to meters
and my formula looks correct
scharla
@scharla
Mar 21 2016 00:39
When i try to add js http://codepen.io/scharlatanka/pen/GZWvGE
js $(".newQuote").click(getQuote); when I add this to the $document jquery function it stops working competely
 $(".newQuote").click(getQuote);
scharla
@scharla
Mar 21 2016 00:44
nvm, figured it out
help
CamperBot
@camperbot
Mar 21 2016 00:57

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. ex: find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Viren Bhagat
@virenb
Mar 21 2016 01:09
find String Immutability
CamperBot
@camperbot
Mar 21 2016 01:09

find string immutability

:zero: challenge understand string immutability

Stanley
@stanleyyylau
Mar 21 2016 01:15
```

```
function add() {
if(typeof arguments[0]!=='number' || typeof arguments[1]!=='number'){
return undefined;
}//if one arguments is not number

else if(typeof arguments[0]==='number' & typeof arguments[1]==='number'){
return arguments[0]+arguments[1];
}//if both arguments are number
else{
function add(y){
if(typeof y==='number'){
return arguments[0]+y;
}// end return function
return add();
}//end if
}//end else

}//end add

add(2)(3);

```
shooterchengde
@shooterchengde
Mar 21 2016 01:16

function palindrome(str) {
// Good luck!
var array = [];
str=str.replace(/\s/g,'');
var str1;
array = str.split('');
str1 = array.reverse().join('');
if(str1.toLowerCase()== str.toLowerCase())
{
return true;
}
else
{
return false;
}
}

palindrome("eye");

Stanley
@stanleyyylau
Mar 21 2016 01:16
function add() {
  if(typeof arguments[0]!=='number' || typeof arguments[1]!=='number'){
    return undefined;
  }//if one arguments is not number

  else if(typeof arguments[0]==='number' & typeof arguments[1]==='number'){
    return arguments[0]+arguments[1];
  }//if both arguments are number
    else{
      function add(y){
        if(typeof y==='number'){
          return arguments[0]+y;
        }// end return function
        return add();
      }//end if
    }//end else

}//end add

add(2)(3);
can somebody help
i can't define the closure function
shooterchengde
@shooterchengde
Mar 21 2016 01:16
Check for Palindromes
scharla
@scharla
Mar 21 2016 01:16
@stanleyyylau number is undefined?
Stanley
@stanleyyylau
Mar 21 2016 01:16
it gives me error
@scharla number is fine, but the function add(y) is not defined
scharla
@scharla
Mar 21 2016 01:20
@stanleyyylau maybe take out the word functiuon before add(y) - I think you're callign it rather than defining it? But I'm not this far yet
Viren Bhagat
@virenb
Mar 21 2016 01:28
Hello all, requesting some help for JS exercise https://www.freecodecamp.com/challenges/understand-string-immutability#
rphares
@rphares
Mar 21 2016 01:29
@hejvb , could you paste your code please? :blush:
Viren Bhagat
@virenb
Mar 21 2016 01:29
oh sorry

// Setup
var myStr = "Jello World";

// Only change code below this line

var myStr = "Hello World";
myStr[0] = "H"; // Fix Me

rphares
@rphares
Mar 21 2016 01:29
no worries-- okay, cool, you are nearly done--
delete the last line, please, he's useless :blush:
also,
you only need to use the var keyword the first time,
so when you reassign that myStr part,
Stanley
@stanleyyylau
Mar 21 2016 01:30
function add() {
  if(typeof arguments[0]!=='number' || typeof arguments[1]!=='number'){
    return undefined;
  }//if one arguments is not number

  else if(typeof arguments[0]==='number' & typeof arguments[1]==='number'){
    return arguments[0]+arguments[1];
  }//if both arguments are number
    else{
      var x=arguments[0];
      function addd(y){
        if(typeof y==='number'){
          return x+y;
        }// end return function
        return addd;
      }//end if
    }//end else

}//end add

add(2)(3);
i changed the code a little bit, but still not ok
rphares
@rphares
Mar 21 2016 01:31
you can just say myStr = "whatever I changed it to"; @hejvb
no need to reuse var myStr, just the name is better :blush:
Viren Bhagat
@virenb
Mar 21 2016 01:31
ah, got it
thanks for your help
Stanley
@stanleyyylau
Mar 21 2016 01:31
it said function add()() is not defined and function added also not defined, i'm confused
rphares
@rphares
Mar 21 2016 01:32
anytime~
Stanley
@stanleyyylau
Mar 21 2016 01:37
can someone help?
Ken Haduch
@khaduch
Mar 21 2016 01:39
@stanleyyylau - I don't think that you can return the function within the function itself? (I'll have to go find my solution and see what I did or read about it.)
eeflores
@eeflores
Mar 21 2016 01:43
This message was deleted
Jonathan Gibbs
@zealousgibbs
Mar 21 2016 01:43

var myVar = 87;

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

am I doing this increment correctly?
rphares
@rphares
Mar 21 2016 01:43
very close, but--
Jonathan Gibbs
@zealousgibbs
Mar 21 2016 01:43
to 88
rphares
@rphares
Mar 21 2016 01:43
check the note in the instructions, @zealousgibbs
Jonathan Gibbs
@zealousgibbs
Mar 21 2016 01:43
oh okay thanks
rphares
@rphares
Mar 21 2016 01:43
when you use something++ you dont need the something = part on the left,
Jonathan Gibbs
@zealousgibbs
Mar 21 2016 01:44
I realized that just now thanks @rphares
CamperBot
@camperbot
Mar 21 2016 01:44
zealousgibbs sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 3429 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Mar 21 2016 01:44
sure thing!
Happy coding~
Stanley
@stanleyyylau
Mar 21 2016 01:45
@khaduch um, i'm not sure, the seems like closure is what FCC suggested
let me try to move it out the function
Ken Haduch
@khaduch
Mar 21 2016 01:50
@stanleyyylau - which exercise is this, please?
Kevin Rodriguez
@kevin2r
Mar 21 2016 01:50

ES6 is awesome, I figured out that I can do this

function largestOfFour(arr) {

  return arr
    .map( (cval) => Math.max(...cval) );
}

instead of

function largestOfFour(arr) {
  // You can do this!
  var finalArr = [];

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

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

        if (arr[i][j] > num) {
            num = arr[i][j];
        }
    }

    finalArr.push(num);
  }

  return finalArr;
}
now, is this valid if I put the shortest way on my freecodecamp challenge?
Merly
@merlys
Mar 21 2016 01:52
@shooterchengde need to change the regex part and it will work, add more conditions with | in between
Micah Bales
@micahbales
Mar 21 2016 01:53
Hi folks! I'm working on "Where Art Thou" algorithm challenge and feeling... challenged. Here's what I've got so far. (It's not working.)
function where(collection, source) {
  var values = [];
  for (var i in collection) {
    if (collection.hasOwnProperty(source)) {
      values.push(collection[i]);
      return true;
    }
  }
  return values;
}

where([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Any suggestions?
Jin Choi
@JiniHendrix
Mar 21 2016 01:53
bonfire Map the Debris
CamperBot
@camperbot
Mar 21 2016 01:53

:fire:Bonfire: Map the Debris :link:

function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  return arr;
}

orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);

Return a new array that transforms the element's average altitude into their orbital periods.

more info:  bf details | bf links | hint

Jin Choi
@JiniHendrix
Mar 21 2016 01:53
hint
CamperBot
@camperbot
Mar 21 2016 01:53
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Stanley
@stanleyyylau
Mar 21 2016 01:59
@khaduch Arguments Optional
Ken Haduch
@khaduch
Mar 21 2016 01:59
@stanleyyylau - thank you.
CamperBot
@camperbot
Mar 21 2016 01:59
khaduch sends brownie points to @stanleyyylau :sparkles: :thumbsup: :sparkles:
:star: 301 | @stanleyyylau | http://www.freecodecamp.com/stanleyyylau
Stanley
@stanleyyylau
Mar 21 2016 02:00
@khaduch i'm reviewing my code again, can't find anything wrong no~
@nViser
@nviser
Mar 21 2016 02:01
@micahbales first I put key and value into the variable. than go through collection and compare this var with each el in collection. If they are equal put them to an empty array! ;)
Ken Haduch
@khaduch
Mar 21 2016 02:01

@stanleyyylau - as long as everything else is correct in your code - you can just do this:

return function (a) {
    /// whatever function code you need
}

So you do not need to return it from within the function that you're defining...

Pascal T.
@omegga
Mar 21 2016 02:01
help friendly date
CamperBot
@camperbot
Mar 21 2016 02:01

:point_right: algorithm friendly date ranges [wiki]

Problem Explanation:

  • Create a program that will take two dates and convert them into a more easy to understand date such as January 1st, 2017. It will also check the difference between them, and handles cases with no difference, more than a day, more than a month, more than a year, and more than a month and less than a year respectively.
:pencil: read more about algorithm friendly date ranges on the FCC Wiki
Stanley
@stanleyyylau
Mar 21 2016 02:02
@khaduch let me try thanks
CamperBot
@camperbot
Mar 21 2016 02:02
stanleyyylau sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 766 | @khaduch | http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Mar 21 2016 02:02
@stanleyyylau - if you're still having a problem, please post your latest code and I'll look at it a little more...
Micah Bales
@micahbales
Mar 21 2016 02:03
@nviser do you have an example of how i would do that?
scharla
@scharla
Mar 21 2016 02:04
Could anybody provide some info on why the GetColour function doesn't work? http://codepen.io/scharlatanka/pen/GZWvGE
wire2111
@wire2111
Mar 21 2016 02:04
hi everyone, i have hit a confusing block - i am trying to use final-expression in a for loop to increment my init value by the number of an incoming argument and im getting a warning i would need to use //noprotect and it will probably crash the browser, when i increment by just init value++ i dont get this error
function chunk(arr, size) {
var g = [];
for (var i=0;i<=arr.length/size;i++){
g.push(arr.slice(i, i+size));
}
return g;
}
works, changing i++ to i+size warns
@nViser
@nviser
Mar 21 2016 02:05
@micahbales I did it. But if you want to be good at coding try to figure it out by yourself using the hint
Micah Bales
@micahbales
Mar 21 2016 02:06
@nviser Well, I was already trying to do what your hint was
my problem isn't not knowing what to do. i'm just stumped knowing how to do it
@nViser
@nviser
Mar 21 2016 02:06
@micahbales If you want I give you solution
Micah Bales
@micahbales
Mar 21 2016 02:06
and i've been working on this a while, so feeling a bit frustrated
Nathaniel Nasarow
@Torgian
Mar 21 2016 02:06
ugh
Micah Bales
@micahbales
Mar 21 2016 02:06
what function are you using to iterate through and identify the fields that have "source" in them?
Nathaniel Nasarow
@Torgian
Mar 21 2016 02:07
ok this is slightly annoying. Need some help with this; the profile lookup code
Micah Bales
@micahbales
Mar 21 2016 02:07
er, method, I mean
@nViser
@nviser
Mar 21 2016 02:07
This message was deleted
Nathaniel Nasarow
@Torgian
Mar 21 2016 02:08
'''
CamperBot
@camperbot
Mar 21 2016 02:08
:bulb: to format code use backticks! ``` more info
@nViser
@nviser
Mar 21 2016 02:08
@micahbales try to do it by your own way!
Micah Bales
@micahbales
Mar 21 2016 02:08
sure thing
Nathaniel Nasarow
@Torgian
Mar 21 2016 02:09
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
  //console.log(contacts[i].firstName + " " + prop);
  //var nameProperty = i.firstName === firstName.prop;
       console.log(contacts[i].firstName);
  if (contacts[i].firstName == firstName) {
    var name = contacts[i].firstName;
    console.log (contacts[i][prop]);
    return name;

  } else if (contacts[i].firstName !== firstName) {

    return "No such contact";


  }
}
// Only change code above this line
}

// Change these values to test your function
lookUp("Harry", "address");
Micah Bales
@micahbales
Mar 21 2016 02:09
i'll keep going. it's only been a couple days
Stanley
@stanleyyylau
Mar 21 2016 02:09

@khaduch ```
function add() {
if (typeof arguments[0] !== 'number' || typeof arguments1 !== 'number') {
return undefined;
} //if one arguments is not number
else if (typeof arguments[0] === 'number' & typeof arguments1 === 'number') {
return arguments[0] + arguments1;
} //if both arguments are number
else {
var x = arguments[0];
return function(y) {
if (typeof y === 'number') {
return x + y;
}
}
} //end else

add(2)(3);
```

function add() {
  if (typeof arguments[0] !== 'number' || typeof arguments[1] !== 'number') {
    return undefined;
  } //if one arguments is not number
  else if (typeof arguments[0] === 'number' & typeof arguments[1] === 'number') {
    return arguments[0] + arguments[1];
  } //if both arguments are number
  else {
    var x = arguments[0];
    return function(y) {
        if (typeof y === 'number') {
          return x + y;
        }
    }
  } //end else

  add(2)(3);
a bit confusing, still not ok
@nViser
@nviser
Mar 21 2016 02:10
@micahbales I gave you my code, use it!
Nathaniel Nasarow
@Torgian
Mar 21 2016 02:10
for some reason it's coming up false, I think the for loop just stops at the first one, and doesn't keep going through the whole list
scharla
@scharla
Mar 21 2016 02:13
@Torgian snce You're searching for "Harry" it always finds it.
Jared Pranke
@EtherWolf
Mar 21 2016 02:13
@scharla Why do most of the hex values have two octothorpes?
Nathaniel Nasarow
@Torgian
Mar 21 2016 02:14
But then why does my if loop comes up false? firstName should match contacts[i].firstName, right?
scharla
@scharla
Mar 21 2016 02:15
@EtherWolf apparently because I fail at copy-paste. Taking them out didn;t help though :(
Ken Haduch
@khaduch
Mar 21 2016 02:18
@stanleyyylau - OK, I see what's happening. This is really subtle, but you have a problem where you are checking the type of the arguments, and you are always checking for two arguments. If you don't have two arguments, the second one (that you don't have) is not a number, therefore you just get the return "undefined" if you have that case, so you never see any other code. That means that you never return the function (closure) to the caller, so it cannot process add(2)(3); - it took a little while to see it. You have to consider the length of the arguments object in doing that first check, then I think that it will work out after that?
Jared Pranke
@EtherWolf
Mar 21 2016 02:19
@scharla You also have a function call that is getColour() , however your function declaration is GetColour()
Viren Bhagat
@virenb
Mar 21 2016 02:19
find Word Blanks
CamperBot
@camperbot
Mar 21 2016 02:19

find word blanks

:zero: checkpoint word blanks

Stanley
@stanleyyylau
Mar 21 2016 02:20
@khaduch oh, thanks man, it's a great help!
CamperBot
@camperbot
Mar 21 2016 02:20
stanleyyylau sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: stanleyyylau already gave khaduch points
scharla
@scharla
Mar 21 2016 02:23
@EtherWolf Thanks! It's time to go to bed I think - my brain isn't working anymore lol
@EtherWolf Thank you
CamperBot
@camperbot
Mar 21 2016 02:23
scharla sends brownie points to @etherwolf :sparkles: :thumbsup: :sparkles:
:star: 314 | @etherwolf | http://www.freecodecamp.com/etherwolf
m-farooqui
@m-farooqui
Mar 21 2016 02:24
hi i am doing the java part and in the way point "Golf Code" i am having trouble getting through the way point
this is my code

function golfScore(par, strokes) {
// Only change code below this line
if (1){
return"Hole-in-one!";
}
else if(2){
return "Eagle";
}
else if(1) {
return "Birdie";
}
else if (par){
return "Par";
}
else if(1){
return "Bogey";
}
else if (2) {
return "Double Bogey";
}
else if(3){
return "Go Home!";
}
else() {
return "Change Me";
}
// Only change code above this line
}

// Change these values to test
golfScore(5, 4);

cannelflow
@cannelflow
Mar 21 2016 02:25
@m-farooqui you passed two argument in function par & strokes now you need to compare them in if else
m-farooqui
@m-farooqui
Mar 21 2016 02:28
so how should i change the code
?
cannelflow
@cannelflow
Mar 21 2016 02:42
@m-farooqui worked it out ?
Matthew Shaver
@RazzaFrazza
Mar 21 2016 02:43
help caesars cipher
CamperBot
@camperbot
Mar 21 2016 02:43

: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: Write your own code. :memo:

:checkered_flag: Problem Explanation:

  • You need to write a function, which will take 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

Aknotts
@Aknotts
Mar 21 2016 02:50
stuck on golf code
Rumen1982
@Rumen1982
Mar 21 2016 02:51
Hey guys i need help in Logical Order in If Else Statements
i dont know wat number i should put
OmMinky
@OmMinky
Mar 21 2016 02:58
hi I'm working on Stand in Line, any suggestions?
function queue(arr, item) {
  // Your code here
  //write a function queue which take an array and a number(arr) and a number (item) as argument
  {
  item.push();//1. add the number to the end of the array
  }//.push() takes one or more parameter and "pushes" it onto the end of the array.
  {arr.shift([]); //2.  then remove the first element of array. 
 //to remove the first element on an array, use .shift()
 var shiftedFromArray= arr.shift(); //3.queue function should then return the element that was removed.

  return shiftedFromArray ;  // Change this line
}
}
// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
var code = "formatted";
Aknotts
@Aknotts
Mar 21 2016 03:00

```function queue(arr, item) {
arr.push(item); // Your code here
var juice = arr.shift();
return juice;

// Change this line

}

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

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

@OmMinky this is what i got from Stand In Line
OmMinky
@OmMinky
Mar 21 2016 03:04
@Aknotts are you saying my code is missing: arr.push(item)?
bitgrower
@bitgrower
Mar 21 2016 03:04
@Aknotts -- there are 4 array challenges shortly before stand in line ... on different array methods ... push pop shift unshift -- review those and it should help you a lot on stand in line ....
Ken Haduch
@khaduch
Mar 21 2016 03:05
@OmMinky - you have some strange curly braces in there - not necessary before/after item.push(). item.push() is not correct. You are being passed an array in the function argument arr, .push() is a method of Array, so you need to push to the array. Then you only want to have one call to arr.shift(), and return the value that is returned from that. You can simplify your code, and fix that push call.
Artur Sęp
@a-sep
Mar 21 2016 03:09
God morning :)
OmMinky
@OmMinky
Mar 21 2016 03:09
@khaduch thanks, going to look further into this, hmm, so the push is formatted incorrectly?
CamperBot
@camperbot
Mar 21 2016 03:09
omminky sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 767 | @khaduch | http://www.freecodecamp.com/khaduch
Jin Choi
@JiniHendrix
Mar 21 2016 03:10
finally found why Map the Debris is so confusing
heads up for anyone who hasn't done it yet
the GM value is in KM not METERS
and they don't tell you, which they should because the wikipedia article they link
everything is in meters
Jeff
@meankraken
Mar 21 2016 03:25
Hey guys I'm having trouble figuring out how to find all of the permutations of an arr and putting the answer into my ans arr... could anyone assist?
var count = 0;
var ans = [];

function permAlone(str) {

  permute(str.split(""),0);
  return ans;



}

function permute(arr,index) {
  var temp=0;
  if (index >= arr.length) {
    return; 

  }
  else {
  ans.push(arr);
  for (var i=index+1; i<arr.length; i++) {
     temp = arr[index];
     arr[index] = arr[i];
     arr[i] = temp;
     ans.push(arr.slice());
     permute(arr.slice(),index+1);

  }
  }  
}
OmMinky
@OmMinky
Mar 21 2016 03:25
@khaduch suggestions on how to use arr.shift() once, yet still return the element removed?
@Aknotts thank you!
CamperBot
@camperbot
Mar 21 2016 03:27
omminky sends brownie points to @aknotts :sparkles: :thumbsup: :sparkles:
:star: 227 | @aknotts | http://www.freecodecamp.com/aknotts
hnry
@hnry
Mar 21 2016 03:27
@OmMinky what do you mean ?
arr.shift only runs once and returns the element you removed
shooterchengde
@shooterchengde
Mar 21 2016 03:28
Title Case a Sentence
help me
CamperBot
@camperbot
Mar 21 2016 03:28

:point_right: adding environment variables [wiki]

In Windows

Via GUI

  1. Download Varpanel.
  2. Open Varpanel.
  3. In PATH variable, add the relevant path (for example).

:pencil: read more about adding environment variables on the FCC Wiki

devonwilson1
@devonwilson1
Mar 21 2016 03:28
having challenges on "Golf Code" anyone wanna help?

function golfScore(par, strokes) {
// Only change code below this line

if (strokes >=1) {
return "Hole-in-one!";
}
else if (strokes <=par - 2) {
return "Eagle";
}
else if (par - 1) {
return "Birdie";
}
else if (par) {
return "Par";
}
else if (par + 1) {
return "Bogey";
}
else if (par + 2) {
return "Double Bogey";
}
else if (strokes >=par + 3) {
return "Go Home!";
}

return "Go Home";
// Only change code above this line
}

// Change these values to test
golfScore(5, 9);

OmMinky
@OmMinky
Mar 21 2016 03:30
@hnry the code i wrote used the arr.shift 2x's, and was redundant, one to perform the action, another to assign the action to variable in order to recall the element removed
hnry
@hnry
Mar 21 2016 03:31
@OmMinky you just do var removed = arr.shift() it will remove and assign it to the variable
agaudet84
@agaudet84
Mar 21 2016 03:31
@devonwilson1 missing a few stroke to par comparisons in the middle
devonwilson1
@devonwilson1
Mar 21 2016 03:32
yes thats what I'm trying to figure out what does that look like
i added strokes , to them all still nothing
agaudet84
@agaudet84
Mar 21 2016 03:33
else if (strokes == par - 1) {
return "Birdie";
}
else if (strokes == par) {
return "Par";
}
else if (strokes == par + 1) {
return "Bogey";
}
else if (strokes == par + 2) {
return "Double Bogey";
}
Jeff
@meankraken
Mar 21 2016 03:34
Could anyone who knows how to do the permutation bonfire No repeat (find all permutations of a string) challenge assist me with mine? Kind of stuck atm
devonwilson1
@devonwilson1
Mar 21 2016 03:34
@agaudet84 i did that to them and still nothing
does something else look wrong? @agaudet84 thank you
CamperBot
@camperbot
Mar 21 2016 03:34
devonwilson1 sends brownie points to @agaudet84 :sparkles: :thumbsup: :sparkles:
:star: 221 | @agaudet84 | http://www.freecodecamp.com/agaudet84
devonwilson1
@devonwilson1
Mar 21 2016 03:35
and will you remind what == means again
isn't it only that number
agaudet84
@agaudet84
Mar 21 2016 03:35
it means that value a == value b
equals sorry
OmMinky
@OmMinky
Mar 21 2016 03:35
@hnry yep, got it, thank you, wooohoo!
CamperBot
@camperbot
Mar 21 2016 03:35
omminky sends brownie points to @hnry :sparkles: :thumbsup: :sparkles:
hnry
@hnry
Mar 21 2016 03:35
@meankraken what exactly are you stuck on?
CamperBot
@camperbot
Mar 21 2016 03:35
:star: 178 | @hnry | http://www.freecodecamp.com/hnry
devonwilson1
@devonwilson1
Mar 21 2016 03:35

function golfScore(par, strokes) {
// Only change code below this line

if (strokes >= @a1) {
return "Hole-in-one!";
}
else if (strokes <= par - 2) {
return "Eagle";
}
else if (strokes == par - 1) {
return "Birdie";
}
else if (strokes == par) {
return "Par";
}
else if (strokes == par + 1) {
return "Bogey";
}
else if (strokes == par + 2) {
return "Double Bogey";
}
else if (strokes >= par + 3) {
return "Go Home!";
}

return "Go Home";
// Only change code above this line
}

// Change these values to test
golfScore(5, 2

);

Jeff
@meankraken
Mar 21 2016 03:36
@hnry well Im just trying to find all the permutations of a string, and I feel like logically my recursive function should work, but it's extreeeeemely slow and doesn't return all of the permutations
agaudet84
@agaudet84
Mar 21 2016 03:36
@devonwilson1 if (strokes ==1) {
return "Hole-in-one!";
} should be at the top as it is now your code is always returning at that point
Og-Morrow
@Og-Morrow
Mar 21 2016 03:36
New to JavaScript and new to Array Logic. I need help understanding the QUEUE DATA STRUCTURE. I am on the Stand in Line challenge.
agaudet84
@agaudet84
Mar 21 2016 03:36
because you are saying if strokes is greater than or equal to 1 return
Chris Humphreys
@ChrisCHumphreys
Mar 21 2016 03:38
weird question, but if someone has time. in exercise 220 lookup[val] work to pull from an object, but lookup.val does not. anyone know why this is?
Francis
@Francis-p
Mar 21 2016 03:38
i totally have no idea what am i doing for API and Ajax
OmMinky
@OmMinky
Mar 21 2016 03:38
@devonwilson1 , strickly looking at "if (strokes >= @a1)", how about strokes < , {return "hole-in-one!", _ (means fill in the blank)
@devonwilson1 , @agaudet84 's method is correct too. Also in this one, it really helped me to draw a number line by hand and go through each criteria
Jeff
@meankraken
Mar 21 2016 03:40
@geochris35 So lookup.val means you're literally looking up a property under lookup that's called "val", however lookup[val] would work to see what variable val is set to.. if that makes sense
hnry
@hnry
Mar 21 2016 03:40
@meankraken i'm looking at your code, why do you try to remember the words?
Chris Humphreys
@ChrisCHumphreys
Mar 21 2016 03:41
@meankraken yes exactly.
it works with [] notation, but not dot notation
Jeff
@meankraken
Mar 21 2016 03:42
@geochris35 right what I'm saying is the dot notation will take the following string literally, meaning you're look for a properly named "val" instead of whatever variable val is set to
Kyle Morton
@kmorton1988
Mar 21 2016 03:42
would the following be a proper regex declaration?
var pattern = /^[\w]$/
Chris Humphreys
@ChrisCHumphreys
Mar 21 2016 03:42
oh. i get it.
Jeff
@meankraken
Mar 21 2016 03:42
@hnry I'm not too sure what you mean hnry
devonwilson1
@devonwilson1
Mar 21 2016 03:42
thanks @agaudet84
CamperBot
@camperbot
Mar 21 2016 03:42
devonwilson1 sends brownie points to @agaudet84 :sparkles: :thumbsup: :sparkles:
:warning: devonwilson1 already gave agaudet84 points
devonwilson1
@devonwilson1
Mar 21 2016 03:42
thanks @OmMinky
CamperBot
@camperbot
Mar 21 2016 03:42
devonwilson1 sends brownie points to @omminky :sparkles: :thumbsup: :sparkles:
:star: 168 | @omminky | http://www.freecodecamp.com/omminky
Chris Humphreys
@ChrisCHumphreys
Mar 21 2016 03:42
thanks @meankraken
CamperBot
@camperbot
Mar 21 2016 03:42
geochris35 sends brownie points to @meankraken :sparkles: :thumbsup: :sparkles:
:star: 323 | @meankraken | http://www.freecodecamp.com/meankraken
hnry
@hnry
Mar 21 2016 03:44
@meankraken you do this ans.push(arr); whats the point of it
Jeff
@meankraken
Mar 21 2016 03:44
oh I guess thats more for my debugging, I'm trying to put all of the permutations into the ans array
Marisol C
@Mariisun
Mar 21 2016 03:44

can anyone help me with Quoting Strings with Single Quotes"

my code: var myStr = "<a href='http://www.example.com' target=\"_blank\">Link</a>";

X Remove all the backslashes ()
  • You should have two single quotes ' and four double quotes "
    X Only remove the backslashes \ used to escape quotes.
agaudet84
@agaudet84
Mar 21 2016 03:45
@Mariisun change the outside double quote to single quotes, and every other one to double taking away the backslashes
Marisol C
@Mariisun
Mar 21 2016 03:46
@agaudet84 Thank you!
CamperBot
@camperbot
Mar 21 2016 03:46
mariisun sends brownie points to @agaudet84 :sparkles: :thumbsup: :sparkles:
:star: 222 | @agaudet84 | http://www.freecodecamp.com/agaudet84
hnry
@hnry
Mar 21 2016 03:48
@meankraken it's really hard to follow
my advice would be stop trying to manipulate the array so much, and pass long the a string of the current permutation
*pass along a string
Kyle Morton
@kmorton1988
Mar 21 2016 03:49
help ceasars cipher
CamperBot
@camperbot
Mar 21 2016 03:49
no wiki entry for: ceasars cipher
Kyle Morton
@kmorton1988
Mar 21 2016 03:49
help caesars cipher
CamperBot
@camperbot
Mar 21 2016 03:49

: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: Write your own code. :memo:

:checkered_flag: Problem Explanation:

  • You need to write a function, which will take 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

Francis
@Francis-p
Mar 21 2016 03:50
hi @kmorton1988 !
Kyle Morton
@kmorton1988
Mar 21 2016 03:50
Good evening/morning (depending on where you are) @Francis-p
Francis
@Francis-p
Mar 21 2016 03:51
@kmorton1988 it’s afternoon for me here in singapore! :smile:
Kyle Morton
@kmorton1988
Mar 21 2016 03:51
ahh, well there ya go. hope it's a good one :P
Francis
@Francis-p
Mar 21 2016 03:52
how’s your progress?
done with random quote?
swimrr
@swimrr
Mar 21 2016 03:56
hey all
shooterchengde
@shooterchengde
Mar 21 2016 03:56

function titleCase(str) {
var array = [];
array = str.split(' ');
for(i=0;i<array.length;i++) { if(array[i].charAt(0)>'a'&& array[i].charAt(0)< 'z')
{

           array[i][0].toUpperCase();
      }  


}

str = array.join(" ");
return str;
}

titleCase("I'm a little tea pot");

error
who can help
swimrr
@swimrr
Mar 21 2016 03:57
can someone please tell me how to start lesson 103?
how do I use the convert(30) line?
Francis
@Francis-p
Mar 21 2016 03:57
@shooterchengde for (var i = 0; …)
DJ
@qualitymanifest
Mar 21 2016 03:58
This message was deleted
swimrr
@swimrr
Mar 21 2016 03:59
fahrenheit = convert(); seems to be incorrect
Ken Haduch
@khaduch
Mar 21 2016 04:04

@swimrr - hello... there is a description of the formula to convert a temperature in Celsius to one in Fahrenheit. That is given (as a word description) in the problem description.

You are given the skeleton of the function "convert" which is expecting an argument which represents a number in Celsius. The line of code at the bottom convert(30); is test code that will call your convert function and pass the number 30. Your function is supposed to return the fahrenheit equivalent. That test code is something that you can use if you want to attempt to use different values, but essentially you do not have to do anything else but leave it there.

There is one line of code that they indicate you should change by the comments. It is to calculate the converted value according to the formula, which you must implement using javascript operations (basically, add, multiply and divide) and set the variable that you see being returned later in that function.

swimrr
@swimrr
Mar 21 2016 04:07
@khaduch thank-you for your response! So convert(30) will automatically call whatever formula I put in the function?
CamperBot
@camperbot
Mar 21 2016 04:07
swimrr sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 768 | @khaduch | http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Mar 21 2016 04:08
@swimrr - yes, the function is named "convert", and you are calling it with the line of code. The function as it is will run, but doesn't have the temperature conversion formula in it, so it will not return the answers that they are expecting when the tests are run. So anything that calls the function 'convert' will run your formula, as well as the other code that is already in place there.
swimrr
@swimrr
Mar 21 2016 04:14
@khaduch so I want to start my code with var fahrenheit = but I'm not sure what to put after that
how do I link var fahrenheit to convert()?
Francis
@Francis-p
Mar 21 2016 04:14
@swimrr celsius
swimrr
@swimrr
Mar 21 2016 04:16
oh....so how does the formula know that celsius == convert(30)?
Francis
@Francis-p
Mar 21 2016 04:17
@Francis-p fahrenheit = celsius
swimrr
@swimrr
Mar 21 2016 04:17
does function convert(celsius) define it as a variable?
Francis
@Francis-p
Mar 21 2016 04:17
then from there you can do your formular to fahrenheit
swimrr
@swimrr
Mar 21 2016 04:18
yes, the rest of the formula is easy to write
I was not sure how celsius is given any value?
Ken Haduch
@khaduch
Mar 21 2016 04:19

@swimrr - it is key to learn how to write an equation to do this conversion. You have the value for celsius as the function argument. You define a variable as you said var fahrenheit, and set it equal to the equation (which you implement in javascript code) using their description of the formula:

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

so you are writing "var fahrenheit = celsius times 9 divided by 5 plus 32", you just have to provide the javascript operators and make sure you end the line with a semicolon!
The "celsius" temperature value is the function argument - you use that name that is up there in the parentheses, and make sure that all of the spellings of the variable names are correct...

swimrr
@swimrr
Mar 21 2016 04:19
@khaduch yes, I get all the operators. But I don't understand how celsius is given a value of 30?
is celsius defined as a variable by convert(celsius)?
does convert() create myVar within the ()?
Francis
@Francis-p
Mar 21 2016 04:20
celsius is just a varible
swimrr
@swimrr
Mar 21 2016 04:21
where is it defined?
Ken Haduch
@khaduch
Mar 21 2016 04:21
@swimrr - read the last sentence in my previous post - the function is written as function convert(celsius) - so whatever value is used when the function is invoked, as in convert(30) is mapped, if you will, to the variable 'celsius', the function argument.
Francis
@Francis-p
Mar 21 2016 04:21
so if you have convert (45) mean celsius is 45
swimrr
@swimrr
Mar 21 2016 04:22
@khaduch ah, that explains it all, thank-you! Did I miss that in the challenges somewhere?
CamperBot
@camperbot
Mar 21 2016 04:22
swimrr sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: swimrr already gave khaduch points
Francis
@Francis-p
Mar 21 2016 04:22
@khaduch explain it well!
swimrr
@swimrr
Mar 21 2016 04:22
Yes, that's a great explanation!!
Francis
@Francis-p
Mar 21 2016 04:22
You are given a variable celsius representing a temperature in Celsius.
swimrr
@swimrr
Mar 21 2016 04:23
what challenge is writing a function like that explained in?
I understand it now, but don't remember reading about that anywhere??
Francis
@Francis-p
Mar 21 2016 04:23
it is written in the 3rd paragrah
Ken Haduch
@khaduch
Mar 21 2016 04:24

@swimrr - probably missed it, but it might not have been explicitly stated? Let me look at the lessons... It is just something that after a while you just know, maybe they don't make it extremely obvious...

the thing is that all of the lessons use functions after a certain point is reached - this might be the first one that you are participating in the creation of? It seems to be something of a stumper, and then perhaps an "aha" moment for a lot of people here!

swimrr
@swimrr
Mar 21 2016 04:25
@khaduch I think you're right. Now that you've explained to me how the function is called I get it
DJ
@qualitymanifest
Mar 21 2016 04:25
swimrr
@swimrr
Mar 21 2016 04:25
it's my "aha" moment
Kevin Nelms Baxter II
@kbax6342
Mar 21 2016 04:25

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

wordBlanks("cat","little","hit","slowly");

// Your code above this line
return result;
}

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

swimrr
@swimrr
Mar 21 2016 04:25
@qualitymanifest yes, thank you, I understand it now
CamperBot
@camperbot
Mar 21 2016 04:25
swimrr sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1091 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Jeff
@meankraken
Mar 21 2016 04:26
has anybody finished bonfire No repeats please (find all permutations of a string) and can assist, can't figure it out
Ken Haduch
@khaduch
Mar 21 2016 04:26
you are correct, @Francis-p - they do exactly describe that in the problem description. Just a quick scan of the lessons looks to me as if there is not one up to that point that really gives the "function 101" explanation... :)
@Francis-p - thanks for pitching in! :thumbsup:
CamperBot
@camperbot
Mar 21 2016 04:27
khaduch sends brownie points to @francis-p :sparkles: :thumbsup: :sparkles:
:star: 284 | @francis-p | http://www.freecodecamp.com/francis-p
Francis
@Francis-p
Mar 21 2016 04:27
@khaduch bye! see you soon!
khaduch @khaduch - time to shut down for the night! Good night all - happy coding...
swimrr
@swimrr
Mar 21 2016 04:29
@khaduch thanks for explaining it to me. I didn't understand that celsius was defined in the explanation in paragraph 3. I get it now!
CamperBot
@camperbot
Mar 21 2016 04:29
swimrr sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: swimrr already gave khaduch points
swimrr
@swimrr
Mar 21 2016 04:29
I didn't realize how functions were executed
DJ
@qualitymanifest
Mar 21 2016 04:30
@kbax6342 this: wordBlanks("cat","little","hit","slowly"); is a recursive call... not something you need to learn about right now, but not useful here. you need to assign wordBlanks parameters (myNoun, myAdjective, myVerb, myAdverb) to result
swimrr
@swimrr
Mar 21 2016 04:30
okay, that's it for me for tonight. More tomorrow! Good night all...!
Francis
@Francis-p
Mar 21 2016 04:31
@swimrr see you!
DJ
@qualitymanifest
Mar 21 2016 04:34
@kbax6342 result += myNoun + myAdjective + myVerb would make result equal "dogbigran". which doesn't make a whole lot of sense as a sentence, but that's the basic idea of what you need to do
Doug
@Spazcool
Mar 21 2016 04:43
Been distracted a bit and I've come back to the Stand in Line challenge. Anyone have any suggestions for that one?
Sean
@burritoranch
Mar 21 2016 04:44
I did a dumb thing... I used // no protect because I thought that my for statement would not create an infinite loop. But it did. Now every time I open Chunky Monkey my browser crashes. Does anyone know how to reset the code of a challenge from outside the actual challenge?
Garrett Tyrrell
@gtyrrell4
Mar 21 2016 04:49
Having some trouble with the "Nesting For Loops" excersise. I need to multiply the product by each subset in the array

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

console.log(product*[i][j][h]);
}}

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

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

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

console.log(product*[i][j]);
}}

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

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

sorry second one is corrected
to what i was attempting
agaudet84
@agaudet84
Mar 21 2016 04:51
@gtyrrell4 you're close look at your console.log you are missing a certain array
Francis
@Francis-p
Mar 21 2016 04:51
@gtyrrell4 syntex error i guess
Kevin Nelms Baxter II
@kbax6342
Mar 21 2016 04:52
thanks @qualitymanifest
CamperBot
@camperbot
Mar 21 2016 04:52
kbax6342 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1092 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Francis
@Francis-p
Mar 21 2016 04:52
the way u call for the array is wrong
shanky
@shaanky
Mar 21 2016 04:52
@gtyrrell4 try this product * = arr[i][j]
Garrett Tyrrell
@gtyrrell4
Mar 21 2016 04:54
in what way do i call for it wrong?
Artur Sęp
@a-sep
Mar 21 2016 04:54
format help
help format
CamperBot
@camperbot
Mar 21 2016 04: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

agaudet84
@agaudet84
Mar 21 2016 04:55
@gtyrrell4 [i] and [j] mean nothing alone you have to attach those to an object , in this case your array, arr.
Artur Sęp
@a-sep
Mar 21 2016 04:58
@gtyrrell4 try
product *= arr[i][j];
Sean
@burritoranch
Mar 21 2016 04:59
anyone know how to reset your code without opening up the actual challenge? Accidentally created an infinite loop.
Garrett Tyrrell
@gtyrrell4
Mar 21 2016 04:59
@agaudet84 so if i changed the console log to console.log(product*arr[i][j])
@a-sep I tried that in my console and set alone
it didnt solve
agaudet84
@agaudet84
Mar 21 2016 05:00
that will show you whats happening but you want to store the result to the product variable. Like product *= arr[i][j];
Artur Sęp
@a-sep
Mar 21 2016 05:02
@gtyrrell4 it works for me
  var product = 1;
  // Only change code below this line
  for(var i=0; i<arr.length; i++){
    for(var j=0; j<arr[i].length; j++){

      product *= arr[i][j];
      console.log(product);
    }
  }
  // Only change code above this line
  return product;
}
Garrett Tyrrell
@gtyrrell4
Mar 21 2016 05:06
it works if i paste it. i guess there something wrong in my code. thanks @agaudet84 & @a-sep
CamperBot
@camperbot
Mar 21 2016 05:06
gtyrrell4 sends brownie points to @agaudet84 and @a-sep :sparkles: :thumbsup: :sparkles:
:star: 231 | @agaudet84 | http://www.freecodecamp.com/agaudet84
:star: 277 | @a-sep | http://www.freecodecamp.com/a-sep
Sean
@burritoranch
Mar 21 2016 05:08
help reset code
CamperBot
@camperbot
Mar 21 2016 05:08
no wiki entry for: reset code
Joseph
@revisualize
Mar 21 2016 05:09
Hello.
DJ
@qualitymanifest
Mar 21 2016 05:09
@burritoranch you have an infinite loop?
Joseph
@revisualize
Mar 21 2016 05:10
help storage
CamperBot
@camperbot
Mar 21 2016 05:10

:point_right: browser storage [wiki]

Store data in web browser's storage

In order to manage data handled by your web application, you do not necessarily need a database.
The respective Browser Storage features are supported by Chrome (version 4 and higher), Mozilla Firefox (version 3.5 and higher) and Internet Explorer (version 8 and higher), and a range of other browsers including those of iOS and Android.

There are two main possibilities for browser storage:

1. localStorage

Any content/data saved to the localStorage object will be available after the browser has been restarted (closed and opened again).
In order to save an item to localStorage, you can use the method setItem(). This method must be handed a key and a value.

Example: localStorage.setItem("mykey","myvalue");

To retrieve the item from the localStorage, the method getItem must be used. The getItem method must be handed the key of the data you would like to retrieve:

  Example: localStorage.getItem("mykey");

:pencil: read more about browser storage on the FCC Wiki

Joseph
@revisualize
Mar 21 2016 05:10
That's not what I wanted.
Sean
@burritoranch
Mar 21 2016 05:11
@qualitymanifest yes I accidently created one, and I did a dumb thing by applying // no protect
Stanley
@stanleyyylau
Mar 21 2016 05:12
i'm at Binary Agents chalenge now
DJ
@qualitymanifest
Mar 21 2016 05:12
wiki auto
CamperBot
@camperbot
Mar 21 2016 05:12

:point_right: disable code auto run [wiki]

By default, the Free Code Camp site automatically loads and runs your last recorded solution. If you have accidentally created an infinite loop or other irrecoverable error or simply don't trust the code, you can disable code auto-run by putting the following in your URL:
run=disabled

Example:

URL: http://www.freecodecamp.com/challenges/Algorithm-meet-Algorithm#?solution=function%20meetBonfire(argument)

No-Run URL: http://www.freecodecamp.com/challenges/Algorithm-meet-Algorithm#?run=disabled&solution=function%20meetBonfire(argument)

:pencil: read more about disable code auto run on the FCC Wiki

Stanley
@stanleyyylau
Mar 21 2016 05:12
does js have a built in function that convert binary to decimal?
DJ
@qualitymanifest
Mar 21 2016 05:12
@burritoranch :point_up:
Sean
@burritoranch
Mar 21 2016 05:12
thank you @qualitymanifest
CamperBot
@camperbot
Mar 21 2016 05:12
burritoranch sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1093 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
BRlau
@BRlau
Mar 21 2016 05:21
function queue(arr, item) {
  // Your code here
  arr.shift([1]);
  return item + 0;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Write a function queue 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 queue function should then return the element that was removed.
i am not sure how is it done, do shift and return the item?
Joseph
@revisualize
Mar 21 2016 05:24

@revisualize
@BRlau HOw do you add an item to the end of an array?

var myArr = [1,2,3];

How do I add 4 to the end of myArr?

Seeing how you're going to ask two places.
Artur Sęp
@a-sep
Mar 21 2016 05:41
It's time to go to work :worried: happy coding
AudioGen
@AudioGen
Mar 21 2016 05:42
@revisualize push() method
Joseph
@revisualize
Mar 21 2016 05:42
@AudioGen Why. Yes. Thank you. Except I was trying to assist someone with the challenge that they're having issues with.
CamperBot
@camperbot
Mar 21 2016 05:42
revisualize sends brownie points to @audiogen :sparkles: :thumbsup: :sparkles:
:star: 328 | @audiogen | http://www.freecodecamp.com/audiogen
AudioGen
@AudioGen
Mar 21 2016 05:43
oh ok
BRlau
@BRlau
Mar 21 2016 05:51
@revisualize alright @@ thanks tho
CamperBot
@camperbot
Mar 21 2016 05:51
brlau sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star: 764 | @revisualize | http://www.freecodecamp.com/revisualize
BRlau
@BRlau
Mar 21 2016 05:52
@revisualize i dont know why i cant hit enter in ther other chatroom
JiaLe Guo
@gabygoole
Mar 21 2016 06:07
function rot13(str) { // LBH QVQ VG!
  var resStr = "";
  var tmp;
  for(var i = 0; i < str.length; i++) {
    if ((tmp = str.charCodeAt(i)) >= 65 && (tmp = str.charCodeAt(i) <= 90)) {
       if(tmp <= 77) {
         resStr += String.fromCharCode(tmp + 13);
       } else {
         resStr += String.fromCharCode(tmp - 13);
       }
    } else {
      resStr += str.charAt(i);
    }
  }
  console.log(resStr);
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
I think my logic on solving this problem is nothing wrong why I can only see punctuation in my resStr?
Norman Dela Cruz
@dcnr
Mar 21 2016 06:13

@gabygoole do it like

for(var i = 0; i < str.length; i++) {
    tmp = str.charCodeAt(i);
    if (tmp >= 65 && tmp <= 90) {

also don't forget to replace console.log(resStr); with return resStr;

Pascal T.
@omegga
Mar 21 2016 06:13
help map the debris
CamperBot
@camperbot
Mar 21 2016 06:13

:point_right: algorithm map the debris [wiki]

Problem Explanation:

The first thing to do is to get familiar with what the program is for, for this I would suggest you check the Wikipedia link as that is very important and from where you can also get the formula for the conversion. The hardest part are finding the formula, implementing it and for some modifying objects by the key. However, something that is not very clear is the fact that your program has to be able to check for any number of objects in the array which is what is tested on the second part.

:pencil: read more about algorithm map the debris on the FCC Wiki

shanky
@shaanky
Mar 21 2016 06:13
Hello guys
i need help to complete challnge -Make Object Properties Private
Can anyone help me???
JiaLe Guo
@gabygoole
Mar 21 2016 06:14
@dcnr Yeah! It works! why?
Cosimo Bressi
@cbressijr
Mar 21 2016 06:15
@shaanky Whats the challenge? Can you link? Been a bit since I played in Java.
Pascal T.
@omegga
Mar 21 2016 06:15
@shaanky maybe
JiaLe Guo
@gabygoole
Mar 21 2016 06:15
@dcnr Is this javascript format?
@dcnr Or a bug?
shanky
@shaanky
Mar 21 2016 06:16
var Bike = function() {

  // Only change code below this line.

var gear = 5;
  this.getGear = function()
{
    get = gear;
  };

  this.setGear = function()
  {
    set = gear;
  };
};

var myBike = new Bike();
no problm @Scriptonaut and @cbressijr
Markus Kiili
@Masd925
Mar 21 2016 06:16
@gabygoole Yes, tmp = str.charCodeAt(i) <= 90 will make tmp hold a boolean.
shanky
@shaanky
Mar 21 2016 06:17
tell me what i m doing wrong ??
Norman Dela Cruz
@dcnr
Mar 21 2016 06:17
@gabygoole you shouldn't do assignments in your conditional statements.
Pascal T.
@omegga
Mar 21 2016 06:17
@shaanky private property are made using '''var'''
CamperBot
@camperbot
Mar 21 2016 06:17
:bulb: to format code use backticks! ``` more info
Norman Dela Cruz
@dcnr
Mar 21 2016 06:17
yeah what @Masd925 said
Cosimo Bressi
@cbressijr
Mar 21 2016 06:17
So your trying for something similar to function Container(param) { this.member = param; var secret = 3; var that = this; }
shanky
@shaanky
Mar 21 2016 06:18
yes , i know it that is why i used var gear @Scriptonaut
Pascal T.
@omegga
Mar 21 2016 06:18
@shaanky when you want to get the value of a private property you call the getter, here it's getGear
shanky
@shaanky
Mar 21 2016 06:18
@cbressijr what you want to say abt my code?
Pascal T.
@omegga
Mar 21 2016 06:18
@shaanky but getGear does not return gear
shanky
@shaanky
Mar 21 2016 06:19
you mean i hv to write like this
return gear;
@Scriptonaut
ryt
?
RyanEnright
@RyanEnright
Mar 21 2016 06:20
@shaanky yes
Pascal T.
@omegga
Mar 21 2016 06:21
@shaanky that's how i would do it based from what ive learned
shanky
@shaanky
Mar 21 2016 06:21
var Bike = function() {  
var gear = 4;
  this.getGear = function()
{
    return gear;
  };

  this.setGear = function()
  {
      Value = gear;
  };
};

var myBike = new Bike();
so is this ryt??
JiaLe Guo
@gabygoole
Mar 21 2016 06:21
@Masd925 But I do it in this way:(tmp = str.charCodeAt(i)) <= 90 I add () to represent it is all in one
RyanEnright
@RyanEnright
Mar 21 2016 06:22
@shaanky setGear should be gear = set;
Pascal T.
@omegga
Mar 21 2016 06:22
@shaanky when you call the setter , you do it like this : setGear(5) for example so you'll have to use a parameter
Markus Kiili
@Masd925
Mar 21 2016 06:23
@gabygoole Yes, but your second one was (tmp = str.charCodeAt(i) <= 90)) which screws it up.
JiaLe Guo
@gabygoole
Mar 21 2016 06:24
@Masd925 oh god ! thanks ! I make a mistake
CamperBot
@camperbot
Mar 21 2016 06:24
gabygoole sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1200 | @masd925 | http://www.freecodecamp.com/masd925
shanky
@shaanky
Mar 21 2016 06:25
i dont understand @RyanEnright and @Scriptonaut
please try to elaborate
i will appreciate it
Alex Praveen
@Alexgeo007
Mar 21 2016 06:27
can anyone help me wats wrong with this code???

function myTest(val) {
var answer = "";
// Only change code below this line

switch(val){
case 1: val==="a"
answer="apple";
break;
case 2: val==="b"
answer="bird";
break;
case 3: val==="c"
answer="cat";
break;
default:
answer="stuff";
}

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

// Change this value to test
myTest("c");

Pascal T.
@omegga
Mar 21 2016 06:27
@shaanky I'm not too advanced on this, but this how i would do it :
this.setGear = function(value){
gear = value;
};
RyanEnright
@RyanEnright
Mar 21 2016 06:27
This message was deleted
shanky
@shaanky
Mar 21 2016 06:29
@Alexgeo007 when you pass arguments to function that should reflect in case like this
switch(val)
{
case "a":
answer ="apple";
break;
......etc..
case "c":
answer="cat";
break;
}
@Alexgeo007 like this use can do whole thing
Alex Praveen
@Alexgeo007
Mar 21 2016 06:32
@shaanky thank u mate :smile:
CamperBot
@camperbot
Mar 21 2016 06:32
alexgeo007 sends brownie points to @shaanky :sparkles: :thumbsup: :sparkles:
:star: 134 | @shaanky | http://www.freecodecamp.com/shaanky
shanky
@shaanky
Mar 21 2016 06:32
anytime @Alexgeo007
@Scriptonaut it works man.... :smile:
@Scriptonaut thnx buddy
CamperBot
@camperbot
Mar 21 2016 06:33
shaanky sends brownie points to @scriptonaut :sparkles: :thumbsup: :sparkles:
:star: 317 | @scriptonaut | http://www.freecodecamp.com/scriptonaut
Pascal T.
@omegga
Mar 21 2016 06:33
np
thanks @RyanEnright also
CamperBot
@camperbot
Mar 21 2016 06:34
scriptonaut sends brownie points to @ryanenright :sparkles: :thumbsup: :sparkles:
:star: 264 | @ryanenright | http://www.freecodecamp.com/ryanenright
走你飛艇
@gofighting123
Mar 21 2016 06:37
why c9 server's response so slow from Asia :zzz:
Stanley
@stanleyyylau
Mar 21 2016 06:40
the great firewall ?
Richard
@rick104
Mar 21 2016 06:42
hi there, how come collectionid.push(value); is not adding the value to the end of the array, it just sets tracks to the string "value"
collectionid.push(value);
走你飛艇
@gofighting123
Mar 21 2016 06:42
@stanleyyylau have no idea, @@ i use no proxy ( auto detect )
Richard
@rick104
Mar 21 2016 06:42
"collectionid.push(value);"
[]
someone please help me
走你飛艇
@gofighting123
Mar 21 2016 06:43
oh my god...c9 web is Reconnecting....
shanky
@shaanky
Mar 21 2016 06:45
@rick104 first create format
we really do not understand what your code saying
Richard
@rick104
Mar 21 2016 06:47
its an object > object> array
shanky
@shaanky
Mar 21 2016 06:47
and mention which challnge
Richard
@rick104
Mar 21 2016 06:47
from Record Collection
javascript
RyanEnright
@RyanEnright
Mar 21 2016 06:48
@rick104 collection[id].push(value) I believe is the correct format
Richard
@rick104
Mar 21 2016 06:50
how does it know to push it to tracks
shanky
@shaanky
Mar 21 2016 06:50
This message was deleted
This message was deleted
RyanEnright
@RyanEnright
Mar 21 2016 06:50
@rick104
if (prop == "tracks" && value !== "") {
  collection[id].tracks.push(value);
Richard
@rick104
Mar 21 2016 06:51
ohhh
shanky
@shaanky
Mar 21 2016 06:51
(prop == "tracks" && value !== ""){
   collection[id][prop].push(value);
   return collection;
@rick104 try this way
RyanEnright
@RyanEnright
Mar 21 2016 06:54
@rick104 one clue that helped me on that challenge was start your function with the second part of the instructions
Richard
@rick104
Mar 21 2016 06:56

if(value===""){
collection[id][prop] = "";

}

is that unsetting it? doesnt seem to work
doesnt pass the test
Richard
@rick104
Mar 21 2016 07:01
wait it worked now, ty
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 07:02
hello fellas
My code need help from you :(
$(document).ready(function() {
  $("#trigger").click(function(event) {
    $.getJSON("http://quotes.rest/quote.json", function(data) {
      $("#quote").html(data.quote);
      $("#author").html(data.author);
    });
  });
});
is there anyone's here?
Pascal T.
@omegga
Mar 21 2016 07:09
@kenniga are you targeting the right properties of your json ?
kirbyedy
@kirbyedy
Mar 21 2016 07:09
@kenniga did you put that link in the browser ?
it says unauthorise
error 401
maybe you need some api key ?
https://theysaidso.com/api/ <-- apparently you have to sign up, to use it, read here...
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 07:12
ah sorry, wrong one
here's the right one
$(document).ready(function() {
  $("#trigger").click(function(event) {
    $.getJSON("http://quotesondesign.com/api/3.0/api-3.0.json", function(data) {
      $("h2").html(data.quote);
      $("h4").html(data.author);
    });
  });
});
kirbyedy
@kirbyedy
Mar 21 2016 07:12
ok and what is the output you are getting ?
do you have a codepen link ?
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 07:13
@kirbyedy there's nothing working
here's my codepen
kirbyedy
@kirbyedy
Mar 21 2016 07:14
I think you need some kind of callback in order to work
http://quotesondesign.com/api/3.0/api-3.0.json ?callback=my_function
something like this
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 07:19
@kirbyedy nah, actually, there's a instruction like that on the blog
yes, here
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 07:21
@kirbyedy it contains "wp-json". is it means only affect on wordpress?
Olawale Akinseye
@brainyfarm
Mar 21 2016 07:23
help exact change
CamperBot
@camperbot
Mar 21 2016 07:23

:point_right: algorithm exact change [wiki]

Problem Explanation:

  • You have to create a program that will handle when the register does not have
    enough cash or will have no cash after the transaction. Other than that it
    needs to return an array of the change in the form of an array, so that will
    be a 2D array.
:pencil: read more about algorithm exact change on the FCC Wiki
kirbyedy
@kirbyedy
Mar 21 2016 07:23
@kenniga I dont think so
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 07:24
well, I'll try then
thanks @kirbyedy
CamperBot
@camperbot
Mar 21 2016 07:24
kenniga sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 702 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
kirbyedy
@kirbyedy
Mar 21 2016 07:25
I do remember that some campers used this for the quote challenge, so it should work
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 07:28
@kirbyedy it still not working :(
kirbyedy
@kirbyedy
Mar 21 2016 07:32
http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback= this should work
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 07:34
$(document).ready(function() {
  $("#trigger").click(function(event) {
    $.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(data) {
      $("h2").html(data.content);
      $("h4").html(data.title);
    });
  });
});
Pascal T.
@omegga
Mar 21 2016 07:35

@kenniga try this :

$(document).ready(function() {
  $("#trigger").click(function(event) {
    $.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(data) {
      $("h2").html(data[0].content);
    });
  });
})

check data[0] carefully

Achilleas Papakonstantinou
@AchiPapakon
Mar 21 2016 07:37
This message was deleted
CamperBot
@camperbot
Mar 21 2016 07:37
no wiki entry for: exact chagne
Achilleas Papakonstantinou
@AchiPapakon
Mar 21 2016 07:37
help exact change
CamperBot
@camperbot
Mar 21 2016 07:37

:point_right: algorithm exact change [wiki]

Problem Explanation:

  • You have to create a program that will handle when the register does not have
    enough cash or will have no cash after the transaction. Other than that it
    needs to return an array of the change in the form of an array, so that will
    be a 2D array.
:pencil: read more about algorithm exact change on the FCC Wiki
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 07:40
@Scriptonaut I thought data.content straight through object properties
it's not working :(
I'm curious, how to debugging javascript activity?
kirbyedy
@kirbyedy
Mar 21 2016 07:42
@kenniga did you try this what @Scriptonaut wrote
it should work
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 07:42
@kirbyedy yes I did, it's still not working
kirbyedy
@kirbyedy
Mar 21 2016 07:42
I am getting the quote in your pen
the only problem its 1 quote, does not rotate
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 07:43
wait, it works....
weird...
so, is "[0]''s means the first array properties?
kirbyedy
@kirbyedy
Mar 21 2016 07:45
yes
first element in the array
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 07:46
is it should be ID's? The first properties on array's quote?
[
{
ID: 680,
title: "Robert Henri",
content: "<p>It is not easy to know what you like. Most people fool themselves their entire lives about this. Self-acquaintance is a rare condition. </p> ",
link: "http://quotesondesign.com/robert-henri/"
}
]
kirbyedy
@kirbyedy
Mar 21 2016 07:48
what you just pasted is 1 object
so whole this is 1 element in the array
lets say element 0
and then you access your title with data[0].title
data[0].content
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 07:50
oooh! I got it!
@kirbyedy you explain everything!
thank you @kirbyedy ! Many thank you!
CamperBot
@camperbot
Mar 21 2016 07:51
kenniga sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:warning: kenniga already gave kirbyedy points
kirbyedy
@kirbyedy
Mar 21 2016 07:56
:thumbsup:
help me!
CamperBot
@camperbot
Mar 21 2016 07:56

:point_right: adding environment variables [wiki]

In Windows

Via GUI

  1. Download Varpanel.
  2. Open Varpanel.
  3. In PATH variable, add the relevant path (for example).

:pencil: read more about adding environment variables on the FCC Wiki

maotao
@maotao1
Mar 21 2016 07:56
please!
please help me
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 07:57
@maotao1 could you just paste the code?
Ayo Isaiah
@ayoisaiah
Mar 21 2016 07:57
Hello guys. I don't know why my code is not passing the tests for the Caesers Cipher bonfire despite returning the correct value. Can anyone help me out?
maotao
@maotao1
Mar 21 2016 07:57
year
yes
Ayo Isaiah
@ayoisaiah
Mar 21 2016 07:57
function rot13 (key, str) {

        //Key is a string of 26 letters in arbitrary order
        //str is the string to be encoded using the key

        var alphabet, coded, i, ch, index;
        alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        coded = "";
        for (i = 0; i < str.length; i++) {
            ch = str.charAt(i);
            index = alphabet.indexOf(ch);
            if (index == -1) { //If it's not a letter
                coded+= ch; //Then leave as is and add
            }

            else { //Otherwise
                coded+= key.charAt(index); //Find the corresponding element in the key and add
            }
        }
        return coded;
    }

    rot13("NOPQRSTUVWXYZABCDEFGHIJKLM", "SERR PBQR PNZC");
maotao
@maotao1
Mar 21 2016 07:58
i can't resolve it

var count = 0;

function cc(card) {
// Only change code below this line
switch (card) {
case 'J':
case 'Q':
case 'K':
case 'A':
case 10:
count--;
}
if (count < 7) {
count++;
}
if (count <= 0) {
return count + " Hold";
}else if (count > 0) {
return count + " Bet";
}

// 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');

counting cards
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 07:59
@maotao1 use ```, for more comfort checking
maotao
@maotao1
Mar 21 2016 08:00
i am crying
Pascal T.
@omegga
Mar 21 2016 08:01
@ayoisaiah your key parameter is not included in freecodecamp tests
@ayoisaiah i dont think you can modify the context of the test
Ayo Isaiah
@ayoisaiah
Mar 21 2016 08:02
@Scriptonaut Does it matter? I thought it was to test onthe return value?
Pascal T.
@omegga
Mar 21 2016 08:02
try it like this :
function rot13 (str) {

        //Key is a string of 26 letters in arbitrary order
        //str is the string to be encoded using the key

        var key = "NOPQRSTUVWXYZABCDEFGHIJKLM";

        var alphabet, coded, i, ch, index;
        alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        coded = "";
        for (i = 0; i < str.length; i++) {
            ch = str.charAt(i);
            index = alphabet.indexOf(ch);
            if (index == -1) { //If it's not a letter
                coded+= ch; //Then leave as is and add
            }

            else { //Otherwise
                coded+= key.charAt(index); //Find the corresponding element in the key and add
            }
        }
        return coded;
    }

    rot13("SERR PBQR PNZC");
@ayoisaiah i think free code camps runs a lot of the tests, and rewrites the call to rot13() each time
Ayo Isaiah
@ayoisaiah
Mar 21 2016 08:03
Well well, it did work @Scriptonaut thanks a lot man, and that's noted for future challenges
CamperBot
@camperbot
Mar 21 2016 08:03
ayoisaiah sends brownie points to @scriptonaut :sparkles: :thumbsup: :sparkles:
:star: 318 | @scriptonaut | http://www.freecodecamp.com/scriptonaut
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 08:05
var count = 0;

function cc(card) {
  // Only change code below this line
  switch (card) {
case 'J':
case 'Q':
case 'K':
case 'A':
case 10:
count--;
}
if (count < 7) {
count++;
}
if (count <= 0) {
return count + " Hold";
}else if (count > 0) {
return count + " Bet";
}

  // 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');
Olawale Akinseye
@brainyfarm
Mar 21 2016 08:05
@kenniga ?
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 08:06
@brainyfarm I'm trying to move it to comfort view mode :D
Olawale Akinseye
@brainyfarm
Mar 21 2016 08:06
Are you having a problem with the challenge @kenniga ?
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 08:07
@brainyfarm no, it's @maotao1 who asking
Marius Brad
@mbrad26
Mar 21 2016 08:07
hello world
CamperBot
@camperbot
Mar 21 2016 08:07

welcome to FreeCodeCamp @mbrad26!

Olawale Akinseye
@brainyfarm
Mar 21 2016 08:07
Cool @kenniga :+1:
good job
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 08:07
@mbrad26 hello too
Olawale Akinseye
@brainyfarm
Mar 21 2016 08:08
welcome and hello @mbrad26 :D
Marius Brad
@mbrad26
Mar 21 2016 08:08

I'm out of ideas ...any kind of help appreciated: ```function convert(str) {

var exp = {"\&": "\&", "\<": "\<", ">": "\>", "\"": "\"", "\'": "\'"};

for(var key in exp) {
if(str.includes(key)) {
str = str.replace(/[&<>"']/g, exp[key]);
} else {
str = str;
}

}

return str;

}

convert("Dolce & Gabbana");```

Is the Convert HTML Entities challenge
alpox
@alpox
Mar 21 2016 08:10
@mbrad26 take a look at the regex object --> new Regexp() (or Regex, i dont remember it exactly)
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 08:10
@maotao1 well, so the function sholud return total of count card
Olawale Akinseye
@brainyfarm
Mar 21 2016 08:11
@mbrad26
Now that you have an object, you should assign the html entities equivalent to each of the object item.
Marius Brad
@mbrad26
Mar 21 2016 08:11
I've been looking at it for the past 18h:).
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 08:12
@maotao1 why you let the case's value empty?
alpox
@alpox
Mar 21 2016 08:12
@mbrad26 you cannot replace all of these characters in each cycle. And you didnt use the real html entities yet --> &lt;as example
Marius Brad
@mbrad26
Mar 21 2016 08:12
My code is working fine guys is just the the test before the last one that doesn't go through
for this test convert("<>") , it only finds and replaces the first "<"
Olawale Akinseye
@brainyfarm
Mar 21 2016 08:13
@mbrad26
var translation  = {"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;"};
alpox
@alpox
Mar 21 2016 08:13
@mbrad26 the html entities includes an & character. This one should not be overwritten in the next cycle
Olawale Akinseye
@brainyfarm
Mar 21 2016 08:13
I do not understand why your code should work @mbrad26 .
maotao
@maotao1
Mar 21 2016 08:14
i am start it ,not long time@kenniga
Marius Brad
@mbrad26
Mar 21 2016 08:15
@brainyfarm is just the same.
@alpox I'm really sorry but I just don't follow
kirbyedy
@kirbyedy
Mar 21 2016 08:16
I was using str.replace() for that challenge
concatenating them in a sausage line :D
alpox
@alpox
Mar 21 2016 08:16
@mbrad26 you can have & characters in the string you have to escape. You have to replace them. BUT if you do that 2 times, you have more of them in your string because all escape series have an & inside which gets replaced again in the next cycle and so on
lpix
@lpix
Mar 21 2016 08:17
@mbrad26 you don't need to use strings..you can use RegExp just type /*your regexp*\ g (g for global)
alpox
@alpox
Mar 21 2016 08:17
& gets & which then gets &amp; which then gets &amp;amp;
Marius Brad
@mbrad26
Mar 21 2016 08:17
I'm sorry, but you are wrong:)
alpox
@alpox
Mar 21 2016 08:18
Ups there is always one more :-D it got replaced in chat
Marius Brad
@mbrad26
Mar 21 2016 08:18
it only searces for & just once
Please run my code and see what happends:).
alpox
@alpox
Mar 21 2016 08:19
@mbrad26 you are wrong. It just replaces with it only once. But you replace ALL characters with it as far as i see.
Since your regex searches for all characters at one
Olawale Akinseye
@brainyfarm
Mar 21 2016 08:19
@mbrad26
Since you have the object translation, just loop through the string and replace the character with its value if it exists in the translation object.
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 08:20
@maotao1 how about the other number?
Olawale Akinseye
@brainyfarm
Mar 21 2016 08:20
I did some like this:
str.split("").map(function (e){
   // Checking the items 
    if (e in translation){ str = str.replace(e, translation[e]);}
  }); // End of mapping
alpox
@alpox
Mar 21 2016 08:20
str.replace(new Regexp(key, 'g'), exp[key])
shanky
@shaanky
Mar 21 2016 08:21
@brainyfarm hello, How r u???
Kenni Gandira Alamsyah
@kenniga
Mar 21 2016 08:21
@maotao1 it should add +1, each of them (unless 7,8,9)
Olawale Akinseye
@brainyfarm
Mar 21 2016 08:21
Good morning @shaanky and welcome back :D
shanky
@shaanky
Mar 21 2016 08:21
do you remember me???
alpox
@alpox
Mar 21 2016 08:21
Or what brainfarmy said
shanky
@shaanky
Mar 21 2016 08:21
i dont think so??
Olawale Akinseye
@brainyfarm
Mar 21 2016 08:21
Why not @shaanky ?
It was you, myself and Anthony @shaanky :P
Selvalingam G
@selva2389
Mar 21 2016 08:23

'''
function where(arr, num) {
// Find my place in this sorted array.

arr.sort();

var index;

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

if(num<=arr[0]){
  index=0;
   break;
}else if(num>arr[arr.length-1]){
  index=arr.length;
   break;
}
else if(num>arr[i]&&num<arr[i+1]){
   index=i+1;
   break;
}else if(num==arr[i]){
  index=i;
  break;
}

}
return index;
'''

CamperBot
@camperbot
Mar 21 2016 08:23
:bulb: to format code use backticks! ``` more info
Selvalingam G
@selva2389
Mar 21 2016 08:24

'''function where(arr, num) {

arr.sort();

var index;

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

if(num<=arr[0]){
  index=0;
   break;
}else if(num>arr[arr.length-1]){
  index=arr.length;
   break;
}
else if(num>arr[i]&&num<arr[i+1]){
   index=i+1;
   break;
}else if(num==arr[i]){
  index=i;
  break;
}

}
return index;

CamperBot
@camperbot
Mar 21 2016 08:24
:bulb: to format code use backticks! ``` more info
Selvalingam G
@selva2389
Mar 21 2016 08:25

''' function where(arr, num) {
// Find my place in this sorted array.

arr.sort();

var index;

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

if(num<=arr[0]){
  index=0;
   break;
}else if(num>arr[arr.length-1]){
  index=arr.length;
   break;
}
else if(num>arr[i]&&num<arr[i+1]){
   index=i+1;
   break;
}else if(num==arr[i]){
  index=i;
  break;
}

}
return index;
''' only one input is not working !!

CamperBot
@camperbot
Mar 21 2016 08:25
:bulb: to format code use backticks! ``` more info
swoertz
@swoertz
Mar 21 2016 08:26
@mbrad26 : @alpox gave you the solution. do you understand what was wrong?
V Arun Kumar
@arunvkumr
Mar 21 2016 08:32
@SelvalingamG can you post more info.. what's the challenge and for which test case it's not working?
Lawrence Archer
@LawrenceArcher
Mar 21 2016 08:35
Hi there guys, I have a question about the Profile Lookup exercise, I've managed to complete it but honestly am not sure that my way of completing the problem was the right one, would it be ok if I post it here and someone could tell me if it was right? Thanks
Selvalingam G
@selva2389
Mar 21 2016 08:35
'''
CamperBot
@camperbot
Mar 21 2016 08:35
:bulb: to format code use backticks! ``` more info
V Arun Kumar
@arunvkumr
Mar 21 2016 08:35
@LawrenceArcher post your code.. :grinning:
Lawrence Archer
@LawrenceArcher
Mar 21 2016 08:35
for (var i = 0; i < contacts.length; i++) {
    if (firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    }
  }
  for (i = 0; i < contacts.length; i++){
    if (firstName != contacts[i].firstName){
      return "No such contact";
    }else if (contacts[i].hasOwnProperty(prop) === false){
      return "No such property";
    }
  }
V Arun Kumar
@arunvkumr
Mar 21 2016 08:37
@SelvalingamG use backticks.. the one above the tab.
bot format
CamperBot
@camperbot
Mar 21 2016 08:37

: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

Martin Aarhus Gregersen
@gregersen12
Mar 21 2016 08:37
Hey guys. I'm currently doing the algorythmic exercises, and I came across the factorialize. I can't quite comprehend how I would go about solving an issue like that.
I'm thinking something like 1...num ** ?? (all numbers between 1 and entered number times.. Yeah).
Am I thinking in the right direction?
Selvalingam G
@selva2389
Mar 21 2016 08:38

'''
function where(arr, num) {

arr.sort();

var index;

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

if(num<=arr[0]){
  index=0;
   break;
}else if(num>arr[arr.length-1]){
  index=arr.length;
   break;
}
else if(num>arr[i]&&num<arr[i+1]){
   index=i+1;
   break;
}else if(num==arr[i]){
  index=i;
  break;
}

}
return index;

}

where([5, 3, 20, 3], 5);
'''

for above input its failing.. i understand its bec of same consecutive numbers!!! but when i tried sort for this input it showing like [20,3,3,5] Is it correct?

CamperBot
@camperbot
Mar 21 2016 08:38
:bulb: to format code use backticks! ``` more info
V Arun Kumar
@arunvkumr
Mar 21 2016 08:38
@LawrenceArcher code looks good... you got it right.. instead of using two for loops just one would be enough.. :grinning:
Lawrence Archer
@LawrenceArcher
Mar 21 2016 08:41
ok thanks @arunkumrv how would I use just one though? I attempted that a fair few times and always just ended up with the loops exiting before they were complete because I couldn't place my return "No such contact" and return "no such property" lines in the right place so that I could fully check all the objects
CamperBot
@camperbot
Mar 21 2016 08:41
lawrencearcher sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 377 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
shanky
@shaanky
Mar 21 2016 08:41
@gregersen12 first of all you need to write if condition to check wheather give number is zero or not.
@gregersen12 after the in else condition you need to write recurrsion
V Arun Kumar
@arunvkumr
Mar 21 2016 08:42
@SelvalingamG by default the sort functions sorts the array characterwise.. not numberically.. for that you need a function inside sort... read about sort here..
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
shanky
@shaanky
Mar 21 2016 08:42
@brainyfarm yes thats ryt ... :smile:
@brainyfarm r u there??
where is anthony???? @brainyfarm
:smile:
V Arun Kumar
@arunvkumr
Mar 21 2016 08:45
This message was deleted
Martin Aarhus Gregersen
@gregersen12
Mar 21 2016 08:46
@shaanky thank you I'll try that out, I was already heading in that direction, but perhaps I don't understand recursion well enough
CamperBot
@camperbot
Mar 21 2016 08:46
gregersen12 sends brownie points to @shaanky :sparkles: :thumbsup: :sparkles:
:star: 147 | @shaanky | http://www.freecodecamp.com/shaanky
Olawale Akinseye
@brainyfarm
Mar 21 2016 08:47
Yes, I am here @shaanky
shanky
@shaanky
Mar 21 2016 08:47
ok np here is code you can do it and just dont copy it try to understand it.
@gregersen12
function factorialize(num) 
{
  if(num === 0)
  {
    return 1;
  }
  return num * factorialize(num - 1);
}

factorialize(5);
Lawrence Archer
@LawrenceArcher
Mar 21 2016 08:48
@arunkumrv brilliant thank you ever so much for your help
CamperBot
@camperbot
Mar 21 2016 08:48
lawrencearcher sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:warning: lawrencearcher already gave arunkumrv points
shanky
@shaanky
Mar 21 2016 08:48
ok @brainyfarm i need help regarding "Check for Palindromes
"
Olawale Akinseye
@brainyfarm
Mar 21 2016 08:48
Expired Message
Martin Aarhus Gregersen
@gregersen12
Mar 21 2016 08:48
@shaanky I totally understand that! It's so easy to read
The problem is I can't come up with these kind of solutions myself :(
shanky
@shaanky
Mar 21 2016 08:50
@gregersen12 you must be know practice makes man perfect :smile: it takes time
buddy @gregersen12 its not the process like over night you can
Martin Aarhus Gregersen
@gregersen12
Mar 21 2016 08:50
Yeah I realize that, I have just been doing web programming for almost 3 years and I still keep coming up short on anything slightly advanced =/ It's kinda frustrating at this point
shanky
@shaanky
Mar 21 2016 08:50
@brainyfarm i have not write the code yet
Martin Aarhus Gregersen
@gregersen12
Mar 21 2016 08:51
I'm trying to get into algorhytmic thinking because it's based on problem solving, which seems to be a weakness of mine
shanky
@shaanky
Mar 21 2016 08:51
i want to tell you what i m thinking abt that example
is i need to take first character of string and compare it to the last character of string...is this ryt??? @brainyfarm
@gregersen12 get class from someone who is best programmer
Martin Aarhus Gregersen
@gregersen12
Mar 21 2016 08:54
Yeah. I just don't know any I'm afraid
V Arun Kumar
@arunvkumr
Mar 21 2016 08:55
@LawrenceArcher Adding comments to understand what's happening in the code. :grinning:
// the loops checks for entires in the contacts array and if the contact exists.. then only this two conditions exists.. either he exists and has a property or he exists and has no property.. if he doesn't exist do nothing just loop on to next entry.
for (var i = 0; i < contacts.length; i++) {
    // check if the contact exists. if he exists either of the condition must return.. if not then he doesn't exist.
    if (firstName === contacts[i].firstName) // <- this condition is necessary for returning property and no such property.
    {
        // the contact exist and has a property return that property.
        if (contacts[i].hasOwnProperty(prop))
            return contacts[i][prop];
        // the constact exists and doesn't have the property, then return no such property.
        else if (contacts[i].hasOwnProperty(prop) === false)
            return "No such property";
    }
    // now you are out of loop.. that means the contact doesn't exist.. then just return no such contact.
    return "No such contact";
}
shanky
@shaanky
Mar 21 2016 08:55
@gregersen12 no prblm you can study frm this it self and most important just try to ask @brainyfarm he is genius
Olawale Akinseye
@brainyfarm
Mar 21 2016 08:55

No @shaanky .
Here is what you might do.

  • convert the string to lowercase.
  • replace all weird/unneeded characters. (save in a variable) let us call it a

    • Reverse the new using .split('').reverse().join() (save in a variable) let us call this one a
  • now, compare a to b

Selvalingam G
@selva2389
Mar 21 2016 08:56
@arunkumrv thanks.i'm done.!
V Arun Kumar
@arunvkumr
Mar 21 2016 08:57
@SelvalingamG you're welcome... :grinning:
shanky
@shaanky
Mar 21 2016 08:57
@brainyfarm actully i did the first and second which are lowercase and replace string,
@brainyfarm ok as my mentor says i'll do :smile:
Achilleas Papakonstantinou
@AchiPapakon
Mar 21 2016 08:58
Hi, is there a way to filter an array (arr1) based on values of another array (marked, which has values wither 1 or 0)?
I want to push into the array "inv" the values of arr1 based on this creterion: the values of marked with the same index as arr1 which are not equal to 1.
inv.push(arr1.filter(function(val, index) {

    return marked[index] !== 1;
  }));
`return marked[index] !== 1; checks only for index = 0
shanky
@shaanky
Mar 21 2016 08:59
@brainyfarm one morething can you teach me regular exp. i really can not get it
Achilleas Papakonstantinou
@AchiPapakon
Mar 21 2016 09:00
@shaanky try http://regexr.com/
Abdullah Hoosen
@abdullahhoosen
Mar 21 2016 09:00

var myVar = 87;

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

how to get 87"?
I mean 88
rphares
@rphares
Mar 21 2016 09:01
very close, @abdullahhoosen --
check the note in the instructions,
when you use myVar++, it can replace the entire line,
shanky
@shaanky
Mar 21 2016 09:01
@abdullahhoosen you just need to write return myVar++;
Abdullah Hoosen
@abdullahhoosen
Mar 21 2016 09:01
ohh
haha
Thanks
mwah
rphares
@rphares
Mar 21 2016 09:02
sure thing~ Happy coding :blush:
V Arun Kumar
@arunvkumr
Mar 21 2016 09:03
@AchiPapakon i think you can do that.. can you post your code.?
shanky
@shaanky
Mar 21 2016 09:03
@rphares hello buddy
Marius Brad
@mbrad26
Mar 21 2016 09:03
@alpox Thanks man. Made it work
CamperBot
@camperbot
Mar 21 2016 09:03
mbrad26 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 427 | @alpox | http://www.freecodecamp.com/alpox
Abdullah Hoosen
@abdullahhoosen
Mar 21 2016 09:04
But why does myVar = myVar++; only equal 87?
Olawale Akinseye
@brainyfarm
Mar 21 2016 09:05
@shaanky
There is a very useful website to learn regex.
Achilleas Papakonstantinou
@AchiPapakon
Mar 21 2016 09:05
function updateInventory(arr1, arr2) {
  var inv = [];
  var found = false;
  var marked = [];
  marked.length = arr1.length;
  console.log(marked);
    for (var j = 0; j < arr2.length; j++) {    // arr2 -> j
      found = false;
      for (var i = 0; i < arr1.length; i++) {  // arr1 -> i
        if(arr2[j][1] === arr1[i][1]) {
          console.log('i: ' + i + ' j: ' + j);
          inv.push([arr2[j][0] + arr1[i][0], arr2[j][1]]);
          //console.log('arr2[j][0]:' + arr2[j][0] + ' + ' + 'arr1[j][0]:' + arr1[j][0] + ' = ' + (arr2[j][0] + arr1[j][0]));
          found = true;
          marked[i] = true;
        }
      }
      if(!found) {
        inv.push(arr2[j]);
      }
    }
  console.log(marked);
  inv.push(arr1.filter(function(val, index) {

    return marked[index] !== 1;
  }));


  console.log(inv);
  //return inv;
}

// Example inventory lists
var curInv = [
    [21, "Bowling Ball"],
    [2, "Dirty Sock"],
    [1, "Hair Pin"],
    [5, "Microphone"]
];

var newInv = [
    [2, "Hair Pin"],
    [3, "Half-Eaten Apple"],
    [67, "Bowling Ball"],
    [7, "Toothpaste"]
];

updateInventory(curInv, newInv);
shanky
@shaanky
Mar 21 2016 09:05
yes @brainyfarm tell me which one ???
Olawale Akinseye
@brainyfarm
Mar 21 2016 09:05
I am also not a genius @shaanky .
I only try hard :P
wiki regex
CamperBot
@camperbot
Mar 21 2016 09:06

:point_right: js regex resources [wiki]

Links to useful RegEx resources.

See also: :clipboard: Tutorials | :syringe: Testing | :soccer: Games | :newspaper: Blogs | :package: Software

:pencil: read more about js regex resources on the FCC Wiki

Olawale Akinseye
@brainyfarm
Mar 21 2016 09:06
@shaanky :point_up:
V Arun Kumar
@arunvkumr
Mar 21 2016 09:06
@abdullahhoosen there is somthing called pre-increment/pre-decrement and post-increment/post- decrement when you use the increment and decrement operators..
when you use val++ this means the value will be used first and then it will be changed(incremented).. that's why myVar = myVar++; return 87..
but when you use ++val this means the values will be changed first(incremented) and then it will be used. you can try myVar = ++myVar;.
Achilleas Papakonstantinou
@AchiPapakon
Mar 21 2016 09:07
@arunkumrv Let's say marked = [1, 0, 1] and arr1 = ["a", "b", "c"], I want inv = ["b"]...
Mohammedaadem As
@mohamma548
Mar 21 2016 09:09
hello guys i need help with this function
Achilleas Papakonstantinou
@AchiPapakon
Mar 21 2016 09:09
I want to use filter(), reduce() or every() but I can't understand how...
Abdullah Hoosen
@abdullahhoosen
Mar 21 2016 09:09
@arunkumrv Thanks!
CamperBot
@camperbot
Mar 21 2016 09:09
abdullahhoosen sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 378 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
MarkHR
@MarkH16
Mar 21 2016 09:10
@duanwalker sorry I think you didn't understand my problem.In the "Accessing Nested Arrays in Objects" challenge I don't know how to access the arrays because they have no strings as names.
Here is my code:

// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

// Only change code below this line

var secondTree = ""; // Change this line

Mohammedaadem As
@mohamma548
Mar 21 2016 09:10

function update(id, prop, value) {
if(value!=="" && prop!= collection[id].hasOwnProperty(prop)){
collection[id][prop]=value;
}
else if(value!==" " && prop==collection[id].hasOwnProperty(prop)){

collection[id][prop].push(value);

}
else if(value!==""){
delete collection[id][prop];
}

return collection;
}

V Arun Kumar
@arunvkumr
Mar 21 2016 09:11
@AchiPapakon .. i think this should work.
var arr1 = ["a","b","c"];
var marked = [1,0,1];
var newArr = arr1.filter(function(val, ind){
return marked[ind] !== 1;
});
return newArr;// or console.log(newArr);
Mohammedaadem As
@mohamma548
Mar 21 2016 09:14
I need some help guys I could not push the values to the end of the tracks
shanky
@shaanky
Mar 21 2016 09:14
@brainyfarm there more than 1 link i m confused from which link i should read first :worried:
V Arun Kumar
@arunvkumr
Mar 21 2016 09:14
@MarkHgit you access arrays using index values... the index value of an array starts from 0 and ends at length of array - 1.
for example..
var arr = [1,2,3,4,5];
this means..
arr[0]=1,arr[1]=2,arr[2]=3,arr[3]=4and arr[4]=5.
if you observe... the index value starts from 0 and ends at 4.
Reza Farshbaf
@grfarshbaf
Mar 21 2016 09:14
Hello coders!
I want to check if the code is well -written
please help
for the profile lookup xercise

function lookUp(firstName, prop){
// Only change code below this line

var foundContact = "";

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

if (contacts[i].firstName == firstName) {
  foundContact = contacts[i].firstName;
  if (contacts[i].hasOwnProperty(prop)) {
    return contacts[i][prop];
  } else {
    return "No such property";
  }
}

}
if (foundContact === ""){
return "No such contact";
}
// Only change code above this line
}

Olawale Akinseye
@brainyfarm
Mar 21 2016 09:15
@shaanky
Start with http://regexone.com
shanky
@shaanky
Mar 21 2016 09:17
ok i'll do that but ryt now i need help in the same example which i told you "palindrome"
how to remove all non-alphanumeric characters @brainyfarm
V Arun Kumar
@arunvkumr
Mar 21 2016 09:18
@grfarshbaf looks good... and you got it right.. :grinning:. you don't need foundContact variable, you can directly return no such contact when the loop exists.. it will work the same..
shanky
@shaanky
Mar 21 2016 09:18
@grfarshbaf what output you are getting??
Achilleas Papakonstantinou
@AchiPapakon
Mar 21 2016 09:18
@arunkumrv It doesn't work, because marked[ind] only checks the first value which is for ind=0
Olawale Akinseye
@brainyfarm
Mar 21 2016 09:19
@shaanky use regex /[^0-9a-z]/gi, it matches all non-alphanumeric characters.
Reza Farshbaf
@grfarshbaf
Mar 21 2016 09:19
@arunkumrv the test is passed but I want to make sure if I have done it right/
V Arun Kumar
@arunvkumr
Mar 21 2016 09:19
@AchiPapakon post your code.. i have tried it here and it works without any prob..
Olawale Akinseye
@brainyfarm
Mar 21 2016 09:20
It is right when it is passed @grfarshbaf ;)
V Arun Kumar
@arunvkumr
Mar 21 2016 09:20
@grfarshbaf it's right.. :grinning:
greg
@wearenotgroot
Mar 21 2016 09:20
@mohamma548 it should be prop === "tracks" and prop !== "tracks" btw
Reza Farshbaf
@grfarshbaf
Mar 21 2016 09:20
@arunkumrv You are right!
shanky
@shaanky
Mar 21 2016 09:22
@brainyfarm i selected you for private chat but i think you dont
??
Achilleas Papakonstantinou
@AchiPapakon
Mar 21 2016 09:22
@arunkumrv I've commented your name in the line of interest
function updateInventory(arr1, arr2) {
  var inv = [];
  var found = false;
  var marked = [];
  marked.length = arr1.length;
    for (var j = 0; j < arr2.length; j++) {    // arr2 -> j
      found = false;
      for (var i = 0; i < arr1.length; i++) {  // arr1 -> i
        if(arr2[j][1] === arr1[i][1]) {
          //console.log('i: ' + i + ' j: ' + j);
          inv.push([arr2[j][0] + arr1[i][0], arr2[j][1]]);
          //console.log('arr2[j][0]:' + arr2[j][0] + ' + ' + 'arr1[j][0]:' + arr1[j][0] + ' = ' + (arr2[j][0] + arr1[j][0]));
          found = true;
          marked[i] = true;
        }
      }
      if(!found) {
        inv.push(arr2[j]);
      }
    }
  console.log(marked);
  inv.push(arr1.filter(function(val, index) {
    /*return marked.every(function(val2) {
      return val2 !== 1;
    });*/
    console.log(marked[index]);
    return marked[index] !== 1; // arunkumrv
  }));


  console.log(inv);
  //return inv;
}

// Example inventory lists
var curInv = [
    [21, "Bowling Ball"],
    [2, "Dirty Sock"],
    [1, "Hair Pin"],
    [5, "Microphone"]
];

var newInv = [
    [2, "Hair Pin"],
    [3, "Half-Eaten Apple"],
    [67, "Bowling Ball"],
    [7, "Toothpaste"]
];

updateInventory(curInv, newInv);
V Arun Kumar
@arunvkumr
Mar 21 2016 09:22
@AchiPapakon filter automatically increments the array taking one ind value at a time.. so automatically the ind value increments and it's compared with the marked array.. post your code without that i might be not able to help you..
Reza Farshbaf
@grfarshbaf
Mar 21 2016 09:23

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

if (contacts[i].firstName == firstName) {
  if (contacts[i].hasOwnProperty(prop)) {
    return contacts[i][prop];
  } else {
    return "No such property";
  }
}

}
return "No such contact";

Olawale Akinseye
@brainyfarm
Mar 21 2016 09:23
Maybe not yet @shaanky
Reza Farshbaf
@grfarshbaf
Mar 21 2016 09:23
I removed that foundContact var.
looks good
V Arun Kumar
@arunvkumr
Mar 21 2016 09:23
@grfarshbaf yup that's the one... :smile:
Reza Farshbaf
@grfarshbaf
Mar 21 2016 09:24
Can I combine those 2 if conditions?
shanky
@shaanky
Mar 21 2016 09:25
may i know why @brainyfarm ???
V Arun Kumar
@arunvkumr
Mar 21 2016 09:25
ya you can combine them with an and operator && if you do that you also have to do that for else..
@grfarshbaf
Mohammedaadem As
@mohamma548
Mar 21 2016 09:25

function update(id, prop, value) {
if(value!=="" && prop!= collection[id].hasOwnProperty(prop)){
collectionid=value;
}
else if(value!==" " && prop==collection[id].hasOwnProperty(prop)){

collection[id][prop].push(value);

}
else if(value!==""){
delete collectionid;
}

return collection;
}
could you please give me some i dea i couldnt push values to tracks

"

V Arun Kumar
@arunvkumr
Mar 21 2016 09:26
@AchiPapakon give me some time.. i'm reading your code.. and please try to write comments in your code.. it will be helpful to read..
shanky
@shaanky
Mar 21 2016 09:26
 var tolow = str.toLowerCase();
  var strreg = tolow.replace(/[^0-9a-z]/gi);
  var revstr = strreg.split(',').reverse().join();
  if(strreg == revstr)
    {
      return true;
    }
  else
    {
      return false;
    }
@brainyfarm this is my code but still some problms in this as i can not pass the test
greg
@wearenotgroot
Mar 21 2016 09:27

@mohamma548
if you re-read the instruction those if statements should be

if(value!=="" && prop!== "tracks")

and

else if(value!=="" && prop === "tracks")
Olawale Akinseye
@brainyfarm
Mar 21 2016 09:27
@shaanky
Are you talking about shaanky/Web_Developer room?
There are multiple errors @shaanky
shanky
@shaanky
Mar 21 2016 09:28
yes @brainyfarm
shaanky/Web_Developer room--- thats me.. @brainyfarm
Mohammedaadem As
@mohamma548
Mar 21 2016 09:28
@wearenotgroot tracks are arrays
vihaan7122014
@vihaan7122014
Mar 21 2016 09:28
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
shanky
@shaanky
Mar 21 2016 09:29
@vihaan7122014 just take all these as string.
vihaan7122014
@vihaan7122014
Mar 21 2016 09:29
kindly hlp me
ok
Olawale Akinseye
@brainyfarm
Mar 21 2016 09:29
First, you should replace like replace(/[^0-9a-z]/gi, ""); and when you split use .split("") then you should join like this .join("") @shaanky .
Emil Aasa
@emilaasa
Mar 21 2016 09:30
@vihaan7122014 var myStr = “\n” etc for all the special characters
greg
@wearenotgroot
Mar 21 2016 09:30
@mohamma548 yes tracks are array
@mohamma548 then push the value, if prop equal "tracks"
Olawale Akinseye
@brainyfarm
Mar 21 2016 09:30
You can read the documentations on those inbuilt functions to know more @shaanky
greg
@wearenotgroot
Mar 21 2016 09:30
@mohamma548 if prop is not equal tracks then set the value
shanky
@shaanky
Mar 21 2016 09:32
@brainyfarm i passed it...
@brainyfarm :+1:
vihaan7122014
@vihaan7122014
Mar 21 2016 09:33
thanks
shanky
@shaanky
Mar 21 2016 09:36
@brainyfarm you checked that room???
vihaan7122014
@vihaan7122014
Mar 21 2016 09:38
myStr=" '\ \' '\ \t' '\ \t' '\ \r' '\ \n' "; kindly tell me the correct code for it
AbdHan
@abdhan
Mar 21 2016 09:39

var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

Hi can someone tell how I would access pine? I tried many combinations but none were right. Also why are keywords $type and $list used as property names?
TIA

Emil Aasa
@emilaasa
Mar 21 2016 09:40
@vihaan7122014 You do not need all those quotes
shanky
@shaanky
Mar 21 2016 09:40
@vihaan7122014 just myStr =myStr=" \ \ \t \t \r \n ";
kirbyedy
@kirbyedy
Mar 21 2016 09:40
@abdhan you have to access the second element in the my plants array, and the second element in the tree object
and keep in mind that arrays are 0 based
so first element is actually 0, second element is 1, and so on...
Blauelf
@Blauelf
Mar 21 2016 09:41
@vihaan7122014 For code here in chat, put that in single backticks for `inline code` => inline code, inside you can easily use backslashes. Or do code blocks like
```js
Javascript code
```
  Javascript code
AbdHan
@abdhan
Mar 21 2016 09:41
okay so myPlants[1].trees.list[1] ? @kirbyedy
shanky
@shaanky
Mar 21 2016 09:41
@abdhan so in myPlants[0] will be the first flowers and myPlants[1] will be tree
very close @abdhan
kirbyedy
@kirbyedy
Mar 21 2016 09:42
@abdhan you are close
shanky
@shaanky
Mar 21 2016 09:42
just remove tree as you give the second index list[1] as it will directly take that data
@abdhan
Lokendra Sharma
@kuroop
Mar 21 2016 09:43
help everything_be_true
CamperBot
@camperbot
Mar 21 2016 09:43
no wiki entry for: everything_be_true
Lokendra Sharma
@kuroop
Mar 21 2016 09:43
help "everything be true"
CamperBot
@camperbot
Mar 21 2016 09:43

:point_right: algorithm everything be true [wiki]

Explanation:

The program needs to check if the second argument is a truthy element, and it must check this for each object in the first argument.

Hint: 1

Remember to iterate through the first argument to check each object.

Hint: 2

Only if all of them are truth will we return true, so make sure all of them check.

Hint: 3

You could use loops or callbacks functions, there are multiple ways to solve this problem.

Spoiler Alert!

687474703a2f2f7777772e796f75726472756d2e636f6d2f796f75726472756d2f696d616765732f323030372f31302f31302f7265645f7761726e696e675f7369676e5f322e676966.gif

Solutions ahead!

:pencil: read more about algorithm everything be true on the FCC Wiki

Blauelf
@Blauelf
Mar 21 2016 09:43
@abdhan myPlants[1] has two properties, type (with a value of "trees"), and list.
V Arun Kumar
@arunvkumr
Mar 21 2016 09:44
@AchiPapakon the marked array has boolean values, you cann't compare them with 0 or 1.. instead of using return marked[index] !== 1;.. use return marked[index] !== true;
surendra
@surendrap720
Mar 21 2016 09:44
<script>
function name(){
var input1=document.getElementById("firstname");
document.write(input1);
}
AbdHan
@abdhan
Mar 21 2016 09:44
Ah cool @shaanky @kirbyedy @Blauelf Thanks. Also is it okay to use property names JS keywords?
CamperBot
@camperbot
Mar 21 2016 09:44
abdhan sends brownie points to @shaanky and @kirbyedy and @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1429 | @blauelf | http://www.freecodecamp.com/blauelf
:star: 149 | @shaanky | http://www.freecodecamp.com/shaanky
surendra
@surendrap720
Mar 21 2016 09:44
<script>
function name(){
var input1=document.getElementById("firstname");
document.write(input1);
}
CamperBot
@camperbot
Mar 21 2016 09:44
:star: 704 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
surendra
@surendrap720
Mar 21 2016 09:45
what is wrong with the code ?
<script>
function name(){
var input1=document.getElementById("firstname");
document.write(input1);
}</script> what's wrong with the code?
shanky
@shaanky
Mar 21 2016 09:46
@brainyfarm r ut there????
 {
  var arry = [];
      arry = str.split(" ");
  for(var i=0; i<= arry.length; i++)
    {
      var newarry = arry.split("");
      return newarry;
    }
can anyone tell me i m stuck with this exaample- "palindrome"
what to do next???
JackeL
@jackel27
Mar 21 2016 09:49
hola
kirbyedy
@kirbyedy
Mar 21 2016 09:50
hohohola
JackeL
@jackel27
Mar 21 2016 09:50
what up @kirbyedy how far are you now?
kirbyedy
@kirbyedy
Mar 21 2016 09:50
trying to tic the tac with a toe
Achilleas Papakonstantinou
@AchiPapakon
Mar 21 2016 09:50
@arunkumrv Thanks, that was it. The problem in my code was elsewhere :/
CamperBot
@camperbot
Mar 21 2016 09:50
achipapakon sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
kirbyedy
@kirbyedy
Mar 21 2016 09:50
stuck :)
CamperBot
@camperbot
Mar 21 2016 09:50
:star: 379 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
JackeL
@jackel27
Mar 21 2016 09:51
@kirbyedy nice. I just finished the recipe thing for React, on game of life now
kirbyedy
@kirbyedy
Mar 21 2016 09:51
holly macaroni :D
JackeL
@jackel27
Mar 21 2016 09:51
@kirbyedy my tic toe ai was easy
kirbyedy
@kirbyedy
Mar 21 2016 09:51
you are fast
JackeL
@jackel27
Mar 21 2016 09:51
lol, just been putting in TONS of hours
kirbyedy
@kirbyedy
Mar 21 2016 09:52
yea
I have to juggle in 8h of work, some family time and coding :D
JackeL
@jackel27
Mar 21 2016 09:52
yeah, I have no juggles at the moment.
kirbyedy
@kirbyedy
Mar 21 2016 09:52
plus some additional life crap
JackeL
@jackel27
Mar 21 2016 09:53
my life crap is not having a job atm. reason why I'm putting in hours here..
degree doesn't guarantee a job unfortunately...
shanky
@shaanky
Mar 21 2016 09:54
hello guys
need help
JackeL
@jackel27
Mar 21 2016 09:54
heres my recipe react with es6 if you wanna check it out.
shanky
@shaanky
Mar 21 2016 09:54
challnge - palindrome
recommend full screen
shanky
@shaanky
Mar 21 2016 09:54
anyone??
JackeL
@jackel27
Mar 21 2016 09:56
@shaanky reviewing your code
@shaanky can you give full code?
kirbyedy
@kirbyedy
Mar 21 2016 09:57
can I change the color somehow ?
shanky
@shaanky
Mar 21 2016 09:57
ok @jackel27
JackeL
@jackel27
Mar 21 2016 09:57
@kirbyedy no options for that
kirbyedy
@kirbyedy
Mar 21 2016 09:57
ok
got confused for the moment, when the recipes were one above each other :D
then I thought... hang on, he wouldnt leave it like that :D
JackeL
@jackel27
Mar 21 2016 09:58
@kirbyedy try putting this into one of your notes, then viewing it....
# Korean Style ShortRibs
<p>The classic flavors of soy sauce and fish sauce provide a satisfying balance to the deep, beefy character of the short ribs in this recipe. Fish sauce, an excellent complement to generously marbled meat, stands in for salt, so you don’t need to salt. If you want to broil the ribs on the baking sheet in which they are drained and allowed to dry, be sure to line the pan with aluminum foil to avoid burnt-on caramelized juices. <p>

### ![alt text](http://rk.wsimgs.com/wsimgs/rk/images/dp/recipe/201536/0072/img57l.jpg "Mmmm Tasty")
#### Ingredients:
### ![alt text](https://upload.wikimedia.org/wikipedia/commons/e/e5/Gospers_glider_gun.gif "Game of Life")



+ 1/2 cup sake or dry white wine 
+ 3/4 cup reduced-sodium soy sauce 
+ 1/4 cup Thai or Vietnamese fish sauce 
+ 1/4 cup honey 
+ 2 Tbs. peanut oil 
+ 1 tsp. Asian sesame oil 
+ 7 large garlic cloves, minced 
+ 1 Tbs. peeled and minced fresh ginger 
+ 5 green onions, white and light green portions, minced  
+ 1 cup water 
+ 5 lb. flanken-cut beef short ribs, cut 1/2 inch thick, patted dry 
+ 3/4 tsp. freshly ground pepper 
+ 1/2 tsp. Chinese five spice

#### Directions:
1. In a large baking dish, combine the sake, soy sauce, fish sauce, honey, peanut oil, sesame oil, garlic, ginger, half of the green onions and the water and mix well. Add the ribs and rub on all sides with the mixture. Let stand at room temperature for 2 hours or preferably overnight in the refrigerator, turning the ribs once or twice. 
2. Remove the ribs from the dish and discard the marinade. Place the ribs on a rack on a baking sheet. Let come to room temperature and air-dry for about 30 minutes. 
3. Preheat a broiler. 
4. Season the ribs all over with the pepper and Chinese five spice. Transfer the rack to a roasting pan. Place under the broiler about 3 inches from the heat source and cook the ribs, turning once, until nicely browned and sizzling on all sides, about 6 minutes per side. 
5. Leave the ribs whole or, if desired, cut them between the bones into smaller pieces. Garnish with the remaining green onions and serve immediately. Serves 6. 

<b>A note from the butcher:</b> Short ribs can be cut between the ribs (English cut) or across the ribs (flanken cut). Each slab of short ribs has a thick end, which has more meat, and a smaller end, which has less meat. Ask for your short ribs to be cut from the thick end and for the excess surface fat to be trimmed.
— Tanya Cauthen, Belmont Butchery, Richmond, VA 

<i>Adapted from Williams-Sonoma The Cook and The Butcher, by Brigit Binns (Weldon Owen, Inc., 2011).</i>
kirbyedy
@kirbyedy
Mar 21 2016 09:58
drag around is a nice idea
JackeL
@jackel27
Mar 21 2016 09:58
@kirbyedy yeah, after you save that note.. refresh page ;)
shanky
@shaanky
Mar 21 2016 09:59
function findLongestWord(str) {
  var arry = [];
      arry = str.split(" ");
     //return arry;
  for(var i=0; i<= arry.length; i++)
    {
      var newarry = str.split(" ");
      return newarry.length;
    } 
}

findLongestWord("The quick brown fox jumped over the lazy dog");
@jackel27 check above
my full code
Alex Praveen
@Alexgeo007
Mar 21 2016 09:59