These are chat archives for FreeCodeCamp/HelpJavaScript

22nd
May 2016
Chris Cullen
@123xylem
May 22 2016 00:01
@GUITARPLRC thanks il look it up// But is having the <A tag really the problem?
CamperBot
@camperbot
May 22 2016 00:01
123xylem sends brownie points to @guitarplrc :sparkles: :thumbsup: :sparkles:
:cookie: 314 | @guitarplrc |http://www.freecodecamp.com/guitarplrc
Charles
@GUITARPLRC
May 22 2016 00:02
@123xylem try and remove button tag and then click lunk
Link
Norvin Burrus
@ndburrus
May 22 2016 00:03
@tadake here is a closer look at the code/ouput... do you see the issue?
function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  console.log("arr: " + arr);


  // Only change code below this line
  for(i = 0; i < collection.length;i++){
      console.log("arr " + i + " " + arr[i]);

    var search = Object.getOwnPropertyNames(source);
    console.log("search: " + search);


    if(collection[i].hasOwnProperty(search)){

      if(collection[i][search] === source[search]){
         arr.push(collection[i]);
         console.log("collection[i]" + collection[i]);
   }
  } 
 }

  // Only change code above this line
  console.log("arr: " + arr);
  return arr;
}

whereAreYou([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "c": 2 });
---------------------------------
arr: 
arr 0 undefined
search: a,c
arr 1 undefined
search: a,c
arr 2 undefined
search: a,c
arr: 
=> []
Charles
@GUITARPLRC
May 22 2016 00:04
@123xylem what happens?
Chris Cullen
@123xylem
May 22 2016 00:05
it only works on rightclick
leftclick refreshes page even though its set to wikipedia.xom
Charles
@GUITARPLRC
May 22 2016 00:05
@123xylem I removed both open and close button tags and link redirects to random wiki page....
Does the
Search link work?
Suprith Aireddy
@sup-rith
May 22 2016 00:12
Anyone here to help me on the seek and destroy challenge?
Diego Mayer
@Chrono79
May 22 2016 00:13
@sup-rith paste your code
Suprith Aireddy
@sup-rith
May 22 2016 00:13
I am having trouble on how I should start @Chrono79
Diego Mayer
@Chrono79
May 22 2016 00:14
wiki seek and destroy
CamperBot
@camperbot
May 22 2016 00:14

:point_right: algorithm seek and destroy [wiki]

Algorithm Seek and Destroy

Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

:pencil: read more about algorithm seek and destroy on the FCC Wiki

Diego Mayer
@Chrono79
May 22 2016 00:14
did you see how to use arguments?
Suprith Aireddy
@sup-rith
May 22 2016 00:15
yes thanks @Chrono79
CamperBot
@camperbot
May 22 2016 00:15
sup-rith sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 786 | @chrono79 |http://www.freecodecamp.com/chrono79
Charles
@GUITARPLRC
May 22 2016 00:19
@123xylem did you get anywhere?
hjernefrys
@hjernefrys
May 22 2016 00:22
I feel like I'm 90% there now, but the script doesn't work if the first two or more letters are consonants, and the variable toSlice never becomes more then 1. Any ideas?

function translatePigLatin(str) {

  var toSlice = 0;
  var vowel = ["a","e","i","o","u"];
  var consonant =["b","c","d","f"
                 ,"g","h","j","k","l","m","n","p",
                  "q","r","s","t","u","v","w","x","y","z"];


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

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

      if(str[0] === vowel[i]){
        var toConcat = "way";
        str = str.concat(toConcat);
        break;
      }
    }

      while(str[x] !== vowel[i]){

      var takenOut = str[toSlice];
      toSlice +=1;
      console.log(toSlice);
      str = str.substr(toSlice);

      str = str.concat(takenOut,'ay');

      console.log(str);

      break;
    }

    break;
  }

  return str;
}

translatePigLatin("consonant");
Kyle W Pilkinton
@tadake
May 22 2016 00:22
@dagman i see that for the last two my array isnt populating but i still am missing why and how i can fix it.
Diego Mayer
@Chrono79
May 22 2016 00:24
@hjernefrys why so many loops?
tommy
@tommygebru
May 22 2016 00:30
can anyone help explain the .key()
Diego Mayer
@Chrono79
May 22 2016 00:30
sorry for the long link :+1:
@Chrono79 yes i couldnt make sense of the examples.....
on mdn
hjernefrys
@hjernefrys
May 22 2016 00:34
@Chrono79 to loop trough all the letters in the string and all the vowels…
Diego Mayer
@Chrono79
May 22 2016 00:35

@hjernefrys

 while(str[x] !== vowel[i]){

      var takenOut = str[toSlice];
      toSlice +=1;
      console.log(toSlice);
      str = str.substr(toSlice);

      str = str.concat(takenOut,'ay');

      console.log(str);

      break;
    }

if you have a break at the botton, it doesn't loop

David Shavers
@frontEndDevv
May 22 2016 00:35
hey guys im working on the basic algorithms and it appears as though the arr.reverse method doesn't work. im trying to reverse an array. can someone help?
tommy
@tommygebru
May 22 2016 00:35
@ndburrus LOL are you working on the third intermediate too?
@frontEndDevv before reversing try to split the string :smile:
Diego Mayer
@Chrono79
May 22 2016 00:36
@tommygebru basically you get the list of properties of source with Object.keys
Suprith Aireddy
@sup-rith
May 22 2016 00:36
wiki Where do I belong
CamperBot
@camperbot
May 22 2016 00:36

:point_right: algorithm where do i belong [wiki]

Algorithm Where do I Belong

Explanation:

This can be a tricky problem to understand. You need to find where in the array a number should be inserted by order, and return the index where it should go.

:pencil: read more about algorithm where do i belong on the FCC Wiki

Diego Mayer
@Chrono79
May 22 2016 00:37
you have to find if all of them are present in collection with hasOwnProperty and if the value of both properties is the same
tommy
@tommygebru
May 22 2016 00:37
@Chrono79 I thought I understood the examples but then I saw this one .... and I was like.... NOPE
// array like object with random key ordering
var an_obj = { 100: 'a', 2: 'b', 7: 'c' };
console.log(Object.keys(an_obj)); // console: ['2', '7', '100']
Erik Moura
@erikian
May 22 2016 00:37

i need to multiply my product variable by each number in the sub-arrays of arr, but i just can't to this. the example code isn't helping. any tips?

<code>

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].length; j++) {
product = arr[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]]);

</code>

Chinchano
@chinchano
May 22 2016 00:37
Hey everybody...working on the looping over array challenge and I think I'm on the right track. The only problem is my loop is only going over the first element in each sub array instead of all of the elements.
Norvin Burrus
@ndburrus
May 22 2016 00:37
@tommygebru no, i'm not there yet... i was attempting to offer useful information on the code...
Chinchano
@chinchano
May 22 2016 00:38

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

for (var i = 0; i < arr.length; i++){
//console.log(arr[i][0]);
var counter = 0;
if(arr[i][0] > counter){
counter = arr[i][0];
console.log(counter);
}
}
return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

tommy
@tommygebru
May 22 2016 00:38
@ndburrus did you understand the suggested method .key()////???
Chinchano
@chinchano
May 22 2016 00:38
anything look off?
Diego Mayer
@Chrono79
May 22 2016 00:39
@tommygebru yes, the order is arbitrary, they're not sorted as in the object
tommy
@tommygebru
May 22 2016 00:39
@chinchano is it logging out [4,5,1,3]?
Norvin Burrus
@ndburrus
May 22 2016 00:39
@tommygebru i haven't looked at it, did you have a question about it?
tommy
@tommygebru
May 22 2016 00:40
@Chrono79 oh wait is it just getting the properties as it iterates????
Moisés Man
@moigithub
May 22 2016 00:40
var myObj = {
   key1: "value1",
  key2: 1234,
  key3: false
}
Object.keys(myObj);  <-- will return ["key1", "key2", "key3"]
@tommygebru
Diego Mayer
@Chrono79
May 22 2016 00:40
@chinchano @tommygebru I think it's logging 4, 13, 32 and 1000
Chinchano
@chinchano
May 22 2016 00:40
It's logging 4, 13, 32, 1000
@Chrono79 exactly
tommy
@tommygebru
May 22 2016 00:40
@Chrono79 me right?
@moigithub @Chrono79 @ndburrus thanks .... I was put off by the trick example... :smile:
CamperBot
@camperbot
May 22 2016 00:41
tommygebru sends brownie points to @moigithub and @chrono79 and @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 390 | @ndburrus |http://www.freecodecamp.com/ndburrus
:cookie: 787 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 1225 | @moigithub |http://www.freecodecamp.com/moigithub
Diego Mayer
@Chrono79
May 22 2016 00:42
@tommygebru you can use 2 for loops, one to go through collection and one to go through the keys of source, yes
Stephen Mansfield
@StephenMansfield
May 22 2016 00:42
Can anyone tell me what is wrong with this? I am on Escaping Literal Qoutes in Strings
var myStr = "I am a \"double qouted\" string inside \"double qoutes\"";
Diego Mayer
@Chrono79
May 22 2016 00:42
@StephenMansfield mispelled quoted and quotes
tommy
@tommygebru
May 22 2016 00:42
ok i just wanted to know how to use my methods :+1: sometimes that is half the battle if you know what i mean :smile:
rphares
@rphares
May 22 2016 00:43
and quoted @StephenMansfield
tommy
@tommygebru
May 22 2016 00:43
@StephenMansfield have to be careful here spelling, spaces and quotation
Stephen Mansfield
@StephenMansfield
May 22 2016 00:43
o jesus
Diego Mayer
@Chrono79
May 22 2016 00:43
@chinchano if you're taking that path, use 2 for loops and reset count with every inner array
Stephen Mansfield
@StephenMansfield
May 22 2016 00:43
:worried: Maybe I should be in english class
thanks @rphares @tommygebru @Chrono79
CamperBot
@camperbot
May 22 2016 00:44
:cookie: 788 | @chrono79 |http://www.freecodecamp.com/chrono79
stephenmansfield sends brownie points to @rphares and @tommygebru and @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 722 | @tommygebru |http://www.freecodecamp.com/tommygebru
:star2: 4758 | @rphares |http://www.freecodecamp.com/rphares
Chris Cullen
@123xylem
May 22 2016 00:44
@GUITARPLRC sory just ate
Gee Eem
@Gaary-A-M
May 22 2016 00:44
Help! Been stuck on "Make Object Properties Private" for ~ 2 hours, and laptop is about to meet its end. I can only get "myBike.gear should remain undefined." to "check" ..
CamperBot
@camperbot
May 22 2016 00:44
no wiki entry for: been stuck on make object properties private for 2 hours and laptop is about to meet its end i can only get mybikegear should remain undefined to check
Chris Cullen
@123xylem
May 22 2016 00:44
If i remove button tags it no longer is a button
rphares
@rphares
May 22 2016 00:44
anytime~ And dont worry about it-- happens to all of us :blush:
Gee Eem
@Gaary-A-M
May 22 2016 00:44

code : var gear;
this.getGear = function(){
return gear;
};
this.setGear = function(set){
gear = set;

};

var myCar = new Car();

var myBike = new Bike();

Diego Mayer
@Chrono79
May 22 2016 00:44
@Gaary-A-M paste your code
ok
Gee Eem
@Gaary-A-M
May 22 2016 00:45

my code......var gear;
this.getGear = function(){
return gear;
};
this.setGear = function(set){
gear = set;

};

var myCar = new Car();

var myBike = new Bike();

Chris Cullen
@123xylem
May 22 2016 00:45
@GUITARPLRC BUt removing button tags doeswork!.. Why Is that/?!!?
tommy
@tommygebru
May 22 2016 00:45
LOL I have learned from starting the intermediates that i have to read carefully....
so im writing notes on each challenge so I can have a better feel for the challenges!!
Gee Eem
@Gaary-A-M
May 22 2016 00:46

@Chrono79 var gear;
this.getGear = function(){
return gear;
};
this.setGear = function(set){
gear = set;

};

var myCar = new Car();

var myBike = new Bike();

tommy
@tommygebru
May 22 2016 00:46
@Gaary-A-M oh this one is tricky!
Diego Mayer
@Chrono79
May 22 2016 00:46
@Gaary-A-M I think you're missing the Bike object creator function
var Bike = function() {
   var gear;
  this.getGear = function(){
    return gear;
  };
  this.setGear = function(set){
    gear = set;
  };
};
Gee Eem
@Gaary-A-M
May 22 2016 00:46
i HATE it .. lol
I only included my code below // Only change.....
tommy
@tommygebru
May 22 2016 00:49
ok @Gaary-A-M
Norvin Burrus
@ndburrus
May 22 2016 00:49
@erikian is this helpful?
code:
function multiplyAll(arr) {
  var product = 1;

// Only change code below this line
for (var i=0; i < arr.length; i++) {
  console.log("var i: " + i);

    for (var j=0; j < arr[i].length; j++) {
      console.log("var j: " + j);
      console.log("arr" + i + j + ": " + arr[i][j]);
      console.log("product: " + product);
      product = arr[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]]);
--------------------------------
output:
var i: 0
var j: 0
arr00: 1
product: 1
var j: 1
arr01: 2
product: 1
var i: 1
var j: 0
arr10: 3
product: 2
var j: 1
arr11: 4
product: 3
var i: 2
var j: 0
arr20: 5
product: 4
var j: 1
arr21: 6
product: 5
var j: 2
arr22: 7
product: 6
=> 7
tommy
@tommygebru
May 22 2016 00:49
@Gaary-A-M did you remember to declare gear
Diego Mayer
@Chrono79
May 22 2016 00:50
@Gaary-A-M you're missing a }; in what you pasted
David Shavers
@frontEndDevv
May 22 2016 00:51

having trouble with the palindrome section still. could someone point out to me the problem of my code? code:
function palindrome(str) {
var a = str.toLowerCase().replace(/\W/g, '');
var narry = a.split('').reverse().join().replace(/\W/g, '');

if (a == narry) {
return true;

} else {
return false;

}
}

Gee Eem
@Gaary-A-M
May 22 2016 00:51
@Chrono79 funny .. no errors reported
Diego Mayer
@Chrono79
May 22 2016 00:51
@Gaary-A-M does it work now?
Gee Eem
@Gaary-A-M
May 22 2016 00:52
sigh ... no
Diego Mayer
@Chrono79
May 22 2016 00:52
@frontEndDevv why 2 replaces?
and \W alone won't do all the work, you have to get rid of the underscore too
Norvin Burrus
@ndburrus
May 22 2016 00:52
@Gaary-A-M ReferenceError: Car is not defined. also the function gear is not defined (or named).
Gee Eem
@Gaary-A-M
May 22 2016 00:53
@Chrono79 there is another }; under var Bike
Diego Mayer
@Chrono79
May 22 2016 00:54
@Gaary-A-M try this:
var Bike = function() {
   var gear;
  this.getGear = function(){
    return gear;
  };
  this.setGear = function(set){
    gear = set;
  };
};
David Shavers
@frontEndDevv
May 22 2016 00:54
@Chrono79 because I had a feeling that I should do that to each step. and ok ill give that a shot
Diego Mayer
@Chrono79
May 22 2016 00:55
@frontEndDevv also join() should be join('')
Gee Eem
@Gaary-A-M
May 22 2016 00:55
@Chrono79 dammit ... syntax issue .. THANK YOU!
CamperBot
@camperbot
May 22 2016 00:55
gaary-a-m sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 789 | @chrono79 |http://www.freecodecamp.com/chrono79
tommy
@tommygebru
May 22 2016 00:56
kinda frustrating the error wouldnt show up for me either?? :wink2:
Gee Eem
@Gaary-A-M
May 22 2016 00:57
@tommygebru lol .. Thank you to you as well
CamperBot
@camperbot
May 22 2016 00:57
:cookie: 723 | @tommygebru |http://www.freecodecamp.com/tommygebru
gaary-a-m sends brownie points to @tommygebru :sparkles: :thumbsup: :sparkles:
tommy
@tommygebru
May 22 2016 00:57
@Gaary-A-M glad to help!
Erik Moura
@erikian
May 22 2016 00:58
@ndburrus it didn't work, and i don't understand what this code is doing. why do i need to use console.log() ?
tommy
@tommygebru
May 22 2016 00:58
@frontEndDevv your join value has to match the split .....
David Shavers
@frontEndDevv
May 22 2016 00:58
@Chrono79 roger, that damn syntax is a killer
tommy
@tommygebru
May 22 2016 00:59

@frontEndDevv also this isnt necessary...

if (a == narry) {
return true;
} else {
return false;
}

hjernefrys
@hjernefrys
May 22 2016 00:59
this is looping forever: I can't figure out why:

function translatePigLatin(str) {

  var toSlice = 0;
  var vowel = ["a","e","i","o","u"];
  var consonant =["b","c","d","f"
                 ,"g","h","j","k","l","m","n","p",
                  "q","r","s","t","u","v","w","x","y","z"];


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

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

      if(str[0] === vowel[i]){
        var toConcat = "way";
        str = str.concat(toConcat);
        break;
      }
    }



      while(str[x] !== vowel[i]){

      var takenOut = str[toSlice];
      toSlice +=1;
      str = str.substr(toSlice);
      str = str.concat(takenOut,'ay');

      console.log(str);
      //break;

      }
    break;
    }



  return str;
}

translatePigLatin("consonant");
David Shavers
@frontEndDevv
May 22 2016 00:59
@tommygebru are you saying it should be a.join('') instead of a.join()
tommy
@tommygebru
May 22 2016 00:59
because if you make a statement
a===b; it forces the output to be boolean, either true or false :smile:
Diego Mayer
@Chrono79
May 22 2016 01:00
@hjernefrys this condition: while(str[x] !== vowel[i]){
if you're not changing x nor i inside the loop, it'll loop forever
try with an if there, or think of doing it in another way
tommy
@tommygebru
May 22 2016 01:00
yes that too
stevie
@pmwong007
May 22 2016 01:00

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val) {
case (val === 1):
answer += "alpha";
break;
case (val === 2):
answer += "beta";
break;
case (val === 3):
answer += "gamma";
break;
case (val === 4):
answer += "delta";
break;
}

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

// Change this value to test
caseInSwitch(1);

help! what's wrong with this switch statement?
CamperBot
@camperbot
May 22 2016 01:01
no wiki entry for: whats wrong with this switch statement
Diego Mayer
@Chrono79
May 22 2016 01:01
@pmwong007 case (val === 1): this is wrong
it should be case 1: and so on with the rest of the cases
stevie
@pmwong007
May 22 2016 01:02
why isn't it returning the answers?
Norvin Burrus
@ndburrus
May 22 2016 01:02
@erikian sometimes it is helpful to see what the code is doing... :)
stevie
@pmwong007
May 22 2016 01:03
Thaaaaanks!!!! Diego!
Diego Mayer
@Chrono79
May 22 2016 01:03
@pmwong007 no problem :+1:
Josh Lavely
@Azayzel
May 22 2016 01:03
how do i attach a screenshot of my code in this chat (on a mac, already have the screen capture)
? i need some help with 'Record Collection' :-(
tommy
@tommygebru
May 22 2016 01:03

@pmwong007 (val === 1) should be 1

what Diego said :smile:

stevie
@pmwong007
May 22 2016 01:03
case values are tested with strict equality (===)
rphares
@rphares
May 22 2016 01:03
explain format
CamperBot
@camperbot
May 22 2016 01:03

: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 thecode`.

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

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

stevie
@pmwong007
May 22 2016 01:04
so what does the above mean?
rphares
@rphares
May 22 2016 01:04
@Azayzel :point_up: :point_up: how to paste code
Diego Mayer
@Chrono79
May 22 2016 01:04
you better paste the code @Azayzel
Erik Moura
@erikian
May 22 2016 01:04
@ndburrus there was no console output
Norvin Burrus
@ndburrus
May 22 2016 01:04
@erikian i posted the code output above...
hjernefrys
@hjernefrys
May 22 2016 01:04
@Chrono79 yes I can change it to a if loop, but the problem is with glove I can't figure out how to make it go through the loop once more to cut two letters from the start
Norvin Burrus
@ndburrus
May 22 2016 01:05
@pmwong007 which challenge is this?
David Shavers
@frontEndDevv
May 22 2016 01:05
Passed! thanks @Chrono79 @tommygebru
CamperBot
@camperbot
May 22 2016 01:05
frontenddevv sends brownie points to @chrono79 and @tommygebru :sparkles: :thumbsup: :sparkles:
:cookie: 790 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
May 22 2016 01:05
@hjernefrys I can give you a line of code as a hint if you want
CamperBot
@camperbot
May 22 2016 01:05
:cookie: 724 | @tommygebru |http://www.freecodecamp.com/tommygebru
Josh Lavely
@Azayzel
May 22 2016 01:06
@pmwong007 delete your (val === _) and just do case 1:......case 2:.... the switch is evaluating if val is equal to you case statements
hjernefrys
@hjernefrys
May 22 2016 01:06
@Chrono79 yes please :-)
Josh Lavely
@Azayzel
May 22 2016 01:06
how you're doing it now, its like, double switch but with another boolean, just won't work
Diego Mayer
@Chrono79
May 22 2016 01:06
@hjernefrys if ('aeiou'.match(str[i]) === null) {
stevie
@pmwong007
May 22 2016 01:06

@Chrono79 so what does this mean: case values are tested with strict equality (===) @ndburrus

multiple options from Switch statement
@Azayzel Thaaanks!

Josh Lavely
@Azayzel
May 22 2016 01:07

so try ....

switch(val){
case 1:
do something;
break;
case 2:
do something;
break;
}

hjernefrys
@hjernefrys
May 22 2016 01:07
@Chrono79 thanks!
CamperBot
@camperbot
May 22 2016 01:07
hjernefrys sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 791 | @chrono79 |http://www.freecodecamp.com/chrono79
stevie
@pmwong007
May 22 2016 01:07
@Azayzel thaaanks!
Norvin Burrus
@ndburrus
May 22 2016 01:07
@pmwong007 the === operator evaluates both value and data type... the == operator only evaluates value...
Diego Mayer
@Chrono79
May 22 2016 01:07
@pmwong007 that for example, if your var value is "1" it won't match 1
stevie
@pmwong007
May 22 2016 01:08
@ndburrus So it operates at the background, but not in my lines of code??
Erik Moura
@erikian
May 22 2016 01:08
@ndburrus i just used the upper part of the code :smile: i'm trying to solve this challenge for about two hours now, and i'm really stuck. could anyone help me? here's the link for the challenge https://www.freecodecamp.com/challenges/nesting-for-loops
Diego Mayer
@Chrono79
May 22 2016 01:10
@pmwong007
var a = 1;
var b = "1";
if (a == b) console.log("same");
if (a !== b) console.log("not the same");
stevie
@pmwong007
May 22 2016 01:10
@Chrono79 So it runs at the background, and i don't need to code the ===?
Diego Mayer
@Chrono79
May 22 2016 01:10
@erikian paste what you have done so far
tommy
@tommygebru
May 22 2016 01:11
@erikian share your code :smile:
@Chrono79 you are too fast for me :+1:
Diego Mayer
@Chrono79
May 22 2016 01:11
@pmwong007 exactly, but you have to remember it works that way
stevie
@pmwong007
May 22 2016 01:11
@Chrono79 Thanks!!!
Norvin Burrus
@ndburrus
May 22 2016 01:11
@erikian the key to resolving the code issue involves "multiplies the product variable by each number in the sub-arrays of arr"... :) can you see what you're missing? hint: carefully examine this pice of code.... "product = arr[i][j];"
CamperBot
@camperbot
May 22 2016 01:11
pmwong007 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 792 | @chrono79 |http://www.freecodecamp.com/chrono79
Erik Moura
@erikian
May 22 2016 01:12
@ndburrus i can't figure out how to take each number off the array
Diego Mayer
@Chrono79
May 22 2016 01:13
@erikian arr is your array of arrays
so you refer to your sub-arrays as arr[i] for example
To get an element of the sub-array you need another index, let's say j
so, each element of a sub-array is referred as arr[i][j]
Chris Cullen
@123xylem
May 22 2016 01:13
Does anyone know why if i remove bbutton tag off my Random button it works but with tags it wont open new page? http://codepen.io/123xylem/pen/aNxREJ
Josh Lavely
@Azayzel
May 22 2016 01:13

// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

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

Norvin Burrus
@ndburrus
May 22 2016 01:13
@erikian you've already generated all of the iterated array (and inner array) numbers needed (here: product = arr[i][j];). now, you just need to use each of those numbers in calculating the result (product)....
Josh Lavely
@Azayzel
May 22 2016 01:14
can't quite figure out the correct call :-(
Stephen James
@sjames1958gm
May 22 2016 01:14
@Azayzel unshift works for arrays the properties (other than tracks) are not arrays. just assign value to the property
Norvin Burrus
@ndburrus
May 22 2016 01:15
@Azayzel which challenge is this?
Stephen James
@sjames1958gm
May 22 2016 01:15
@Azayzel Also id is a variable just like prop and requires the same syntax.
Diego Mayer
@Chrono79
May 22 2016 01:15
This message was deleted
@Azayzel show us your code so we can help you better
DwayneCode
@DwayneCode
May 22 2016 01:16
is there something wrong with challenge: Iterate over Arrays with map?
Diego Mayer
@Chrono79
May 22 2016 01:16
@DwayneCode don't think so, why?
Stephen James
@sjames1958gm
May 22 2016 01:17
@DwayneCode Probably not, try refreshing the browser if you think the answer is correct.
DwayneCode
@DwayneCode
May 22 2016 01:17
It should be doing something similar to the 3rd example here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
Diego Mayer
@Chrono79
May 22 2016 01:18
paste your code here
Firas El-Hamed
@Felhamed
May 22 2016 01:18

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

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

return collection;
}

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

DwayneCode
@DwayneCode
May 22 2016 01:18

``` var oldArray = [1,2,3,4,5];

// Only change code below this line.

timesThree = oldArray.map(function(num){

return num + 3;

});

var newArray = oldArra
```

Stephen James
@sjames1958gm
May 22 2016 01:18
@DwayneCode yes that seems correct.
tommy
@tommygebru
May 22 2016 01:19
@Azayzel To access the value of a key in this object, you will use collection[id][prop]
DwayneCode
@DwayneCode
May 22 2016 01:19
sorry, i forgot how to format my code :(
Stephen James
@sjames1958gm
May 22 2016 01:19
@Felhamed id is a variable just like prop and requires the same syntax
Michael Njagi
@mnjagi
May 22 2016 01:19
someone help!
bitgrower
@bitgrower
May 22 2016 01:19
if it's times 3, shouldn't it be multiplying by 3, not adding ? :)
Diego Mayer
@Chrono79
May 22 2016 01:19
@DwayneCode var newArray = oldArra should be oldArray;?
Michael Njagi
@mnjagi
May 22 2016 01:19

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber=16; // Change this Line
var player =testObj[16]; // Change this Line

Stephen James
@sjames1958gm
May 22 2016 01:19
@DwayneCode three backticks shift-enter paste three backtick
Norvin Burrus
@ndburrus
May 22 2016 01:20
@Azayzel since the id value changes (ie is being used as a variable), it needs to use/have bracket (as opposed to dot) notation... :)
DwayneCode
@DwayneCode
May 22 2016 01:20
@bitgrower it says to add 3
Diego Mayer
@Chrono79
May 22 2016 01:20
@bitgrower that too ;)
Stephen James
@sjames1958gm
May 22 2016 01:20
@mnjagi You should be using the variable to look up
Michael Njagi
@mnjagi
May 22 2016 01:20
playerNumber should be a number
The variable player should be a string
The value of player should be "Montana"
You should use bracket notation to access testObj
bitgrower
@bitgrower
May 22 2016 01:20
@DwayneCode -- okay ... was just wondering ... weird ...
DwayneCode
@DwayneCode
May 22 2016 01:20
the problem is that the array is not changing the value, whether i add or multiply
tommy
@tommygebru
May 22 2016 01:20
@Azayzel becuase in this manner ... it is accessing the large object with the parameters of the function update
Norvin Burrus
@ndburrus
May 22 2016 01:20
@mnjagi which challenge is this?
Stephen James
@sjames1958gm
May 22 2016 01:20
@DwayneCode The array doesn't change value it returns a new array
Michael Njagi
@mnjagi
May 22 2016 01:21
@sjames1958gm please explain how
Firas El-Hamed
@Felhamed
May 22 2016 01:21
@sjames1958gm I'm not sure I follow
Erik Moura
@erikian
May 22 2016 01:21

@Chrono79 @ndburrus thank you!! it worked, but i still don't understand why

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].length; j++) {
product *= arr[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]]);

CamperBot
@camperbot
May 22 2016 01:21
erikian sends brownie points to @chrono79 and @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 391 | @ndburrus |http://www.freecodecamp.com/ndburrus
:cookie: 793 | @chrono79 |http://www.freecodecamp.com/chrono79
Stephen James
@sjames1958gm
May 22 2016 01:21
@Felhamed With prop you are using brackets [] because it is a variable, so is id.
tommy
@tommygebru
May 22 2016 01:21
@mnjagi second to last line is perfect :+1:
but the last line needs to have a different way, to access the testObj :smile:
Michael Njagi
@mnjagi
May 22 2016 01:21
@ndburrus accessing objects properties with variables.
Stephen James
@sjames1958gm
May 22 2016 01:22
@mnjagi Replace the 16 in the last line with the variable you just assigned 16 to
tommy
@tommygebru
May 22 2016 01:22
@erikian which part is still confusing?
Norvin Burrus
@ndburrus
May 22 2016 01:22
@erikian ok, you are using each of the array values in the loop to multiply product by.... this meets the requirements.... make sense?
Firas El-Hamed
@Felhamed
May 22 2016 01:22
@sjames1958gm So something like this collection[id[prop]] = value;
Stephen James
@sjames1958gm
May 22 2016 01:23
@Felhamed no, just id
Diego Mayer
@Chrono79
May 22 2016 01:23
@DwayneCode instead of timesThree, write var newArray there
Stephen James
@sjames1958gm
May 22 2016 01:24
@DwayneCode Carefully read the last paragraph of the instructions
Norvin Burrus
@ndburrus
May 22 2016 01:24
@mnjagi ok, we need to use the variable playerNumber (within the testObj object) to identify the object property that we want the value for.... make sense? right now, it is hard coded to be 16. what if we (or a user)wanted a different player number? by using a variable, the code can accept a variable to identify a property, and thus retrieve the correct value.... :)
DwayneCode
@DwayneCode
May 22 2016 01:25
@Chrono79 thanks
CamperBot
@camperbot
May 22 2016 01:25
dwaynecode sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 794 | @chrono79 |http://www.freecodecamp.com/chrono79
bitgrower
@bitgrower
May 22 2016 01:25

@erikian - assume the array is an address, and the subarray are the apartment numbers of the address ... you still have to provide a "context" ... for the apartment building, you have a number on a street ... assume the name of your array is the street, the top array is the address of the apartment building and the numbers in the subarray are apartment numbers ....
in order to get the money from each renter, you have to go to each aapartment number, at each address on the street ... that's how to think of the addressing part of the problem (where most people seem to have the most trouble...) ...

Does that help -- or am I'm completely missing what you are having trouble with ?

now -- the cool thing is that, your street addresses are the same as the indexes of the array -- 0, 1, 2, 3 etc ...
Norvin Burrus
@ndburrus
May 22 2016 01:27
@Azayzel how are we doing? do you see what needs attention?
Firas El-Hamed
@Felhamed
May 22 2016 01:27
@sjames1958gm Thanks, I understood it now. You use . when giving the actual variable data and [] when using the variable name itself
CamperBot
@camperbot
May 22 2016 01:27
felhamed sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1205 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Erik Moura
@erikian
May 22 2016 01:27
@tommygebru @bitgrower as far as i'm concerned, arr[i][j] is the j-th element from the i-th subarray. in this case, the 3rd element from the 3rd subarray (7). i had previosly set product = 1. when i use the = operator, i'm doing: 1 7.
Norvin Burrus
@ndburrus
May 22 2016 01:28
@Gaary-A-M where you able to resolve the issue?
bitgrower
@bitgrower
May 22 2016 01:28
yes, if you are multiplying you should definitely start the product at 1 ... although I don't understand the rest of your comment (maybe because I didn't see what you were trying before the solution was posted.)
Stephen James
@sjames1958gm
May 22 2016 01:28
@Felhamed The terminology is a bit off, but yes. You use . when using the actual property name, but [] when the property name is in a variable
Erik Moura
@erikian
May 22 2016 01:29
i mean, the "*= operator, so i'm multiplying 1 by 7"
bitgrower
@bitgrower
May 22 2016 01:29
I really disliked the parameter names in record collection ... makes it hard to discuss ...
Michael Njagi
@mnjagi
May 22 2016 01:29
ok, we need to use theVARIABLE playerNumber (within the testObj object) to identify the object PROPERTY that we want the value for.... make sense? right now, it is hard coded to be 16. what if we (or a user)wanted a different player number? by using a VARIABLE, the code can accept a VARIABLE to identify a PROPERTY, and thus retrieve the correctVALUE....
tommy
@tommygebru
May 22 2016 01:29
@erikian i understand :+1:
Michael Njagi
@mnjagi
May 22 2016 01:30
am still lost.
Diego Mayer
@Chrono79
May 22 2016 01:30
@erikian yes, when you use *= product *= 7; is the same as product = product * 7;
Norvin Burrus
@ndburrus
May 22 2016 01:30
@erikian these were each of the arr[i][j] values posted earlier:
var i: 0
var j: 0
arr00: 1
product: 1
var j: 1
arr01: 2
product: 1
var i: 1
var j: 0
arr10: 3
product: 2
var j: 1
arr11: 4
product: 3
var i: 2
var j: 0
arr20: 5
product: 4
var j: 1
arr21: 6
product: 5
var j: 2
arr22: 7
product: 6
=> 7
bitgrower
@bitgrower
May 22 2016 01:30
yes product = val; is the same as `product val`
argh ...
product times val
tommy
@tommygebru
May 22 2016 01:30
@bitgrower not just that the instructions dont actually reference the parameters enough.... is kind of misleading//
Michael Njagi
@mnjagi
May 22 2016 01:31
@ndburrus still lost

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber=16; // Change this Line
var player ="Montana"; // Change this Line

Erik Moura
@erikian
May 22 2016 01:32
@Chrono79 so why the result is 5040? ("1234567")
Stephen James
@sjames1958gm
May 22 2016 01:32
@mnjagi playerNumber is a variable that could be any playerNumber, in this case you set it to 16. By using the variable in the lookup rather than 16 you can make your code more flexible. This will make more sense later when using functions. The idea is that rather than object[16] you can use object[playerNumber] and if you set playerNumber to a different number it will lookup a different player
Michael Njagi
@mnjagi
May 22 2016 01:32
is this how its supposed to be??
Stephen James
@sjames1958gm
May 22 2016 01:32
@mnjagi no
Diego Mayer
@Chrono79
May 22 2016 01:32
@erikian you're in a loop, and it's multiplying again and again
1st time: product = 1 * 1;
2nd time: product = 1 * 2; // product is 2 now
3rd time: product = 2 * 3; // product is 6 now
...
7th time: product = 720 * 7; // product is finally 5040
bitgrower
@bitgrower
May 22 2016 01:32
I actually don't recall that the instructions were terrible ... it's just in trying to explain it to others, that's where I've found it difficult to just talk about ... :) However, if you are having problems with a particular challenge I HIGHLY recommend preceding related challenges ... like reviewing the various object challenges if you get stuck with record collection, profile lookup and the like ...
Norvin Burrus
@ndburrus
May 22 2016 01:33
@mnjagi ok moment...
Stephen James
@sjames1958gm
May 22 2016 01:34
@mnjagi You still need testObj - you are doing the lookup. But instead of 16 you use the variable in the previous line.
Miguel Benevento
@KSMOknot
May 22 2016 01:34
hey guys, need minor help here.
'''
CamperBot
@camperbot
May 22 2016 01:34
:bulb: to format code use backticks! ``` more info
Miguel Benevento
@KSMOknot
May 22 2016 01:35
js

function switchOfStuff(val) {
  var answer = "";
  // Only change code below this line
  switch(val){
    case 1:
      answer = "apple";
      break;
     case 2:
      answer  = "bird";
      break;
     case 3:
      answer  = "cat";
      break;
    default:
      answer = "stuff";
      break;
  }


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

// Change this value to test
switchOfStuff(1);
what am i doing wrong?
Instructions
Write a switch statement to set answer for the following conditions:
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"
Norvin Burrus
@ndburrus
May 22 2016 01:35
@mnjagi ok... examine the code. think about how the code could accomodate using a different input other than 16. how could that happen...?
code:
// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};
// Only change code below this line;

var playerNumber=16; // Change this Line

var player =testObj[16]; // Change this Line

console.log("player: " + player);
-------------------------------------
output:
player: Montana
Stephen James
@sjames1958gm
May 22 2016 01:36
@KSMOknot Your cases are comparing to 1, 2,3 not "a" "b" "c"
bitgrower
@bitgrower
May 22 2016 01:36
@mnjagi --
basic objects:
  1. objects are made up of property:value (or Key:value) pairs...
  2. to access the VALUE of a property, you "index" into the object using the property
  3. there are 2 ways of indexing into the object -- the first is by using brackets ... which is what you MUST use if you are using a variable containing the property name
  4. the second way is to use the dot notation ... you can only use this under select conditions, foremost of which is that the property name must be the actual property name in the object ... the property name cannot be in a variable ...
Michael Njagi
@mnjagi
May 22 2016 01:36
@sjames1958gm thanks.it worked but to be honest,makes no sense at all.
CamperBot
@camperbot
May 22 2016 01:36
mnjagi sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1206 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 22 2016 01:37
@mnjagi Here is a reference - I would not move on until you understand
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors
Miguel Benevento
@KSMOknot
May 22 2016 01:38
@sjames1958gm but if I put put case a: it prompts not defined
Stephen James
@sjames1958gm
May 22 2016 01:38
@KSMOknot a or "a"
Norvin Burrus
@ndburrus
May 22 2016 01:38
@KSMOknot carefully review the stated requirement/s criteria: hint: follow the format exactly...
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"
Miguel Benevento
@KSMOknot
May 22 2016 01:39
@sjames1958gm yeap just got it. feel dumb lol thanks guys
CamperBot
@camperbot
May 22 2016 01:39
ksmoknot sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1207 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Diego Mayer
@Chrono79
May 22 2016 01:39
@KSMOknot a without the quotes is a var named a, that's why it's undefined
Stephen James
@sjames1958gm
May 22 2016 01:39
@KSMOknot :+1:
Islam Ibakaev
@dagman
May 22 2016 01:39
how it looks now guys? http://codepen.io/dagman/full/wGZLWv/
Norvin Burrus
@ndburrus
May 22 2016 01:40
@mnjagi how are we doing? does it make sense that by using a variable there is more flexibility in identify any of the multiple properties (and corresponding values) in the key/value pair table?
bitgrower
@bitgrower
May 22 2016 01:43
@dagman only your 'about me' link seems to be working ... and then it takes me to a place where I no longer can see the site navigation ... you want to make your site a bit clearer, and direct people's attenntion to where you want them to go ... prime real estate on your website is where heatmaps show that people look first -- which is center (from left to right) and about 1/3rd of the way down the browser window
tommy
@tommygebru
May 22 2016 01:43
@dagman change the cursor back for this codepen
Erik Moura
@erikian
May 22 2016 01:43
@Chrono79 is there a way to make this multiplication withou using a loop?
bitgrower
@bitgrower
May 22 2016 01:44
if you take people to another place on your website, it might also help if you give them a link to get back to the top of your website ... (there is also a way in bootstrap to keep your menu as the top most item visible on the page no matter how far they scroll down -- which is another possible design choice.)
Diego Mayer
@Chrono79
May 22 2016 01:44
@erikian not without some kind of loop
Kevin Min
@placidmoon1
May 22 2016 01:44

Please help me! '''js

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas",
};

// Only change code below this line;

var playerNumber = testObj["Montana"]; // Change this Line
var player = testObj[16]; // Change this Line

'''

CamperBot
@camperbot
May 22 2016 01:44
:bulb: to format code use backticks! ``` more info
Islam Ibakaev
@dagman
May 22 2016 01:44
@bitgrower @tommygebru it's in progress guys and all stuff will be added in future :smile: but thx for feedback
CamperBot
@camperbot
May 22 2016 01:44
dagman sends brownie points to @bitgrower and @tommygebru :sparkles: :thumbsup: :sparkles:
:cookie: 725 | @tommygebru |http://www.freecodecamp.com/tommygebru
:star2: 1060 | @bitgrower |http://www.freecodecamp.com/bitgrower
Islam Ibakaev
@dagman
May 22 2016 01:45
@tommygebru cursor: pointer ?
tommy
@tommygebru
May 22 2016 01:46
@placidmoon1 they ask you to change this line because...
usually its wrong or incomplete
BUT in this case they just want a different way....... to access the object using a different property :smile:
bitgrower
@bitgrower
May 22 2016 01:46

@erikian why would you want to do it without a loop ?

Looping is one of the great powers in programs ... the ability to iterate over sets of things ... used in practically everything ... there's not much useful that you can do if you take out the power of loops !

Diego Mayer
@Chrono79
May 22 2016 01:47
@erikian also, remember that the challenge name is Nesting For Loops
tommy
@tommygebru
May 22 2016 01:47
@dagman yeah i really like the cursor change on the other codepen you showed yesterday!!
Kevin Min
@placidmoon1
May 22 2016 01:47
Ohhhh. Now I get it. Thanks @tommygebru
CamperBot
@camperbot
May 22 2016 01:47
placidmoon1 sends brownie points to @tommygebru :sparkles: :thumbsup: :sparkles:
:cookie: 726 | @tommygebru |http://www.freecodecamp.com/tommygebru
Norvin Burrus
@ndburrus
May 22 2016 01:47
@placidmoon1 ok, think about how the code would handle a different player request - ie could we use 12 or 19?
code:
// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};
// Only change code below this line;

var playerNumber=16; // Change this Line

var player =testObj[16]; // Change this Line

console.log("player: " + player);
------------------------------
output:
player: Montana
Kevin Min
@placidmoon1
May 22 2016 01:49
Got it! Thank you @ndburrus
CamperBot
@camperbot
May 22 2016 01:49
placidmoon1 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 392 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
May 22 2016 01:49
@placidmoon1 great!! super work... :sparkles:
Joshua Swift
@joshuaswift
May 22 2016 01:51
Hey guys, I'm struggling with Caesars Cipher, https://www.freecodecamp.com/challenges/caesars-cipher
tommy
@tommygebru
May 22 2016 01:52
@Joshuaswift @sup-rith is also working on this :+1:
Jason Shoemaker
@kutsuya1
May 22 2016 01:52
@Joshuaswift which part?
tommy
@tommygebru
May 22 2016 01:53
idk
how are you doing?
Joshua Swift
@joshuaswift
May 22 2016 01:53
@kutsuya1 Well I'm trying to figure out how to translate the unicode values to the new characters
Jason Shoemaker
@kutsuya1
May 22 2016 01:53
@tommygebru Not bad..just codeing. You?
Joshua Swift
@joshuaswift
May 22 2016 01:54
@kutsuya1 e.g. S>F is -13 difference in unicode
@kutsuya1 However E>R is +13, how can I account for this when translating the whole sentence?
Norvin Burrus
@ndburrus
May 22 2016 01:54
@mnjagi did you resolve the issue?
Erik Moura
@erikian
May 22 2016 01:54
@bitgrower @Chrono79 i have a serious problem: i can't use a piece of knowledge without understanding every detail about how it works. i know this particular piece of code works for this particular situation, but i still don't understand the reason, and thereby i won't remember it when i face a similar problem. i understand the power of loops, i just wanted to try to to this challenge without loops to understand how and why the loop solution works
Jason Shoemaker
@kutsuya1
May 22 2016 01:56
@Joshuaswift I handled this part first: All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.
Joshua Swift
@joshuaswift
May 22 2016 01:56
@kutsuya1 I know the reason for the difference is dependent on where the character falls in the alphabet, but I don't know how to translate that into code!
Jason Shoemaker
@kutsuya1
May 22 2016 01:57
@Joshuaswift
if (str[i] < 'A' || str[i] > 'Z') {
      decoded += str[i];
      continue;
    }
Diego Mayer
@Chrono79
May 22 2016 01:57
I don't think you can do it without some kind of loop, as I said. You have to go through each element of an array, it has loop written all over it ;) @erikian
Jason Shoemaker
@kutsuya1
May 22 2016 01:58
@Chrono79 yes, continue shows that
Michael Njagi
@mnjagi
May 22 2016 01:58
@ndburrus am still reading this page have been given a link to.the mozilla developer network.
Jason Shoemaker
@kutsuya1
May 22 2016 01:58
:)
DarioRebirth
@DarioRebirth
May 22 2016 01:59
Hi, I'm now getting into JavaScript and it feels like alot
Jason Shoemaker
@kutsuya1
May 22 2016 01:59
@Joshuaswift var charCode = str.charCodeAt(i) - 13; is next
Michael Njagi
@mnjagi
May 22 2016 02:00
@ndburrus yeah..the only thing i havent done is really understanding how the solution worked.
Joshua Swift
@joshuaswift
May 22 2016 02:00
@kutsuya1 Thanks, I think I understand
CamperBot
@camperbot
May 22 2016 02:00
joshuaswift sends brownie points to @kutsuya1 :sparkles: :thumbsup: :sparkles:
:cookie: 317 | @kutsuya1 |http://www.freecodecamp.com/kutsuya1
Erik Moura
@erikian
May 22 2016 02:00
@Chrono79 what if i read each individual value and store it into a variable?
tommy
@tommygebru
May 22 2016 02:00
@DarioRebirth thats ok .... if that feeling goes away... you're doing it wrong! :laughing:
Jason Shoemaker
@kutsuya1
May 22 2016 02:01
@Joshuaswift The hard part comes next...wrap around... A - 13 isn't a letter
Diego Mayer
@Chrono79
May 22 2016 02:01
@erikian you don't know for sure how many elements you have to work with, because that depends on the value the function was called with
You don't even know how they're arranged inside your array, because they're stored in sub-arrays
Norvin Burrus
@ndburrus
May 22 2016 02:02
@mnjagi ok, let's see if we can simplify.... the value of 16 was assigned to playerNumber. since the input source is playerNumber, we can use playerNumber as the variable which will point to the appropriate key in the key/value pair table. so, we won't need to use a number (in this case 16) in the player variable declaration. we can just use the variable playerNumber..... make sense?
bleujai
@bleujai
May 22 2016 02:02
@DarioRebirth or doing it way right :)
@DarioRebirth One day, one step at a time.
DarioRebirth
@DarioRebirth
May 22 2016 02:04
I'm new to it and don't really get it yet, I did htm,css
Freinet Brutus
@freinet12
May 22 2016 02:04
can someone help me with the "Counting Cards" challenge?
Diego Mayer
@Chrono79
May 22 2016 02:05
@freinet12 do you have some code to show?
craftylamma
@craftylamma
May 22 2016 02:05
Im confused with the word blanks challenge
rphares
@rphares
May 22 2016 02:06
@craftylamma , all you need to do is build a sentence
Diego Mayer
@Chrono79
May 22 2016 02:06
@craftylamma what confuses you? Did you read the Mad Libs link?
rphares
@rphares
May 22 2016 02:06
you can do so by concatenating all the parameters, @craftylamma -
Norvin Burrus
@ndburrus
May 22 2016 02:06
@mnjagi the example code illustrates how the value access is accomplished (also see the comments :)):
var myDog = "Hunter";
var dogs = {
  Fido: "Mutt",
  Hunter: "Doberman",
  Snoopie: "Beagle"
}
var breed = dogs[myDog];  // here is where the value is retrieved!! see how they use a variable - myDog??
console.log(breed);// "Doberman"
rphares
@rphares
May 22 2016 02:06
and be sure to concatenate in some non-word characters (i suggest spaces) in between each one... @craftylamma
so that the output isn't bigdogranquickly
also, store it all in the var you are going to return :blush:
Diego Mayer
@Chrono79
May 22 2016 02:07
@craftylamma @rphares add some words to make a sentence that makes sense please, we're not Tarzan
craftylamma
@craftylamma
May 22 2016 02:07
so all i have to do is enter in the variables for a noun, adjective, verb and an adverb
Jason Shoemaker
@kutsuya1
May 22 2016 02:07
I tend to click "Run Test" right away...to see what the test are looking for.
rphares
@rphares
May 22 2016 02:08
@Chrono79 , you can, but arent required to,
Michael Njagi
@mnjagi
May 22 2016 02:08
@ndburrus just how are Hunter and Var breed related???
tommy
@tommygebru
May 22 2016 02:08
sometimes the console doesnt put out enough info.... :-1:
Freinet Brutus
@freinet12
May 22 2016 02:08

@Chrono79 yeah I tried doing this: var count = 0;

function cc(card) {
// Only change code below this line

if (card == 2, 3, 4, 5, 6){

return "5 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');

rphares
@rphares
May 22 2016 02:08
and I've given up on telling people to do so, as in many places the game doesn't make sense, especially if English isn't your native language @Chrono79 ;)
@craftylamma , you dont need to declare any var,
Diego Mayer
@Chrono79
May 22 2016 02:09
@freinet12 you have to separate what you have to do in two code blocks
first evaluate card and modify the value of count as the instructions say
Then, in another block, evaluate count value and return count + bet or hold, mind your spaces and capitalization
rphares
@rphares
May 22 2016 02:09
just use the myNoun , myAdjective parameters they have already given you... you can, as @Chrono79 suggested, add other words if you like, but no new variables are necessary~
Jason Shoemaker
@kutsuya1
May 22 2016 02:10
@freinet12 Think you should use a switch()?
tommy
@tommygebru
May 22 2016 02:10
@freinet12 thats no how to exit the function.... because it is not looking for a string in that form..... the 5 would come from the
switch(value){
case 5://then do this...;
}
Puja
@Pujachaubey
May 22 2016 02:10
i am doing phoneticlookup but i did not understood can anyone just explain me.
Diego Mayer
@Chrono79
May 22 2016 02:11
@freinet12 @tommygebru you can do the first evaluation either with a switch or if/else block
tommy
@tommygebru
May 22 2016 02:12
@Chrono79 oh yeah an if/else comes to play later on
Diego Mayer
@Chrono79
May 22 2016 02:12
@tommygebru I think in this case if/else is shorter
KingCodeV
@KingCodeV
May 22 2016 02:12
Hello! guys
need help with something
Diego Mayer
@Chrono79
May 22 2016 02:12
@freinet12 certainly you can't use the if like this: if (card == 2, 3, 4, 5, 6){
try if (card >= 2 && card <= 6){
tommy
@tommygebru
May 22 2016 02:13
@Chrono79 for the whole function?challenge?
Charles
@GUITARPLRC
May 22 2016 02:14
@123xylem r u still there?
KingCodeV
@KingCodeV
May 22 2016 02:14
may someone helpme with the palindrome challenge?
Diego Mayer
@Chrono79
May 22 2016 02:14
@tommygebru yes, 2 if/else blocks can do the work
tommy
@tommygebru
May 22 2016 02:15
@rphares you should friend me that way I have 125 friends by association :smile:
Jason Shoemaker
@kutsuya1
May 22 2016 02:15
@KingCodeV that was a tough one
Puja
@Pujachaubey
May 22 2016 02:15
hii i just need help ,where am i doing wrong. i wrote the code for lookups but still i am litttle confused.
tommy
@tommygebru
May 22 2016 02:15
@Chrono79 I guess but it is necessary to learn the switch! :thumbsup:
Freinet Brutus
@freinet12
May 22 2016 02:16
@Chrono79 i tried both of those: if (card == 2, 3, 4, 5, 6){
try if (card >= 2 && card <= 6){ and they work. But what about the two other blocks of code? When I do that, they don't work
Diego Mayer
@Chrono79
May 22 2016 02:16
@tommygebru yes, but there are other cahllenges where they're better suited
tommy
@tommygebru
May 22 2016 02:16
@KingCodeV share your code please
KingCodeV
@KingCodeV
May 22 2016 02:16
@kutsuya1 you again, hope we could work together
the issue is i cant find the ,
@tommygebru how can i send it like a capture?
tommy
@tommygebru
May 22 2016 02:17
@Chrono79 this isnt so bad for practice... because we can show what happens when the value is the same for a case
@KingCodeV just send the link to the challenge that is on your page or
Jason Shoemaker
@kutsuya1
May 22 2016 02:17
@KingCodeV You never know. :)
I was able to do it in four lines of code. This was the big help: var regex = /[\W_]/g;
tommy
@tommygebru
May 22 2016 02:17
help format
CamperBot
@camperbot
May 22 2016 02:17

: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 thecode`.

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

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

Diego Mayer
@Chrono79
May 22 2016 02:17
@freinet12 look at this: https://repl.it/CThc/0
that way of writing your condition isn't ok
KingCodeV
@KingCodeV
May 22 2016 02:18
function palindrome(str) {
  // Good luck!
  var lower = str.toLowerCase();
  var splits = lower.split("");
  var comp = splits.join("");
  var scomp = comp.replace(/\s+/gm, "");
  splits.reverse();

  var tg = splits.join("");
  var stg = tg.replace(/\s+/gm, "");
  if (stg == scomp)
    {
      return true;
    }
  else
    {
      return scomp;
    }
}  

palindrome("A man, a plan, a canal, Panama");
ignore the return scoomp
its just a test of what of that var storing
@kutsuya1 let me try your way
rphares
@rphares
May 22 2016 02:19
lol, hiya, @tommygebru ~ gitter doesn't have friends...?
tommy
@tommygebru
May 22 2016 02:19
@Chrono79 also explain the other option :+1:
https://repl.it/CThc/1
Diego Mayer
@Chrono79
May 22 2016 02:19
@tommygebru maybe, but this is an opportunity to learn how to use a range in an if condition too, as you can see ;)
DarioRebirth
@DarioRebirth
May 22 2016 02:20
I'm thinking of pausing my JavaScript learning and going to ruby
Jason Shoemaker
@kutsuya1
May 22 2016 02:20
@KingCodeV
function palindrome(str) {
  var regex = /[\W_]/g;
  str1 = str.toLowerCase().replace(regex, '');
  str2 = str1.split('').reverse().join('');

  return (str1 === str2);
}
DarioRebirth
@DarioRebirth
May 22 2016 02:20
Good idea?
tommy
@tommygebru
May 22 2016 02:20
@rphares just looking at github
Freinet Brutus
@freinet12
May 22 2016 02:20
@Chrono79 you're right
rphares
@rphares
May 22 2016 02:20
ahh,
sure, i can follow you, one sec~
tommy
@tommygebru
May 22 2016 02:20
@DarioRebirth ask CodingJobs chatroom on gitter
rphares
@rphares
May 22 2016 02:21
Done! :blush:
DarioRebirth
@DarioRebirth
May 22 2016 02:21
@tommygebru okay will do
KingCodeV
@KingCodeV
May 22 2016 02:21
@kutsuya1 thank you man
CamperBot
@camperbot
May 22 2016 02:21
kingcodev sends brownie points to @kutsuya1 :sparkles: :thumbsup: :sparkles:
:cookie: 318 | @kutsuya1 |http://www.freecodecamp.com/kutsuya1
Puja
@Pujachaubey
May 22 2016 02:21
i need help.
Diego Mayer
@Chrono79
May 22 2016 02:21
@kutsuya1 /[\W|_]/g; I think it's the same either way
tommy
@tommygebru
May 22 2016 02:22
oh man @rphares you the coolest
Puja
@Pujachaubey
May 22 2016 02:22
i am doing objects for lookup. i wrote code but still its showing error.
Jason Shoemaker
@kutsuya1
May 22 2016 02:22
@KingCodeV took a while...make sure to go through it to understand it.
tommy
@tommygebru
May 22 2016 02:22
@kutsuya1 share code!
Diego Mayer
@Chrono79
May 22 2016 02:23
@Pujachaubey show us your code
Puja
@Pujachaubey
May 22 2016 02:23

function phoneticLookup(val) {
var result = "";

// Only change code below this line
var phoneticLookup = {
1: "alpha",
2: "bravo",
3: "charlie",
4: "delta",
5: "echo",
6: "foxtrot",
};
alpha[1] = "Adams";
bravo[2] = "Boston";
charlie[3] = "Chicago";
delta[4] = "Denver";
echo[5] = "Easy";
foxtrot[6] = "Frank";

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

// Change this value to test
var val = 1;
phoneticLookup[val];

KingCodeV
@KingCodeV
May 22 2016 02:23
@kutsuya1 but i would be more grateful if u dont put it that easy, i just help to figure it out how to solve it, but it was a nice hand by you
Diego Mayer
@Chrono79
May 22 2016 02:23

@Pujachaubey remove this comma: 6: "foxtrot",
delete this:

alpha[1] = "Adams";
bravo[2] = "Boston";
charlie[3] = "Chicago";
delta[4] = "Denver";
echo[5] = "Easy";
foxtrot[6] = "Frank";

change the name of your object from phoneticLookup to lookup as the instructions say

Jason Shoemaker
@kutsuya1
May 22 2016 02:24
@KingCodeV noted :)
KingCodeV
@KingCodeV
May 22 2016 02:25
@kutsuya1 great man, you are good
Puja
@Pujachaubey
May 22 2016 02:25
iok
Norvin Burrus
@ndburrus
May 22 2016 02:26
@Pujachaubey ...hmmm... carefully follow the format (for key/value storage) of the example code: (hint: the alpha, bravo, etc. values are your keys & they are not numbers...)
var alpha = {
  1:"Z",
  2:"Y",
  3:"X",
  4:"W",
  ...
  24:"C",
  25:"B",
  26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"

var value = 2;
alpha[value]; // "Y"
Diego Mayer
@Chrono79
May 22 2016 02:26
@Pujachaubey finally you have to set result value using lookup and val
Jason Shoemaker
@kutsuya1
May 22 2016 02:26
@KingCodeV that one just happen to fall together like that...you may not want to see my other code. ;)
KingCodeV
@KingCodeV
May 22 2016 02:27
@kutsuya1 sure i dont, but i like better to get help instead of a easy solution, i dont noe if you get me
Jason Shoemaker
@kutsuya1
May 22 2016 02:27
@tommygebru I usually don't share the whole thing, but it was only 4 lines. ;)
Puja
@Pujachaubey
May 22 2016 02:28
it means first i have to define var = lookup
what is the meaning of return result;
tommy
@tommygebru
May 22 2016 02:30
return result is a variable that needs to be defined @Pujachaubey
Diego Mayer
@Chrono79
May 22 2016 02:30
@Pujachaubey you have to set result value using your object lookup and the value passed as val to your function (using val as your object property name)
Jason Shoemaker
@kutsuya1
May 22 2016 02:30
@KingCodeV I understand, and it's good. It isn't that bad to read others code and figure how it works.
Norvin Burrus
@ndburrus
May 22 2016 02:30
@Pujachaubey "return result" will provide the result variable which is set by retrieving the correct value from the key/value pair table.... :)
KingCodeV
@KingCodeV
May 22 2016 02:31
@kutsuya1 yea you ate right
are*
Angel Jimenez
@aJimmer
May 22 2016 02:31
has anyone done finders keepers?
Puja
@Pujachaubey
May 22 2016 02:32
ok i am doing.
Angel Jimenez
@aJimmer
May 22 2016 02:32
function findElement(arr, func) {
  var num = 0;

  num = arr.filter(func);

  return num[0];
}

findElement([1, 2, 3, 4], function(num){ return num % 2 === 0; });
here is my solution but i was wondering if there is a better way
Norvin Burrus
@ndburrus
May 22 2016 02:32
@Pujachaubey these two lines of code need to be adjusted (phoneticLookup is set to a function & a variable....):
1. function phoneticLookup(val) {
2. var phoneticLookup = {
tommy
@tommygebru
May 22 2016 02:35
signing off today guys :smile:
DarioRebirth
@DarioRebirth
May 22 2016 02:36
Take care
Norvin Burrus
@ndburrus
May 22 2016 02:36
@Pujachaubey ...also, review/check the format of the test code line: :+1:
// Change this value to test
phoneticLookup("charlie");
Jason Shoemaker
@kutsuya1
May 22 2016 02:36
@tommygebru GNite
bleujai
@bleujai
May 22 2016 02:37
@aJimmer Doesn't get much more succinct than that. The only thing I would say is to be careful declared a variable and then changing the type of data that goes into it later. Here you started num as a number and then it finished the function as an array.
Angel Jimenez
@aJimmer
May 22 2016 02:39
@bleujai thanks for the catch, you're 100% correct
CamperBot
@camperbot
May 22 2016 02:39
ajimmer sends brownie points to @bleujai :sparkles: :thumbsup: :sparkles:
:cookie: 355 | @bleujai |http://www.freecodecamp.com/bleujai
craftylamma
@craftylamma
May 22 2016 02:41
:cookie:
:clap: :cactus: :alien:
tommy
@tommygebru
May 22 2016 02:43
cookies only appear in empty fields by aliens
OneRandomJamie
@OneRandomJamie
May 22 2016 02:44
Is there anyone on here who can walk me through step by step on Assignment with a Returned Value challenge?
tommy
@tommygebru
May 22 2016 02:45
@OneRandomJamie well this one offers an entire example for you to model off of ///// so what do you need help with specifically
Norvin Burrus
@ndburrus
May 22 2016 02:46
@OneRandomJamie sure... where are you with it?
OneRandomJamie
@OneRandomJamie
May 22 2016 02:47
@tommygebru I tried to copy the example but it didn't work. I have changed it 10 times since then. I honestly dont know what part I dont understand. It may be all of it.
Norvin Burrus
@ndburrus
May 22 2016 02:47
@OneRandomJamie ok, what does your code look like now? you're going to have an "ahaa!" moment.... :)
OneRandomJamie
@OneRandomJamie
May 22 2016 02:47
@ndburrus var = processArg;
var result = processArg(num);
function processArg(num) {
return (num - 5);
}
changed = change();
tommy
@tommygebru
May 22 2016 02:48
@OneRandomJamie might be spelling or syntax!
Kevin Schwert
@kevinpschwert
May 22 2016 02:49

Having trouble understanding what is wrong with this code. When I submit my answer it says that I get 4 out of the six checklists correct but it won't return the last two correctly and I can't figure out why.
var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function() {

// Only change code below this line.
var gear = 0;

this.setGear = function(shift) {
gear += shift;
};

this.getGear = function() {
return gear;
};

};

var myCar = new Car();

var myBike = new Bike();

tommy
@tommygebru
May 22 2016 02:51
var = processArg; ???? @OneRandomJamie
Diego Mayer
@Chrono79
May 22 2016 02:51
@kevinpschwert this: gear += shift; you should set the value, not increase it
Norvin Burrus
@ndburrus
May 22 2016 02:51
@OneRandomJamie ok, the only code that should be changed is below the comment line...
// Only change code below this line
OneRandomJamie
@OneRandomJamie
May 22 2016 02:51
@tommygebru ok
Firas El-Hamed
@Felhamed
May 22 2016 02:52

//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 lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i <= 3; i++) {
if (contacts[i].firstName == firstName) {
var ident = i;
} else {
return "No such contact";
}
}

if (contacts[ident][prop] !== ""){
return contacts[ident][prop];
} else {
return "No such property";
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
porp = "lastName";
console.log (contacts[1][porp]);

tommy
@tommygebru
May 22 2016 02:52

@kevinpschwert it might have to do with this line....
gear += shift;

make it

gear = shift;

Norvin Burrus
@ndburrus
May 22 2016 02:52
@OneRandomJamie can you update the code?
tommy
@tommygebru
May 22 2016 02:52
@Felhamed dude you're spelling T_T
Kevin Schwert
@kevinpschwert
May 22 2016 02:53
@tommygebru Wow...thank you. That was simply:) Been working on that one for a while.
Firas El-Hamed
@Felhamed
May 22 2016 02:53
@tommygebru Spelling?
tommy
@tommygebru
May 22 2016 02:54
many typos @Felhamed :smile: :+1:
ok battery dead now!!
You-Da-Real-MVP.jpg
Norvin Burrus
@ndburrus
May 22 2016 02:55
@Felhamed hmm... examine this code line:
for (var i = 0; i <= 3; i++) {  // what is that 3 doing in there?
Kevin Schwert
@kevinpschwert
May 22 2016 02:56
@tommygebru Why was it working for myBike.setGear(4) but not for 3 or 1 and when I would manually type in myBike.setGear(4) it returned 4 and when I did it with 3 and 1 it returned those numbers respectively also.
OneRandomJamie
@OneRandomJamie
May 22 2016 02:57
@ndburrus var processArg = 7;
function processArg(7) {
return (num +3) / 5;
}
processArg =(7);
Kevin Schwert
@kevinpschwert
May 22 2016 02:57
0 + shift still equals the same as gear = shift. Just confused on why it wouldn't work that way.
Norvin Burrus
@ndburrus
May 22 2016 02:57
@Felhamed review this code line:
porp = "lastName";  // porp !- prop!!!
Firas El-Hamed
@Felhamed
May 22 2016 02:58
@ndburrus I can replace the 3 with contacts.length
Puja
@Pujachaubey
May 22 2016 02:58
in instruction its saying that Convert the switch statement into a lookup table called lookup.
Firas El-Hamed
@Felhamed
May 22 2016 02:58

@ndburrus function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i <= 3; i++) {
if (contacts[i].firstName == firstName) {
if (contacts[i][prop] !== ""){
return contacts[i][prop];
} else {
return "No such property";
}
} else {
return "No such contact";
}
}

// Only change code above this line
}

@ndburrus Can I have a nested if like this
Matthew Hand
@mmhand123
May 22 2016 02:59
@kevinpschwert because gear will keep getting added to if you do += so after the first test gear will be something like 4 for instance and then it would get set to 7
Kevin Schwert
@kevinpschwert
May 22 2016 03:01
But when I would type in myBike.setGear(3) after var myBike = new Bike(); the output was showing that it was 3.
Norvin Burrus
@ndburrus
May 22 2016 03:02
@OneRandomJamie error message: "Expected an identifier and instead saw a '7' " for the line "function processArg(7) {
"
Kevin Schwert
@kevinpschwert
May 22 2016 03:02
Okay...thanks again for the help. Appreciate it a lot.
Norvin Burrus
@ndburrus
May 22 2016 03:03
@OneRandomJamie also, this line makes a reassignment which is not helpful:
processArg =(7);
@Felhamed ok, the logic says if contacts[i][prop] is empty, then return contacts[i][prop] ?
Benjamin Miller
@bendjmiller222
May 22 2016 03:06
Can someone help me with understanding the stand in line challenge in javascript? Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed. I'm a bit confused
Puja
@Pujachaubey
May 22 2016 03:06
at last i run the test.
Norvin Burrus
@ndburrus
May 22 2016 03:06
@bendjmiller222 do you have some code?
Firas El-Hamed
@Felhamed
May 22 2016 03:07
@ndburrus how do I select the "likes" property from the 4th array in var contacts:
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"]
}
];
Benjamin Miller
@bendjmiller222
May 22 2016 03:07

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

return item; // Change this line
}

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

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

Norvin Burrus
@ndburrus
May 22 2016 03:09
@bendjmiller222 ok, there are four (4) array operators to choose from shift, unshift, push & pop. which ones will be needed for the requirement/s? the first step is: "Add the number to the end of the array"
Benjamin Miller
@bendjmiller222
May 22 2016 03:10
shift and push i believe should be used
Norvin Burrus
@ndburrus
May 22 2016 03:11
@bendjmiller222 correct! alright, can we code the first line?
@Felhamed contacts[3] - numbering (for arrays) starts with 0...
Benjamin Miller
@bendjmiller222
May 22 2016 03:13
.shift(arr) .push(num) still trying to wrap my head around java
Kevin Schwert
@kevinpschwert
May 22 2016 03:14
In the Iterate over Arrays with map, what is the benefit of using the map function over a for loop? I got the correct answer but then I did it with a for loop: for (var i = 0; i < oldArray.length; i++) {
console.log(oldArray[i] + 3);
}
and I got the same answer and it seemed less complicated. There may be more with the map function down the road that I don't know about but I was just wondering at the present moment.
Firas El-Hamed
@Felhamed
May 22 2016 03:14
@ndburrus When I try console.log(contacts[3]); nothing comes out
Suprith Aireddy
@sup-rith
May 22 2016 03:16
Can someone help me with the Caesars Ciphers?
wiki Caesars Ciphers
CamperBot
@camperbot
May 22 2016 03:17
no wiki entry for: caesars ciphers
Suprith Aireddy
@sup-rith
May 22 2016 03:17
wiki Caesars Cipher
CamperBot
@camperbot
May 22 2016 03:17

:point_right: algorithm caesars cipher [wiki]

Algorithm Caesars Cipher

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

:checkered_flag: Problem Explanation:

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

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

Norvin Burrus
@ndburrus
May 22 2016 03:18
@Felhamed moment...
Keenen Garnett
@Wallyw4
May 22 2016 03:20
quick question
Norvin Burrus
@ndburrus
May 22 2016 03:20
@Felhamed this line selects the 4th record:
code:
console.log(contacts[3]);
--------------------------
output:
{ firstName: 'Kristian',
  lastName: 'Vos',
  number: 'unknown',
  likes: [ 'Javascript', 'Gaming', 'Foxes' ] }
Keenen Garnett
@Wallyw4
May 22 2016 03:21
how come i cant .sort t?

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

  for (var v = 0; v < arr.length; v++)
     var t = arr.join().split();


         console.log(t);


}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Norvin Burrus
@ndburrus
May 22 2016 03:23
@bendjmiller222 ok, review the shift syntax:
SyntaxEDIT
arr.shift()
@OneRandomJamie how are we doing?
Firas El-Hamed
@Felhamed
May 22 2016 03:25
@ndburrus When I input console.log(contacts[3]); I don't get any output
Benjamin Miller
@bendjmiller222
May 22 2016 03:26

@ndburrus arr.push(item);

return arr.shift(); I see Thanks!

CamperBot
@camperbot
May 22 2016 03:26
bendjmiller222 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 393 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
May 22 2016 03:26
@bendjmiller222 super work!!! :+1:
@Felhamed browser refresh?
Norvin Burrus
@ndburrus
May 22 2016 03:33
@OneRandomJamie are you finished?
@Felhamed ok, can you post your curret code?
Firas El-Hamed
@Felhamed
May 22 2016 03:42

//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"]
}
];
console.log(contacts[3]);
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i <= 3; i++) {
if (contacts[i].firstName == firstName && contacts[i][prop] !== "") {
return contacts[i][prop];
} else if (contacts[i][prop] == "") {
return "No such property";
} else {
return "No such contact";
}
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");

Norvin Burrus
@ndburrus
May 22 2016 03:45
@Felhamed ok, it may be helpful to eliminate the for loop. an if/else if decision structure can allow satisfying all of the requirements.. :) the decision tree can be mapped in the exact order the requirements are given in. this methodology may be easier to follow...
Firas El-Hamed
@Felhamed
May 22 2016 03:46
@ndburrus How would I be able to go through the object to confirm that the contact name exists and then pull the corresponding property
Greg Duncan
@GregatGit
May 22 2016 03:47
@Felhamed (this is your code) this makes it easier to read

//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"]
    }
];
console.log(contacts[3]);
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i <= 3; i++) {
  if (contacts[i].firstName == firstName && contacts[i][prop] !== "") {
    return contacts[i][prop];
  } else if (contacts[i][prop] == "") {
    return "No such property";
  } else  {
    return "No such contact";
  }
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
Norvin Burrus
@ndburrus
May 22 2016 03:47
@Felhamed see above comments and see if they make sense to you.. :) a for loop that iterates three times really isn't necessary....
Firas El-Hamed
@Felhamed
May 22 2016 03:48
@GregatGit Whats the syntax to paste code
Norvin Burrus
@ndburrus
May 22 2016 03:48
help format @Felhamed
CamperBot
@camperbot
May 22 2016 03:48

: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 thecode`.

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

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

Greg Duncan
@GregatGit
May 22 2016 03:48
``` on seperate lines above and below
Firas El-Hamed
@Felhamed
May 22 2016 03:49
Thanks
@ndburrus @GregatGit thanks
CamperBot
@camperbot
May 22 2016 03:49
felhamed sends brownie points to @ndburrus and @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 394 | @ndburrus |http://www.freecodecamp.com/ndburrus
:cookie: 513 | @gregatgit |http://www.freecodecamp.com/gregatgit
Norvin Burrus
@ndburrus
May 22 2016 03:51
<test single line code> neat! :)
stevie
@pmwong007
May 22 2016 03:51

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case a:
answer = "apple";
break;
case b:
answer = "bird";
break;
case c:
answer = "cat";
break;
default:
answer = "stuff";
}

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

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

Got "ReferenceError: a is not defined"
Norvin Burrus
@ndburrus
May 22 2016 03:52
@pmwong007 which challenge is this?
Minh Anh Lam
@LMApro
May 22 2016 03:52
@pmwong007 you're missing important things
stevie
@pmwong007
May 22 2016 03:52
default option in Switch
please tell me
Minh Anh Lam
@LMApro
May 22 2016 03:53
case 'a':, not case a
stevie
@pmwong007
May 22 2016 03:53
have tried, doesn't seem to work..
Norvin Burrus
@ndburrus
May 22 2016 03:54
@pmwong007 answer is never updated! :) it is initially empty, and then it is returned as empty....
Minh Anh Lam
@LMApro
May 22 2016 03:54
anyway, which challenge? @pmwong007 , I understand your issue but i have no idea what is this challenge?
stevie
@pmwong007
May 22 2016 03:54
Adding a default option in Switch statements
have also tried answer += "stuff.."
Norvin Burrus
@ndburrus
May 22 2016 03:55
@pmwong007 also, carefully follow the example code format:
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"
Minh Anh Lam
@LMApro
May 22 2016 03:56
the thing after "case" keyword must be a primitive VALUE like string ('a', 'superman') or number (1, 2.3, ..) , not a variable name, you're using a variable name (a in this case), not a value (i think i would be 'a' or something similar)
stevie
@pmwong007
May 22 2016 03:56
@ndburrus Adding default option in Switch statement
@ndburrus No it doesn't work
Minh Anh Lam
@LMApro
May 22 2016 03:57
and you have to passing value to your function call, not a variable name: switchOfStuff("a"), not switchOfStuff(a)
@pmwong007
Norvin Burrus
@ndburrus
May 22 2016 03:58
@pmwong007 did you see the comment about formatting? :)
stevie
@pmwong007
May 22 2016 03:58
@LMApro @ndburrus Now it works!!! Gracious!!
Norvin Burrus
@ndburrus
May 22 2016 03:59
@pmwong007 super job@! :sparkles:
stevie
@pmwong007
May 22 2016 03:59
@ndburrus it's the quotes in the function call that i need to add**
Norvin Burrus
@ndburrus
May 22 2016 04:01
@pmwong007 yes... i think that was in a/the comment/s... :smile:
Minh Anh Lam
@LMApro
May 22 2016 04:01
@pmwong007 One important thing you have to note is that, beginner often missing the quotes (double or single) on the string value.
AudioGen
@AudioGen
May 22 2016 04:01
'''
return "Hello"
CamperBot
@camperbot
May 22 2016 04:01
:bulb: to format code use backticks! ``` more info
stevie
@pmwong007
May 22 2016 04:01
@LMApro i will remember from now on
AudioGen
@AudioGen
May 22 2016 04:01
'''
return "Hello"
'''
CamperBot
@camperbot
May 22 2016 04:01
:bulb: to format code use backticks! ``` more info
kwal0203
@kwal0203
May 22 2016 04:02
```
```
Norvin Burrus
@ndburrus
May 22 2016 04:02
help format @AudioGen @kwal0203
CamperBot
@camperbot
May 22 2016 04:02

: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 thecode`.

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

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

AudioGen
@AudioGen
May 22 2016 04:02
return "Hello"
Thanks Camper
@kwal0203 Thanks
CamperBot
@camperbot
May 22 2016 04:03
audiogen sends brownie points to @kwal0203 :sparkles: :thumbsup: :sparkles:
:cookie: 325 | @kwal0203 |http://www.freecodecamp.com/kwal0203
kwal0203
@kwal0203
May 22 2016 04:04
@AudioGen haha i was just practicing myself
AudioGen
@AudioGen
May 22 2016 04:04
oh lol
Norvin Burrus
@ndburrus
May 22 2016 04:05
@AudioGen @kwal0203 the chat & compose buttons to the right of the text areas may be useful also... :+1: (for posting code & text) if you forget, you can always type "help format" to get camperbot assistance...
Kelly Kovalcik
@kellykov
May 22 2016 04:06
How do you add 3 for "Iterate over Arrays with map"? I have the overall code but I'm just not sure which word to use. In the example it says var timesFour so I just don't know what to put for var ____Three? I'm not sure if it's plus or add or something else to replace times. Any ideas?
kwal0203
@kwal0203
May 22 2016 04:11
@ndburrus what does compose mode do?
Suprith Aireddy
@sup-rith
May 22 2016 04:11
Whats everyone working on?
Jason Shoemaker
@kutsuya1
May 22 2016 04:12
@sup-rith Convert HTML Entities
Firas El-Hamed
@Felhamed
May 22 2016 04:13
Finally figured it out
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
      if (firstName == contacts[i].firstName) {
        if (contacts[i].hasOwnProperty(prop)) {
          return contacts[i][prop];
      } else {
          return "No such property";
      } 
    }
  }
   return "No such contact";
}
Tekeste Gebreanenia
@iamtekeste
May 22 2016 04:16
Hi guys
New member ... I am working on this challenge and not sure what the formula is for calculating the orbital period
Norvin Burrus
@ndburrus
May 22 2016 04:21
This message was deleted
This message was deleted
CamperBot
@camperbot
May 22 2016 04:21
no wiki entry for: compose
Norvin Burrus
@ndburrus
May 22 2016 04:22
@kwal0203 compose changes to code entry mode
@Felhamed congratulations!! :+1:
@iamtekeste the formula is in the link https://en.wikipedia.org/wiki/Orbital_period
Lallo Vigil
@lalov1
May 22 2016 04:26
Can someone please tell me what I'm doing wrong for this on the Seek and Destroy problem?
function destroyer(a, args) {
  // Remove all the values
  var arr=arguments[0];


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

    for(var i=1;i<arguments.length;i++){

     return value!==arguments[i]; 
    }
  });

  return output;
}

destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3);
Tekeste Gebreanenia
@iamtekeste
May 22 2016 04:26
@ndburrus I saw that one ... but there are a bunch of formulas ... not sure which one is appropriate
kwal0203
@kwal0203
May 22 2016 04:26
console.log('hello');
console.log('hello');
console.log('hello');
@ndburrus thanks
CamperBot
@camperbot
May 22 2016 04:27
kwal0203 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 395 | @ndburrus |http://www.freecodecamp.com/ndburrus
Minh Anh Lam
@LMApro
May 22 2016 04:28

@lalov1 here is my solution:

var args = Array.prototype.slice.call(arguments);
  return arr.filter(function(item) {
    return args.indexOf(item) === -1; 
  });

remember that, arguments is an array-like object, it's not an array

I changed the params to make it more generic:
function destroyer(arr) {
  // Remove all the values
  var args = Array.prototype.slice.call(arguments);
  return arr.filter(function(item) {
    return args.indexOf(item) === -1; 
  });
}
Norvin Burrus
@ndburrus
May 22 2016 04:29
@iamtekeste well, the a (semi-major axis) & "u" (GM/standard gravitational parameter ) are given, so it would be T = 2(pi){sqrt(a/to the third power divided by u)}... "Small body orbiting a central body"
@kwal0203 you're welcome!! kudos to you! :sparkles:
Chris Cullen
@123xylem
May 22 2016 04:34
@GUITARPLRC yes
Norvin Burrus
@ndburrus
May 22 2016 04:36
@kellykov the example code illustrates this one well... :) (of course, we need to update the formula to match the requirement/s)
var timesFour = oldArray.map(function(val){
  return val * 4;
});
Tekeste Gebreanenia
@iamtekeste
May 22 2016 04:36
@ndburrus Thanks!
CamperBot
@camperbot
May 22 2016 04:36
iamtekeste sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 396 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
May 22 2016 04:37
@iamtekeste you're very welcome! great job! :sparkles:
Kelly Kovalcik
@kellykov
May 22 2016 04:41
@ndburrus So I'm just wondering, when I update the formula to match the requirement of adding three to each number, instead of var timesFour it will be var ____Three. I just don't know what the blank should be - is it plusThree or addThree or something else?
@ndburrus Ah nevermind I got it :)
Norvin Burrus
@ndburrus
May 22 2016 04:43
@kellykov let's review the requirement: "Use the map function to add 3 to every value in the variable oldArray". good job! :) keyword - add.
Kelly Kovalcik
@kellykov
May 22 2016 04:47
@ndburrus Thank you :)
CamperBot
@camperbot
May 22 2016 04:47
kellykov sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 397 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
May 22 2016 04:47
@kellykov you're welcome :fire: you're on fire!
Lena Zheng
@missimi
May 22 2016 04:59
hi all!
can someone help me with "this"?

var user = {
tournament:"The Masters",
data :[
{name:"T. Woods", age:37},
{name:"P. Mickelson", age:43}
],

clickHandler:function () {
// the use of this.data here is fine, because "this" refers to the user object, and data is a property on the user object.​

this.data.forEach (function (person) {
// But here inside the anonymous function (that we pass to the forEach method), "this" no longer refers to the user object.​
// This inner function cannot access the outer function's "this"​

console.log ("What is This referring to? " + this); //[object Window]​

console.log (person.name + " is playing at " + this.tournament);
// T. Woods is playing at undefined// P. Mickelson is playing at undefined​
})
}


}

user.clickHandler(); // What is "this" referring to? [object Window]

in here, how come the "this" inside the this.data.forEach(function) does not refer to "this.data"?
Lena Zheng
@missimi
May 22 2016 05:06
 var user = {
    tournament:"The Masters",
    data      :[
    {name:"T. Woods", age:37},
    {name:"P. Mickelson", age:43}
    ],
​
    clickHandler:function () {
    // the use of this.data here is fine, because "this" refers to the user object, and data is a property on the user object.​this.data.forEach (function (person) {
    // But here inside the anonymous function (that we pass to the forEach method), "this" no longer refers to the user object.​
    // This inner function cannot access the outer function's "this"​

    console.log ("What is This referring to? " + this); //[object Window]​

    console.log (person.name + " is playing at " + this.tournament);
    // T. Woods is playing at undefined​
    // P. Mickelson is playing at undefined​
    })
    }
​
    }
​
    user.clickHandler(); // What is "this" referring to? [object Window]
Michael Guest
@MichaelGuest
May 22 2016 05:09

Hello can someone help me with Accessing Objects Properties with Bracket Notation I inputted the properties an entree and drink `
// Setup
var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

// Only change code below this line

var entreeValue = testObj.hamburger; // Change this line
var drinkValue = testObj.water; // Change this line
`


// Setup
var testObj = {
  "an entree": "hamburger",
  "my side": "veggies",
  "the drink": "water"
};

// Only change code below this line

var entreeValue = testObj.hamburger;   // Change this line
var drinkValue = testObj.water;    // Change this line
Norvin Burrus
@ndburrus
May 22 2016 05:15
@MichaelGuest ok, when the value/s (hamburger/water) is/are used in the code it sort of defeats the purpose of being able to use variables. what if, instead of hamburger & water, we wanted veggies and water? how could we get that data without entering (or receiving) this spcific information (hamburger/water) specifically? hint: keep in mind that we went through the trouble of seeting up a variable in entreeValue. what did we do that for?
Michael Guest
@MichaelGuest
May 22 2016 05:17
@ndburrus thanks! Ill think about that
CamperBot
@camperbot
May 22 2016 05:17
michaelguest sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 398 | @ndburrus |http://www.freecodecamp.com/ndburrus
Michael Guest
@MichaelGuest
May 22 2016 05:18
@ndburrus testObj is a variable?
How would I make entreeValue a string? Do I need to make the variable a string?
Norvin Burrus
@ndburrus
May 22 2016 05:20
@MichaelGuest also, remember that we can access the value/s we want/need through/via/using the key in the key/value pair object... make sense? question answer: testObj is a variable. but the variable you should focus on at the moment is the variable entreeValue! second question answer: there is no need to covert entreeValue to a string. we are only dealing with strings... notice, that there are no non-string values... getting clearer?
Michael Guest
@MichaelGuest
May 22 2016 05:23
@ndburrus Yeah I appreciate it that helped me to get a better understanding.
Norvin Burrus
@ndburrus
May 22 2016 05:23
@MichaelGuest take another peek at the sample code to see how they accessed a value ....
var myObj = {
  "Space Name": "Kirk",
  "More Space": "Spock"
};
myObj["Space Name"]; // Kirk
myObj['More Space']; // Spock
@MichaelGuest to get to Kirk, they used "Space Name" & to get to Spock, they used "More Space". see how that works?
Michael Guest
@MichaelGuest
May 22 2016 05:25
@ndburrus Oh yeah I see now haha.
@ndburrus Thanks I got it!
CamperBot
@camperbot
May 22 2016 05:26
michaelguest sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: michaelguest already gave ndburrus points
Norvin Burrus
@ndburrus
May 22 2016 05:28
@MichaelGuest great job!! :+1:
Michael Guest
@MichaelGuest
May 22 2016 05:29
Thanks!
Robert Richey
@0x0936
May 22 2016 05:30
@santa83 sorry for the late response - had a long day. If you haven't solved sumAll() yet, the issue is with using the default behavior of .sort() which performs a lexical sort. The fix for this is to pass a callback function to sort.
arr.sort(function(a, b) {
  // if a - b is negative, keep a before b
  // if a - b is zero, values are equal, keep a before b
  // if a - b is positive, swap a with b
  return a - b;
});
craftylamma
@craftylamma
May 22 2016 05:44
how does assingnment with a returned value work?
:confused:
Norvin Burrus
@ndburrus
May 22 2016 05:47
@craftylamma ok, let's focus on writing this code: "Instructions -
Call the processArg function with an argument of 7 and assign its return value to the variable processed." can you do this?
craftylamma
@craftylamma
May 22 2016 05:48
@ndburrus don't worry, it just startled me cause i'm tired
Norvin Burrus
@ndburrus
May 22 2016 05:48
@craftylamma ok...
Michael Guest
@MichaelGuest
May 22 2016 05:52
Should I always use let instead of var now?
Norvin Burrus
@ndburrus
May 22 2016 05:56
@MichaelGuest i saw a brief comment exchange that suggested that FCC is capable of handling ES6. although it seemed that an adjustment needs to be made. btw, did your code pass?
Michael Guest
@MichaelGuest
May 22 2016 05:59
@ndburrus A lot of people on the chats have been thinking the same way as you. I discovered that you do not have to tweak anything your code challenges will pass in ES6.
Shreyas Gune
@shreyasgune
May 22 2016 06:00
Hi guys
sorry to interfere
I need some help
Michael Guest
@MichaelGuest
May 22 2016 06:01
Hello @shreyasgune
Norvin Burrus
@ndburrus
May 22 2016 06:01
@MichaelGuest i think that is due to backwards compatibility. the fcc material was generated using pre ES6 code, and ES6 maintains backward/s compatibility - thus we don't really notice any change....
Shreyas Gune
@shreyasgune
May 22 2016 06:01
I wrote a Python script for Bottom Up Merge Sort, and Its killing me. Crashes, and I don't know why. :(
Michael Guest
@MichaelGuest
May 22 2016 06:02
@ndburrus Yeah that would make sense haha
Norvin Burrus
@ndburrus
May 22 2016 06:05
@shreyasgune i don't know python....sorry... :worried:
Shreyas Gune
@shreyasgune
May 22 2016 06:05
:(
oh well
Michael Guest
@MichaelGuest
May 22 2016 06:06
@shreyasgune Maybe you could ask the FreeCodeCamp main chat.
Norvin Burrus
@ndburrus
May 22 2016 06:06
@shreyasgune you could post on stackoverflow :) you could also search for other help resources/communities. there is also a great python (and other languages) debugger that has super graphics of what each line of code is doing. I'd have to look for it, but you could try that also... or, you can console.log key pieces of code to narrow down the issue..:)
Michael Guest
@MichaelGuest
May 22 2016 06:06
^^^
@ndburrus Great idea
Shreyas Gune
@shreyasgune
May 22 2016 06:06
I did. I haven't received a reply yet. I'll keep waiting. :)
Steph
@tcapre01
May 22 2016 06:06
This message was deleted
var result = $("#submit").click(function(event){
    shuffle(quotes).html(event.result);
});

$("a:first").attr( "href", "https://twitter.com/intent/tweet?text=" + result)
Hey guys I'm trying to get my random quote generator to tweet the quote
so far what I manage is that it tweets [object object] since my quotes are in an array
any advice on how to fix this? I've been stuck on this for ages
Norvin Burrus
@ndburrus
May 22 2016 06:14
@shreyasgune this debugger may be useful: http://www.pythontutor.com/visualize.html#mode=edit
Shreyas Gune
@shreyasgune
May 22 2016 06:14
im going to try this out
Norvin Burrus
@ndburrus
May 22 2016 06:15
@shreyasgune that's the graphical one i wanted to find.... it seems pretty neat!
Martialis39
@Martialis39
May 22 2016 06:23
hey all!
Can anyone tell me
where can I find a sound for my pomodoro timer
Shreyas Gune
@shreyasgune
May 22 2016 06:25
The graphical debugger is a godsent
Thanks!!!!!!
I'm still looking thru it
but it's helping
Norvin Burrus
@ndburrus
May 22 2016 06:26
@shreyasgune super! glad you find it useful :)
Michael Guest
@MichaelGuest
May 22 2016 06:35

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

function checkObj(checkProp) {
  // Your Code Here
  checkObj.hasOwnProperty("gift");
  checkObj.hasOwnProperty("pet");
  checkObj.hasOwnProperty("bed");
  return "Not Found";
}

// Test your code by modifying these values
checkObj("pet");
why isn't my solution passing?
Norvin Burrus
@ndburrus
May 22 2016 06:36
@MichaelGuest challenge?
Michael Guest
@MichaelGuest
May 22 2016 06:37
Testing Objects for Properties
Camille Garcia
@camgarcia53
May 22 2016 06:38
I have this as solution for lesson: Updating Object Properties
Ivan Saveliev
@ivansvlv
May 22 2016 06:38
@MichaelGuest you return "Not Found"
Camille Garcia
@camgarcia53
May 22 2016 06:38
ourDog.name = "Happy Coder";
Aditya Giridhar
@agiridh
May 22 2016 06:38
@MichaelGuest You need to check if the property passed to the function "checkprop" is one of the properties of myObj. You need an if statement to do this
Michael Guest
@MichaelGuest
May 22 2016 06:39
@agiridh Thanks ill try that.
CamperBot
@camperbot
May 22 2016 06:39
michaelguest sends brownie points to @agiridh :sparkles: :thumbsup: :sparkles:
:cookie: 282 | @agiridh |http://www.freecodecamp.com/agiridh
Norvin Burrus
@ndburrus
May 22 2016 06:39
@MichaelGuest ok, the code really has no instructions to meet the requirement/s.
Ivan Saveliev
@ivansvlv
May 22 2016 06:40
@MichaelGuest write a logic that sounds like: If this object has property of "checkProp" argument, then return true, else return "Not Found"
Camille Garcia
@camgarcia53
May 22 2016 06:40
why doesn't it pas
pass
Michael Guest
@MichaelGuest
May 22 2016 06:41
@camgarcia53 It should but Happy Camper
Mohammad Albarmawi
@malbarmawi
May 22 2016 06:41

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

// Only change code below this line
function updateRecords(id, prop, value) {

if (value !== "")
{
switch (prop)
{
case "artist":
collection[id][prop]=value;
break;
case "tracks":
collection[id][prop].push(value);
break;
}
}

return collection;
}

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

Norvin Burrus
@ndburrus
May 22 2016 06:41
@MichaelGuest these three statements all evaluate to a boolean. they don't return any information. so all you really have is the command to return "Not Found" (which is what you get)
checkObj.hasOwnProperty("gift");
  checkObj.hasOwnProperty("pet");
  checkObj.hasOwnProperty("bed");
Mohammad Albarmawi
@malbarmawi
May 22 2016 06:42
the test fail in After updateRecords(2548, "artist", ""), artist should not be set
Michael Guest
@MichaelGuest
May 22 2016 06:42
@ndburrus Should I put those into a if else statement?
Aditya Giridhar
@agiridh
May 22 2016 06:42
@mbarmawi Can you put three tics ``` before and after your code?
Like so:
your code
Ivan Saveliev
@ivansvlv
May 22 2016 06:42
@camgarcia53 you store properties as Strings, so to read a propery you need to evaluate it. so you should use [ ] and put a property name as a string there
Norvin Burrus
@ndburrus
May 22 2016 06:43
@MichaelGuest ...that would work splendidly... :+1:
Michael Guest
@MichaelGuest
May 22 2016 06:43
@ndburrus sweet! ill try that
Norvin Burrus
@ndburrus
May 22 2016 06:43
help format @mbarmawi
CamperBot
@camperbot
May 22 2016 06:43

: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 thecode`.

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

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

Michael Njagi
@mnjagi
May 22 2016 06:43
myObj.hasOwnProperty(val)\\
Ivan Saveliev
@ivansvlv
May 22 2016 06:46

@camgarcia53 here is an example:

var obj1 = {name: "Camille"};

you can read it - obj1.name because name is not stored as string, and it's a valid variable name, so you can access it just naming it.

but if you create a property as a String like here:

var obj2={"name": "Camille"};

you need to use square brackets like - obj2.["name"], to access it. because you see, String is not a valid variable name, it's a String, and interpreter need to evaluate infromation to match it, and this is done by square brackets.

Kyle W Pilkinton
@tadake
May 22 2016 06:47
hey guys can anyone help me out with the next steps on the Where art thou challenge?
  for(i = 0; i < collection.length;i++){   // for every object in collection

     var matched = 0;
     var missed = 0;

    for(j = 0; j < length; j++){ // for every property in source
  var cur =source[search];

     if(collection[i].hasOwnProperty(search[j])){
        matched++;
       }
      else{
         missed++;
       }

      if(matched > 0 && missed <= 0){
        arr.push(collection[i]);
      }
 } 
}
  //Only change code above this line
  return arr;
}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Mohammad Albarmawi
@malbarmawi
May 22 2016 06:47
'''js
CamperBot
@camperbot
May 22 2016 06:47
:bulb: to format code use backticks! ``` more info
Ivan Saveliev
@ivansvlv
May 22 2016 06:47
@tadake check your "for" statement
Camille Garcia
@camgarcia53
May 22 2016 06:48
@isavelyev ok ,thank you
Ivan Saveliev
@ivansvlv
May 22 2016 06:48
@tadake it should be written like:
for(var i = 0; condition, action);
so you miss a variable declaration there
@camgarcia53 yw, let me know if you've passed it and if further assistance is needed
Michael Njagi
@mnjagi
May 22 2016 06:50
hi guys..i need help here with this: Testing Objects for Properties
Norvin Burrus
@ndburrus
May 22 2016 06:50
@mbarmawi ok, there is a switch statement inside the if statement. hte logic can be improved... :)
Michael Guest
@MichaelGuest
May 22 2016 06:50
@ndburrus I got this now with the if elses but it still doesn't work.

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

function checkObj(checkProp) {
  // Your Code Here
  if(checkObj.hasOwnProperty){
      return "pony";
     }
  else if(checkObj.hasOwnProperty){
      return "kitten";
  }
  else if(checkObj.hasOwnProperty){
      return "bed";
  }
  else
  return "Not Found";
}

// Test your code by modifying these values
checkObj("pet");
Mohammad Albarmawi
@malbarmawi
May 22 2016 06:50

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

// Only change code below this line
function updateRecords(id, prop, value) {

  if (value !== "")
  {
    switch (prop)
      {
        case "artist":
          collection[id][prop]=value;
          break;
        case "tracks":
          collection[id][prop].push(value);
          break;
      }
  }

  return collection;
}

// Alter values below to test your code
updateRecords(1245, "artist", "");
the test fail when the value ""
Michael Guest
@MichaelGuest
May 22 2016 06:50
@mnjagi im on the same one
Ivan Saveliev
@ivansvlv
May 22 2016 06:50
@MichaelGuest it's wrong
@MichaelGuest if you translate it to your own language and read out loud you will understand it
Thompson Ike
@hubhubace
May 22 2016 06:51
hi room
pls help
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
Michael Guest
@MichaelGuest
May 22 2016 06:51
@isavelyev How would I go about doing that? I think it would really help me
Thompson Ike
@hubhubace
May 22 2016 06:51

function abTest(a, b) {
// Only change code below this line

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

Ivan Saveliev
@ivansvlv
May 22 2016 06:52

@MichaelGuest

if(checkObj.hasOwnProperty){
      return "pony";
     }

What do you say here? Object has property, return "pony". But what property? Why you want to return pony?

Norvin Burrus
@ndburrus
May 22 2016 06:52
@MichaelGuest which object should be evaluated? hint: myObj or checkObj?
Thompson Ike
@hubhubace
May 22 2016 06:52

@ndburrus function abTest(a, b) {
// Only change code below this line

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

Aditya Giridhar
@agiridh
May 22 2016 06:52
@MichaelGuest Do something like:
if (myObj.hasOwnProperty(checkProp)){
// ...
}
Ivan Saveliev
@ivansvlv
May 22 2016 06:53
@agiridh people won't learn if you give them answer right away :)
Michael Njagi
@mnjagi
May 22 2016 06:53

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

function checkObj(checkProp) {
  // Your Code Here
 var val="";
if(val=="gift" || val== "pet" || val== "bed")

{console.log( myObj.hasOwnProperty(val));}
 else    console.log("Not Found");


}

// Test your code by modifying these values
checkObj("bed");
Aditya Giridhar
@agiridh
May 22 2016 06:53
@MichaelGuest You want to evaluate whether checkProp is a property of the object myObj
Norvin Burrus
@ndburrus
May 22 2016 06:53
This message was deleted
Aditya Giridhar
@agiridh
May 22 2016 06:53
@isavelyev Oh yeah LOL my bad
Ivan Saveliev
@ivansvlv
May 22 2016 06:54
@agiridh no worries, I just really want push people to that click moment, when they really udnerstand what they are doing rather then just guessing the answer
Norvin Burrus
@ndburrus
May 22 2016 06:54
@hubhubace which challenge?
Thompson Ike
@hubhubace
May 22 2016 06:54
Return Early Pattern for Functions
Aditya Giridhar
@agiridh
May 22 2016 06:54
This message was deleted
@isavelyev true man
Kyle W Pilkinton
@tadake
May 22 2016 06:54
im not sure what you mean @isavelyev my for loops have a declaration codition and an action?? did i make a mistake in syntax??\
Michael Guest
@MichaelGuest
May 22 2016 06:55
I really want to understand this but I just don't get properties lol
Thompson Ike
@hubhubace
May 22 2016 06:56
@ndburrus Return Early Pattern for Functions
Norvin Burrus
@ndburrus
May 22 2016 06:56
@mnjagi whoa.... the function (checkObj) receives input (checkProp). val is set to empty. then a condition evaluates the empty variable?
Michael Njagi
@mnjagi
May 22 2016 06:56
somebody help me out..
Ivan Saveliev
@ivansvlv
May 22 2016 06:56

@tadake for loop starts from initialization, or an existing variable rely on. You've written:

 for(j = 0; j < length; j++)

"j" is not declare anywhere, how program should know what you mean by "j"?
you need to decalre it inside the loop

 for(var j = 0; j < length; j++)
Michael Njagi
@mnjagi
May 22 2016 06:57

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

function checkObj(checkProp) {
  // Your Code Here
 var val="";
if(val=="gift" || val== "pet" || val== "bed")

{console.log( myObj.hasOwnProperty(val));}
 else    console.log("Not Found");


}

// Test your code by modifying these values
checkObj("bed");
Michael Guest
@MichaelGuest
May 22 2016 06:57
@ndburrus how do I set the val?
Ivan Saveliev
@ivansvlv
May 22 2016 06:57
@mnjagi if you translate JS to your own language each step, you will udnerstand what's wrong, right know you logic is absolutely wrong
Michael Guest
@MichaelGuest
May 22 2016 06:58
@isavelyev How do you translate it into your own language?
Michael Njagi
@mnjagi
May 22 2016 06:58
@MichaelGuest i bet you could ask that again..
Ivan Saveliev
@ivansvlv
May 22 2016 06:59
@MichaelGuest have you tried to explain something that you don't udnerstand? just like "Ok, what im doing here, creating a variable that will store something, that make this and that"?
Michael Guest
@MichaelGuest
May 22 2016 06:59
@mnjagi What do u mean by that?
Camille Garcia
@camgarcia53
May 22 2016 06:59
@isavelyev yea it still doesnt pass
Ivan Saveliev
@ivansvlv
May 22 2016 06:59
@MichaelGuest and go step by step, line by line, like debug it :)
Kyle W Pilkinton
@tadake
May 22 2016 06:59
ahh i see! thank you @isavelyev my program still isnt working though. do you have any ideas why??
CamperBot
@camperbot
May 22 2016 06:59
tadake sends brownie points to @isavelyev :sparkles: :thumbsup: :sparkles:
:cookie: 108 | @isavelyev |http://www.freecodecamp.com/isavelyev
Ivan Saveliev
@ivansvlv
May 22 2016 06:59
@camgarcia53 show me code
@tadake show the code
Norvin Burrus
@ndburrus
May 22 2016 07:00
@MichaelGuest sorry, i had an incorrect comment in there (changed recipient).. so michael -we need to work on the correct object...
Michael Guest
@MichaelGuest
May 22 2016 07:00
@isavelyev yeah haha it helps sometimes
Thompson Ike
@hubhubace
May 22 2016 07:00
someone pls help

function abTest(a, b) {
// Only change code below this line

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

Kyle W Pilkinton
@tadake
May 22 2016 07:00
@isavelyev
function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
    var search = Object.getOwnPropertyNames(source); // get propery names of source
    var length = search.length;  // get the number of properties in source

  for(i = 0; i < collection.length;i++){   // for every object in collection

     var matched = 0;
     var missed = 0;

    for(var j = 0; j < length; j++){ // for every property in source
  var cur = source[search];

     if(collection[i].hasOwnProperty(search[j])){
        matched++;
       }
      else{
         missed++;
       }

      if(matched > 0 && missed <= 0){
        arr.push(collection[i]);
      }
 } 
}
  //Only change code above this line
  return arr;
}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Ivan Saveliev
@ivansvlv
May 22 2016 07:01
@tadake check the first loop too :)
Kyle W Pilkinton
@tadake
May 22 2016 07:01
ahhhhhh i did it twice! @isavelyev
Norvin Burrus
@ndburrus
May 22 2016 07:01
@hubhubace ok, this what is needed: "Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined."
Ivan Saveliev
@ivansvlv
May 22 2016 07:01
@tadake yes you did xD
Michael Njagi
@mnjagi
May 22 2016 07:02
@MichaelGuest i mean i ahve the same question as you.how do i translate the javascript into my own language ???
Kyle W Pilkinton
@tadake
May 22 2016 07:02
lol im going to write that down hahahaha
function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
    var search = Object.getOwnPropertyNames(source); // get propery names of source
    var length = search.length;  // get the number of properties in source

  for(var i = 0; i < collection.length;i++){   // for every object in collection

     var matched = 0;
     var missed = 0;

    for(var j = 0; j < length; j++){ // for every property in source
  var cur = source[search];

     if(collection[i].hasOwnProperty(search[j])){
        matched++;
       }
      else{
         missed++;
       }

      if(matched > 0 && missed <= 0){
        arr.push(collection[i]);
      }
 } 
}
  //Only change code above this line
  return arr;
}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Michael Guest
@MichaelGuest
May 22 2016 07:02
@mnjagi nice
Kyle W Pilkinton
@tadake
May 22 2016 07:02
@isavelyev
Michael Njagi
@mnjagi
May 22 2016 07:03
@MichaelGuest have you found the solution to the challenge??
Michael Guest
@MichaelGuest
May 22 2016 07:04
@mnjagi not yet
Ryan
@ispeakcomputer
May 22 2016 07:05
thanks @Rafase282 for your help with Algorithm: Confirm the Ending
CamperBot
@camperbot
May 22 2016 07:05
needsmorecoffee sends brownie points to @rafase282 :sparkles: :thumbsup: :sparkles:
:star2: 1251 | @rafase282 |http://www.freecodecamp.com/rafase282
Ivan Saveliev
@ivansvlv
May 22 2016 07:05

@MichaelGuest chum, try to debug program in your head. What your functions needs? how it should work?

  1. you call it like checkObj("pass property name as argument here");
  2. Now how to say it in JS?:

    function checkObj(checkProp) {
    
    if(checkObj.hasOwnProperty(YOU NEED TO PASS ARGUMENT TO THE FUNCTION " HAS OWN PROPERTY")){
       return SOMETHING THAT YOU WANT IF TRUE
      }
man i literally wrote down the solution right now, and it was done before already
Kyle W Pilkinton
@tadake
May 22 2016 07:06
do you see anymore problems @isavelyev ?????
Ivan Saveliev
@ivansvlv
May 22 2016 07:06
lemme check
Norvin Burrus
@ndburrus
May 22 2016 07:07
@MichaelGuest did you sort out which objects to work on?
Ivan Saveliev
@ivansvlv
May 22 2016 07:07
@tadake can you give the link or name of the task, so i know what you try to achieve
pls
Mohammed Ismail
@ikismail
May 22 2016 07:07
var myStr = "Iam a \"double quoted\" string inside \"double quotes\""; // Change this line
Michael Njagi
@mnjagi
May 22 2016 07:08
anyone please???
Norvin Burrus
@ndburrus
May 22 2016 07:08
@ikismail which challenge is this?
Mohammed Ismail
@ikismail
May 22 2016 07:08
how can i change it to ----I am a "double quoted" string inside "double
Escaping Literal Quotes in Strings @ndburrus
Ivan Saveliev
@ivansvlv
May 22 2016 07:09
@mnjagi friend, don't seek the solution from others without enough efforts given to solve it
Ivan Saveliev
@ivansvlv
May 22 2016 07:09
re-read the task, if needed go back and re-read previouis material and you will get it
that's how you become better
Mohammed Ismail
@ikismail
May 22 2016 07:10
@ndburrus ????
Norvin Burrus
@ndburrus
May 22 2016 07:10
@ikismail ok, this is where you're at "Use backslashes to assign a string to the myStr variable so that if you were to print it to the console, you would see:".... can you do this?
Michael Njagi
@mnjagi
May 22 2016 07:11
@isavelyev dont say that please...i have spent more than an hour trying to figure it out before requesting for help.
darrenbachan
@darrenbachan
May 22 2016 07:12
Can someone give me a hand

// Example
var changed = 0;

function change(num) {
return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 0;

function process(num) {
return (num + 3) / 5;
}

// Only change code below this line

processed = process(7);

but it says I need to assign processArg to processed
Norvin Burrus
@ndburrus
May 22 2016 07:13
@darrenbachan carefully re-read this part: "Call the processArg function"
Mohammed Ismail
@ikismail
May 22 2016 07:13
can you give me the correct code @ndburrus