These are chat archives for FreeCodeCamp/HelpJavaScript

27th
Apr 2017
intcreate
@intcreate
Apr 27 2017 00:00
i cant use if else statement
Stephen James
@sjames1958gm
Apr 27 2017 00:00
@jgutierrez710
You can assign a variable to a new value using =
don't use var
Kat Jin
@qifanj
Apr 27 2017 00:00
@sjames1958gm make sense, thank you!
CamperBot
@camperbot
Apr 27 2017 00:00
qifanj sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: qifanj already gave sjames1958gm points
Stephen James
@sjames1958gm
Apr 27 2017 00:00
@intcreate a < b is boolean so just like you can return true or return false you can return a < b;
intcreate
@intcreate
Apr 27 2017 00:00
oh
thanks @sjames1958gm
CamperBot
@camperbot
Apr 27 2017 00:02
intcreate sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6998 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Jorge
@jgutierrez710
Apr 27 2017 00:02
@sjames1958gm would I use a space to separate it from the 2 ?
Ian V.
@jansolote
Apr 27 2017 00:02
hi, how can i use .push function into a multi-simensional array?
Stephen James
@sjames1958gm
Apr 27 2017 00:02
@intcreate :+1:
Jorge
@jgutierrez710
Apr 27 2017 00:02

// Setup
var a = 7;
var b = 2;

// Only change code below this line

Stephen James
@sjames1958gm
Apr 27 2017 00:03
@jgutierrez710 Don't change above the comment
You can do
var x;
then
x = 10;
or
x = 20;
that is why they are variables - because they can vary
@jgutierrez710 so below that comment line assign 7 as a new value of a
Then assign a as a new value of b
Gulsvi
@gulsvi
Apr 27 2017 00:06
@jansolote
var arr = [[1,2],[3,4]];
arr[1].push(5) // [[1, 2], [3, 4, 5]]
Ian V.
@jansolote
Apr 27 2017 00:06
@SkyCoder01
@SkyCoder01 Thanks a lot
CamperBot
@camperbot
Apr 27 2017 00:06
jansolote sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:star2: 1201 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Gulsvi
@gulsvi
Apr 27 2017 00:07
No problem
Jorge
@jgutierrez710
Apr 27 2017 00:07
@sjames1958gm thanks that made a lot more sense than what the instructions were telling me!
CamperBot
@camperbot
Apr 27 2017 00:07
jgutierrez710 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6999 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 27 2017 00:08
@jgutierrez710 :+1:
@jgutierrez710 The wording is bad in that challenge.
Denis McDonald
@denismcdonald
Apr 27 2017 00:08
Hi everybody. I'm just on the Caesars Cipher challenge, and while my solution works in Sublime, for example, it's not getting past the challenge's tests, and I'm not sure why (even after reading a few github issues as regards the challenge). I don't suppose anyone with fresh eyes might be able to spot where I've gone wrong? (And bear with me if this isn't the most elegant solution.)
var asciiArray = [];
var midArray = [];
var asciiString = "";
var output = "";

function rot13(str) {

for (var i = 0; i < str.length; i++) {
    asciiArray.push(str.charCodeAt(i)); 
    asciiString = String.fromCharCode(asciiArray[i]);
    if (asciiString.charCodeAt(0) === 32 || 
        asciiString.charCodeAt(0) === 33 ||
        asciiString.charCodeAt(0) === 46 ||
        asciiString.charCodeAt(0) === 63) {
        midArray.push(asciiString.charCodeAt(0));
    } else if (asciiString.charCodeAt(0) < 78) {
        midArray.push(asciiString.charCodeAt(0) + 13);
    } else if (asciiString.charCodeAt(0) >= 78) {
        midArray.push(asciiString.charCodeAt(0) - 13);
    }
    output += String.fromCharCode(midArray[i]);
}
return output;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Stephen James
@sjames1958gm
Apr 27 2017 00:10
@denismcdonald In FCC you cannot use globals as they do not get reset between tests.
Denis McDonald
@denismcdonald
Apr 27 2017 00:11
@sjames1958gm Oh, so all my variables need to be defined within the function?
Stephen James
@sjames1958gm
Apr 27 2017 00:11
@denismcdonald Yes.
Denis McDonald
@denismcdonald
Apr 27 2017 00:12
Ah. Whoops. Many thanks, Stephen. I appreciate it.
Stephen James
@sjames1958gm
Apr 27 2017 00:12
@denismcdonald :+1:
@denismcdonald All those intermediate arrays/strings are not really needed -
var char = str.charCodeAt(i);
then operate on char in the middle (add 13 , subtract 13 - do nothing)
then at the end
output += String.fromCharCode(char);
Denis McDonald
@denismcdonald
Apr 27 2017 00:16
I'm indebted for this, @sjames1958gm I was suspecting there might be some redundancy in what I had going on (but, frankly, I was just overjoyed I got the thing to work - and, indeed, with your help, it just passed the tests). I'm going to copy what you've written and go study over it.
Stephen James
@sjames1958gm
Apr 27 2017 00:17
@denismcdonald :+1: my strategy is to get your algorithm working then suggest changes
Denis McDonald
@denismcdonald
Apr 27 2017 00:18
@sjames1958gm I like that approach, too. At least, it's less demoralising that way! (ie, seeing some results, then refining.)
Stephen James
@sjames1958gm
Apr 27 2017 00:18
@denismcdonald :)
Keon Samuel
@keonsam
Apr 27 2017 00:21
whats popping?
intcreate
@intcreate
Apr 27 2017 00:25

// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a || b < 0) {
    return;
  }


  // Only change code above this line

  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
can any1 help me with this one
Keon Samuel
@keonsam
Apr 27 2017 00:26
if (a<0 || b <0)
return undefined;
intcreate
@intcreate
Apr 27 2017 00:27
thanks @keonsam
CamperBot
@camperbot
Apr 27 2017 00:27
intcreate sends brownie points to @keonsam :sparkles: :thumbsup: :sparkles:
:cookie: 342 | @keonsam |http://www.freecodecamp.com/keonsam
Ryan Nelson
@iamryandnelson
Apr 27 2017 00:30
Hi there, can someone take a look at the jQuery/JavaScript in my Twitch.tv pen. I'm not sure what I'm doing wrong...http://codepen.io/iamryandnelson/pen/vmXzXz?editors=1111
Keon Samuel
@keonsam
Apr 27 2017 00:33
what part?
Gulsvi
@gulsvi
Apr 27 2017 00:34
@iamryandnelson Your url should be url: makeURL(account), and you don't appear to be calling the getAccountInfo() function to make the API calls.
Keon Samuel
@keonsam
Apr 27 2017 00:35
sky we cool?
Ryan Nelson
@iamryandnelson
Apr 27 2017 00:37
@SkyCoder01 Where should I call getAccountInfo()?
jump020305
@jump020305
Apr 27 2017 00:37
  • I created arrow images using css.
  • but the problem is i need to add the .down-arrow class to the div when the accordion opens up.
  • right now I added one image but not sure how to add the other image.
  • can you guys tell me how to fix it
  • providing my code below
  • working fiddle http://jsfiddle.net/b4L6kyg4/26/
.down-arrow {
    -ms-transform: rotate(-55deg);
    transform: rotate(-55deg);
}

.up-arrow {
    border-top: .33em solid red;
    border-right: .33em solid red;
    border-bottom: 0;
    border-left: 0;
    width: .9em;
    height: .9em;
    -ms-flex-item-align: center;
    -ms-grid-row-align: center;
    align-self: center;
    transition: all .7s ease;
    -ms-transform: rotate(129deg);
    transform: rotate(129deg);
}
Gulsvi
@gulsvi
Apr 27 2017 00:38
@iamryandnelson Your document.ready function would be a good place to have it, but it should work anywhere
Spyrantis Theodoros
@thodorisanta
Apr 27 2017 00:39
i just finished with the 2 player mode on tic tac toe. Any tips or ideas on how i should do the player vs AI ? cause i have completely no clue :/
Joseph
@revisualize
Apr 27 2017 00:40
Hello.
Keon Samuel
@keonsam
Apr 27 2017 00:40
that is the easy part.
Somia ♡
@somiajagadish
Apr 27 2017 00:40
Hi, I've been at this problem for days and I have no idea whats wrong with it

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

/if (val === "bob") {
answer = "Marley";
} else if (val === 42) {
answer = "The Answer";
} else if (val === 1) {
answer = "There is no #1";
} else if (val === 99) {
answer = "Missed me by this much!";
} else if (val === 7) {
answer = "Ate Nine";
}
/

switch(val){
case 1:
  answer = "Marley";
  break;
case 2:
  answer = "The Answer";
  break;
  case 3:
  answer = "There is no #1";
  break;
case 4:
  answer = "Missed me by this much!";
  break;
case 5:
  answer = "Ate Nine";

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

// Change this value to test
chainToSwitch(7);

Joseph
@revisualize
Apr 27 2017 00:41
@somiajagadish Do you have a trailing }for your switch?
Stephen James
@sjames1958gm
Apr 27 2017 00:41
@somiajagadish The case values are not all numbers look at the val === values
intcreate
@intcreate
Apr 27 2017 00:41
function cc(card) {
  // Only change code below this line
  if (card >= 2 && card <= 6) {
    return '5 Bet';
  } else if (card >=7 && card <= 9) {
    return '0 Hold';
  } else if (card === 10, 'J', 'Q', 'K', 'A') {
    return '-5 Hold';
  } else if (card === 3, 7, 'Q', 8, 'A'|| card === 3, 2, 'A', 10, 'K') {
    return '-1 Hold';
  } else if (card === 2, 'J', 9, 2, 7 || card === 2, 2, 10) {
    return '1 Bet';
  }



  return "Change Me";
  // Only change code above this line
}

Cards Sequence 2, 3, 4, 5, 6 should return "5 Bet"
Cards Sequence 7, 8, 9 should return "0 Hold"
Cards Sequence 10, J, Q, K, A should return "-5 Hold"
Cards Sequence 3, 7, Q, 8, A should return "-1 Hold"
Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Cards Sequence 2, 2, 10 should return "1 Bet"
Cards Sequence 3, 2, A, 10, K should return "-1 Hold"

can any1 help me with this

Joseph
@revisualize
Apr 27 2017 00:42
@intcreate Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
...
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
...
...
Things to note: You should NOT be returning based on the value of the card. The value of card should only be adding or subtracting 1 from the global variable count.
The value of the global variable count is used to determine the return statement.
Stephen James
@sjames1958gm
Apr 27 2017 00:42
@intcreate You need to re-read the instructions.
you change count based on card
then you return Bet or Hold based on count value
Keon Samuel
@keonsam
Apr 27 2017 00:42
use a switch for that.
switch statement
Joseph
@revisualize
Apr 27 2017 00:42
@intcreate Your if conditions are completely incorrect too.
Somia ♡
@somiajagadish
Apr 27 2017 00:42
@revisualize @sjames1958gm NO!! I forgot the ending }
Joseph
@revisualize
Apr 27 2017 00:43

How to write an if conditional statements with OR and AND operators:
I am seeing a large number of people writing if conditions using OR and AND operators incorrectly.
Here is an example of what I'm seeing:

if (param1 == "a" || "c" || "e") { // incorrect
   var output = "Odd lowercase alpha character"; 
}

What I think people think is that it will compare param1 to "a" then compare param1 to "c" then compare param1 to "e"
However, that's not actually what the computer is processing.

if conditions need to be evaluated to true for the if statement to run:

if ((condition1) || (condition2) || (condition3) {
    // true statement
}

And how we would code that up from our example above where we're trying to get the odd character from a parameter (param1):

if (param1 == "a" || param1 == "c" || param1 == "e") {
   var output = "Odd lowercase alpha character"; 
}

I'm also seeing people writing and statements like this:

if (param1 == "a" && param1 == "e") {
}

The problem with this is the fact that a variable can't really be two strings or two different numbers at the same time.

Stephen James
@sjames1958gm
Apr 27 2017 00:43
@somiajagadish Your first case should be case "bob": the others can be taken from the original code.
Joseph
@revisualize
Apr 27 2017 00:43
@somiajagadish Solve it?
Keon Samuel
@keonsam
Apr 27 2017 00:44
switch (card){
 case 2:
case 3:
case 4:
case 5:
case 6:
count++;

}
who next?
Somia ♡
@somiajagadish
Apr 27 2017 00:46
@revisualize @sjames1958gm no it's still saying its wrong and @sjames1958gm can you explain it?
Stephen James
@sjames1958gm
Apr 27 2017 00:47

@somiajagadish The original code was

if (val === "bob") {
answer = "Marley";

so the case should be

   case "bob":
     answer = "Marley";
Keon Samuel
@keonsam
Apr 27 2017 00:48
switch (val){
case "bob":
answer = "Marley";
break;
}
Somia ♡
@somiajagadish
Apr 27 2017 00:48
@sjames1958gm OH OH MY GOD THANK YOU SO MUCH!
CamperBot
@camperbot
Apr 27 2017 00:48
somiajagadish sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7000 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 27 2017 00:48
@somiajagadish :+1:
7K
Keon Samuel
@keonsam
Apr 27 2017 00:48
congratz
Joseph
@revisualize
Apr 27 2017 00:48
@sjames1958gm

7000!!!!!!!!!!!!!!!!

Stephen James
@sjames1958gm
Apr 27 2017 00:48
@keonsam @revisualize thx
CamperBot
@camperbot
Apr 27 2017 00:49
sjames1958gm sends brownie points to @keonsam and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 343 | @keonsam |http://www.freecodecamp.com/keonsam
:star2: 3834 | @revisualize |http://www.freecodecamp.com/revisualize
Keon Samuel
@keonsam
Apr 27 2017 00:49
what do you get for that?
Somia ♡
@somiajagadish
Apr 27 2017 00:49

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

/if (val === "bob") {
answer = "Marley";
} else if (val === 42) {
answer = "The Answer";
} else if (val === 1) {
answer = "There is no #1";
} else if (val === 99) {
answer = "Missed me by this much!";
} else if (val === 7) {
answer = "Ate Nine";
}
/

switch(val){
case "bob":
  answer = "Marley";
  break;
case 42:
  answer = "The Answer";
  break;
  case 1:
  answer = "There is no #1";
  break;
case 99:
  answer = "Missed me by this much!";
  break;
case 7:
  answer = "Ate Nine";
}

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

// Change this value to test
chainToSwitch(7);

it still says its wrong
Joseph
@revisualize
Apr 27 2017 00:49
@keonsam A crisp high five
Austin Wiggins
@austinwiggins
Apr 27 2017 00:49
congratulations @sjames1958gm :D :D :D Great job!
Joseph
@revisualize
Apr 27 2017 00:50
@somiajagadish The tests for that lesson may require that you remove the if block.
Somia ♡
@somiajagadish
Apr 27 2017 00:53
okay i'll try @revisualize
@revisualize OHH THANKS SO MUCH!
CamperBot
@camperbot
Apr 27 2017 00:54
somiajagadish sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3835 | @revisualize |http://www.freecodecamp.com/revisualize
aRtoo
@artoodeeto
Apr 27 2017 00:59
hi everyone. question. can should i use 'hasOwnProperty'? or could i do it like this??
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },

    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },]

function lookUpProfile(firstName){
// Only change code below this line

        if(contacts[0].firstName == firstName){
          console.log("TRUE");
        }else {
          console.log("tasddasdadsadf");
        }




// Only change code above this line
}
anderson
@anderson2825
Apr 27 2017 01:00
hi,guys! Good morning!
JDW
@jd-wheaton
Apr 27 2017 01:01
Does anyone ever have the feeling like they have done this before?
LiWen
@memory713
Apr 27 2017 01:01
good morning
what feeling?
JDW
@jd-wheaton
Apr 27 2017 01:04
Like any little moment in life. I just had the strangest feeling of dejavu, that I was sitting here, typing what I just typed.
hekri-d
@hekri-d
Apr 27 2017 01:04
@jd-wheaton when I 've had a few joints in a row I get all sorts of feelings.
xwmaxx
@xwmaxx
Apr 27 2017 01:04
hey guys&gals, I need help with the Counting Cards problem. I know I can probably find the answer somewhere on the forums but I actually want to learn why I am doing this wrong if someone can point me in the right direction that would be great.
JDW
@jd-wheaton
Apr 27 2017 01:05
and someone brought up smoking cheese
weird right
I've not done any drugs yet today
Have you ever been reading SemanticUI documentation, and felt like, if I had written this, it would be easier to follow?
RonnyNovik
@RonnyNovik
Apr 27 2017 01:06
hey guys please help me out here it doesn't toggle
xwmaxx
@xwmaxx
Apr 27 2017 01:06

'''var count = 0;

function cc(card) {
// Only change code below this line
if (card >= 2 && card <= 6) {
count += 1;
return count + " Bet";
} else if (card >= 7 && card <= 9) {
count += 0;
return count + " Hold";
} else if (card = 10, 'J', 'Q', 'K', 'A') {
count -= 1;
return count + " Hold";
}

return "Change Me";
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc('J'); cc(9); cc(2); cc(7);
'''
anyone know why this isn't working?

CamperBot
@camperbot
Apr 27 2017 01:06
:bulb: to format code use backticks! ``` more info
JDW
@jd-wheaton
Apr 27 2017 01:06
Didn't know when to 'fold 'em'
-or- when to 'hold 'em'
-or- when to 'run'
Sorry I'll stop now. Apparently I need to take my medication.
xwmaxx
@xwmaxx
Apr 27 2017 01:08
var count = 0;

function cc(card) {
  // Only change code below this line
  if (card >= 2 && card <= 6) {
    count += 1;
    return count + " Bet";
  } else if (card >= 7 && card <= 9) {
    count += 0;
    return count + " Hold";
  } else if (card = 10, 'J', 'Q', 'K', 'A') {
    count -= 1;
    return count + " Hold";
  }

  return "Change Me";
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc('J'); cc(9); cc(2); cc(7);
Joseph
@revisualize
Apr 27 2017 01:09
@xwmaxx Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
...
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
...
...
Things to note: You should NOT be returning based on the value of the card. The value of card should only be adding or subtracting 1 from the global variable count.
The value of the global variable count is used to determine the return statement.
JDW
@jd-wheaton
Apr 27 2017 01:09
your only returning a string with the contents of "Change me"
DistinctWolf
@DistinctWolf
Apr 27 2017 01:10

function translatePigLatin(str) {
var arr=str.split('');
  var vowels=['a','e','i','o','u'];
    for(var i=0;i<arr.length;i++){
      if(vowels.includes(arr[0])){
        return str+'way';
      }
       else if(!vowels.includes(arr[i])){
         var index=arr.indexOf(arr[i]);
        var sliced=arr.slice(arr.indexOf(arr[i]));
        var before=arr.slice(0,arr.indexOf(arr[i]));
      return sliced.join('')+before+'ay';
      }

    }



}
translatePigLatin("eight");
I can't get this to work please help
Joseph
@revisualize
Apr 27 2017 01:10
@jd-wheaton There are 3 other return statements.
JDW
@jd-wheaton
Apr 27 2017 01:10
@revisualize snicker
Enric Llopis Fabra
@qiqete
Apr 27 2017 01:11
Why doesnt sum1 return anything?
    var sum1;
    for (var i = 0 ; i < a.length ; i++){
        for ( var j = 0 ; i < a[i].length ; j++){
            if(i === j){
                sum1 = sum1 + a[i][j];
            }
        }
    }
    console.log(sum1);
JDW
@jd-wheaton
Apr 27 2017 01:11
you aren't returning anything
logging to console doesn't return a value
xwmaxx
@xwmaxx
Apr 27 2017 01:11
ah ok thanks Joseph@revisualize
hekri-d
@hekri-d
Apr 27 2017 01:12
@jd-wheaton nice profile pic. I like. :+1:
Joseph
@revisualize
Apr 27 2017 01:12
@qiqete What is your a?
Enric Llopis Fabra
@qiqete
Apr 27 2017 01:12
@jd-wheaton imagine it's return sum1 and a is a 2dArray
JDW
@jd-wheaton
Apr 27 2017 01:13
Yes, I like the story of Vlad
Joseph
@revisualize
Apr 27 2017 01:13
@qiqete What is a?
Keon Samuel
@keonsam
Apr 27 2017 01:13
Vue.js vs react?
JDW
@jd-wheaton
Apr 27 2017 01:14
@keonsam Angular.io
yofri
@yofriadi
Apr 27 2017 01:14
guys im doing mutations challenge, how to sort the string alphabetically, because .sort() is array method
function mutation(arr) {
  var newArr = arr.join().toLowerCase().split(",").sort();
  return newArr[0].indexOf(newArr[1]) !== -1;
}

mutation(["Mary", "Army"]);
Joseph
@revisualize
Apr 27 2017 01:14
Vanilla JS!
Enric Llopis Fabra
@qiqete
Apr 27 2017 01:14
var a = []
    var sum1;
    for (var i = 0 ; i < a.length ; i++){
        for ( var j = 0 ; i < a[i].length ; j++){
            if(i === j){
                sum1 = sum1 + a[i][j];
            }
        }
    }
    return sum1;
JDW
@jd-wheaton
Apr 27 2017 01:14
@Yofri Yeah, strings are immutable, so you have to work with the array
Joseph
@revisualize
Apr 27 2017 01:14
@qiqete Of course sum1 isn't anything.
The for loop never runs.
yofri
@yofriadi
Apr 27 2017 01:15
@jd-wheaton oh damn youre right, then how to solve this haha
Abdullah-Al-Zubair
@a2-zubair
Apr 27 2017 01:16
need help to understand the object lookup table task?
Enric Llopis Fabra
@qiqete
Apr 27 2017 01:17
Why sum1 doesnt return anything? better? hahaha
var a = [[1,2,3],[1,2,3],[1,2,3]];
    var sum1;
    for (var i = 0 ; i < a.length ; i++){
        for ( var j = 0 ; i < a[i].length ; j++){
            if(i === j){
                sum1 = sum1 + a[i][j];
            }
        }
    }
    return sum1;
hekri-d
@hekri-d
Apr 27 2017 01:17
@a2-zubair with what exactly?
@qiqete what are you trying to do?
JDW
@jd-wheaton
Apr 27 2017 01:18
@qiqete sum1 isn't set to anthing
@qiqete set sum1 = what var a is
Joseph
@revisualize
Apr 27 2017 01:19
@qiqete try setting var sum1 = 0;
DistinctWolf
@DistinctWolf
Apr 27 2017 01:19
@qiqete you have an infinite loop that will crash your browser
JDW
@jd-wheaton
Apr 27 2017 01:19
still unclear what he's doing
hekri-d
@hekri-d
Apr 27 2017 01:19
@jd-wheaton Not sure but he might be trying to create an array with distinct elements from the given arrays.
Enric Llopis Fabra
@qiqete
Apr 27 2017 01:20
@revisualize Doesn't result @jd-wheaton I'm summing the diagonal members of an array.
hekri-d
@hekri-d
Apr 27 2017 01:20
if i'm correct then putting sum1=sum1... won't do anything good
Abdullah-Al-Zubair
@a2-zubair
Apr 27 2017 01:20
@hekri-d i can not understand the object lookup system and the task to be asked. how can i change the switch statements into lookup object?
Joseph
@revisualize
Apr 27 2017 01:20
@qiqete for ( var j = 0 ; i < a[i].length; j++){ ... i < in a j loop?
Enric Llopis Fabra
@qiqete
Apr 27 2017 01:21
@revisualize whoooops! hahaha thanks
CamperBot
@camperbot
Apr 27 2017 01:21
qiqete sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3836 | @revisualize |http://www.freecodecamp.com/revisualize
Enric Llopis Fabra
@qiqete
Apr 27 2017 01:22
@revisualize Still not getting a value for sum1, xD
Joseph
@revisualize
Apr 27 2017 01:23
@qiqete Did you set sum1 to be 0 instead of undefined?
@qiqete Because, I got it to work
var a = [[1,2,3],[1,2,3],[1,2,3]];
    var sum1 = 0;
    for (var i = 0 ; i < a.length ; i++){
        for ( var j = 0 ; j < a[i].length; j++){
            if(i === j){
                sum1 = sum1 + a[i][j];
            }
        }
    }
console.log(sum1);
Enric Llopis Fabra
@qiqete
Apr 27 2017 01:23
@revisualize Many Many Many THANKS!
CamperBot
@camperbot
Apr 27 2017 01:23
qiqete sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: qiqete already gave revisualize points
Ryan Nelson
@iamryandnelson
Apr 27 2017 01:24
@SkyCoder01 Hey Sky, can take a look at my pen again. I tried to simplify everything and do just one so I can better understand where I'm going, but I'm still not able to make it work. Any idea why? http://codepen.io/iamryandnelson/pen/vmXzXz?editors=1011
Enric Llopis Fabra
@qiqete
Apr 27 2017 01:24
<3 you Joseph!
DistinctWolf
@DistinctWolf
Apr 27 2017 01:25
function translatePigLatin(str) {
var arr=str.split('');
  var vowels=['a','e','i','o','u'];
    for(var i=0;i<arr.length;i++){
      if(vowels.includes(arr[0])){
        return str+'way';
      }
       else if(!vowels.includes(arr[i])){
         var index=arr.indexOf(arr[i]);
        var sliced=arr.slice(arr.indexOf(arr[i]));
        var before=arr.slice(0,arr.indexOf(arr[i]));
      return sliced.join('')+before+'ay';
      }
    }
translatePigLatin('eight');
can you help me with this ?
Gulsvi
@gulsvi
Apr 27 2017 01:26
@iamryandnelson You have code that parses the channels endpoint, but you're calling the streams endpoint. Do a console.log(data1) as the first line of your success function and you'll see what data is coming back.
keep in mind, different users may have different data on each endpoint,s so a logo may not exist for everyone
JDW
@jd-wheaton
Apr 27 2017 01:27
Anyone here do any Angular?
I'm curious if I can put an ngIf inside a CSS class defininition for an HTML element.
So I can add a class while lets say a boolean of "loading" is set to true.
hollodesign
@hollodesign
Apr 27 2017 01:30

Hello. Can someone help me with this "Convert Celsius to Fahrenheit" test?

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

// Change the inputs below to test your code
convertToF(30);

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
DistinctWolf
@DistinctWolf
Apr 27 2017 01:33
@hollodesign set fahrenheit to celsius times 9/5 and add 32
Gabe Rotberg
@grotberg
Apr 27 2017 01:35
@jd-wheaton I believe you'll want to check out ng-class to modify classes like that using angular
hollodesign
@hollodesign
Apr 27 2017 01:36
thanks @FlashHero
CamperBot
@camperbot
Apr 27 2017 01:36
hollodesign sends brownie points to @flashhero :sparkles: :thumbsup: :sparkles:
:cookie: 171 | @flashhero |http://www.freecodecamp.com/flashhero
hekri-d
@hekri-d
Apr 27 2017 01:43
@hollodesign what;s the problem?
JDW
@jd-wheaton
Apr 27 2017 01:44
@grotberg I looked at ng-class last night, I was fairly convinced it wouldn't do what I just described
I'm using semantic ui and want to add a "loading" class to a search box, whilst the search is running, indicated by a boolean
Alexx Martínez
@AlexxMart
Apr 27 2017 01:46

I'm stuck in the lesson "Local Scope and Functions".

My code:

function myLocalScope() {
var myVar = 'use strict';

console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

hekri-d
@hekri-d
Apr 27 2017 01:46
@AlexxMart what's the problem?
JDW
@jd-wheaton
Apr 27 2017 01:46
@grotberg I'll just try it out and see if it works
Alexx Martínez
@AlexxMart
Apr 27 2017 01:47
is not letting me go through
@hekri-d is just not moving to the next lesson
hekri-d
@hekri-d
Apr 27 2017 01:47
@AlexxMart OK. And what does it say? Why won't it let you go through?
Alexx Martínez
@AlexxMart
Apr 27 2017 01:48
@hekri-d it should give some instructions on the console result, but it just says "myVar not defined"
@hekri-d the lesson just says to declare a variable myVar inside myLocalScope
hekri-d
@hekri-d
Apr 27 2017 01:49
@AlexxMart then do it. Declare a variable myVar inside your local scope
@AlexxMart you haven't so far.
Alexx Martínez
@AlexxMart
Apr 27 2017 01:50

@hekri-d this is what I died, 'use strict' was already there:

function myLocalScope() {
var myVar = 'use strict';

console.log(myVar);
}

hekri-d
@hekri-d
Apr 27 2017 01:52
@AlexxMart do the instructions say anything to what to set the myVar variable? Or post the whole code with instructions here but please format it first with ``` at the beginning and end
Abdullah-Al-Zubair
@a2-zubair
Apr 27 2017 01:53
can anyone help me to understand why don't object dot notation is not work for this "using objects for looksup" task?
Alexx Martínez
@AlexxMart
Apr 27 2017 01:53

@hekri-d the lesson instructions say: "Declare a local variable myVar inside myLocalScope. Run the tests and then follow the instructions commented out in the editor."

my code: Declare a local variable myVar inside myLocalScope. Run the tests and then follow the instructions commented out in the editor.

hekri-d
@hekri-d
Apr 27 2017 01:53
@a2-zubair post the code somewhere and let us see if we can help you.
Christopher McCormack
@cmccormack
Apr 27 2017 01:54
@a2-zubair Dot notation only works if the property has the same name in the object - if you're referencing using a variable, make sure you're using [] bracket notation
hekri-d
@hekri-d
Apr 27 2017 01:54
@AlexxMart ok. And what do the commented out instructions say?
Abdullah-Al-Zubair
@a2-zubair
Apr 27 2017 01:55
@cmccormack thanks. i get my answer @hekri-d
CamperBot
@camperbot
Apr 27 2017 01:55
a2-zubair sends brownie points to @cmccormack and @hekri-d :sparkles: :thumbsup: :sparkles:
:cookie: 325 | @hekri-d |http://www.freecodecamp.com/hekri-d
:cookie: 435 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Apr 27 2017 01:55
@a2-zubair np
JDW
@jd-wheaton
Apr 27 2017 02:01
@grotberg It looks like ng-class is the right way to do it, but I don't understand the developer notes on the usage
<some-element [ngClass]="'first second'">...</some-element>
<some-element [ngClass]="['first', 'second']">...</some-element>
<some-element [ngClass]="{'first': true, 'second': true, 'third': false}">...</some-element>
<some-element [ngClass]="stringExp|arrayExp|objExp">...</some-element>
<some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
that is bad documentation
Like in the last example, what is being tested?
Ralem Eomhd
@Korrah
Apr 27 2017 02:05
var lastName = "Tavor"; var thirdLetterOfLastName = lastName [2];
I got v for the third letter
but what does it mean when it asks "You should use bracket notation"?
hekri-d
@hekri-d
Apr 27 2017 02:06
@Korrah do you know what a bracket is? Genuuine question.
JDW
@jd-wheaton
Apr 27 2017 02:06
@Korrah because that's how you access position 3 of an array
array's are zero indexed
Ralem Eomhd
@Korrah
Apr 27 2017 02:07
@hekri-d I do, it's the [], but I'm pretty dumb, since I had a space there when there shouldn't had been one, so now it passed me
Sorry XD
hekri-d
@hekri-d
Apr 27 2017 02:07
the space has to go
ok you got it. Nice
Ralem Eomhd
@Korrah
Apr 27 2017 02:07
Always the little things that can get me ha
Kyle Janka
@KTJanka
Apr 27 2017 02:08
Does JavaScript ever get easier lol?
Ralem Eomhd
@Korrah
Apr 27 2017 02:08
Thank you for the help
hekri-d
@hekri-d
Apr 27 2017 02:08
@Korrah you're welcome.
@EverythingEpi no. But you get better at it so it seems easier
JDW
@jd-wheaton
Apr 27 2017 02:08
@EverythingEpi It gets easier, then harder again, then much harder, then easier
Kyle Janka
@KTJanka
Apr 27 2017 02:09
So should I just shave my head now? Before I rip my hair out? haha
JDW
@jd-wheaton
Apr 27 2017 02:09
and that cycle repeats over and over again, until you achive master jedi status
hekri-d
@hekri-d
Apr 27 2017 02:09
@EverythingEpi of course. That's one of the first steps to javascript. But take a picture first. XD
Kyle Janka
@KTJanka
Apr 27 2017 02:09
Ahahah
I always wondered why so many programmers were bald
JDW
@jd-wheaton
Apr 27 2017 02:09
Day 1, javascripting
1.) Get head shaved
Ralem Eomhd
@Korrah
Apr 27 2017 02:10
@EverythingEpi I'll tell you this. Last year, I stopped FCC when I got to the JS section. Recently, I started Harvard's CS50's course and they get your feet wet with a programming language called C, which is supposed to be the like the mother language of most programs. JS is really similar to C, so after watching a couple of their lectures, JS looks a tad simpler (not SIMPLE SIMPLE, but easier to read prior to me not watching those lectures!)
JDW
@jd-wheaton
Apr 27 2017 02:10
@Korrah C is a remarkably difficult language
hekri-d
@hekri-d
Apr 27 2017 02:11
@jd-wheaton I would strongly disagree.
Ralem Eomhd
@Korrah
Apr 27 2017 02:11
If nothing else, I really recommend taking that course because it really helped me understand some of the logic behind programming
JDW
@jd-wheaton
Apr 27 2017 02:11
@Korrah Nothing, I mean, NOTHING is done for you.
Kyle Janka
@KTJanka
Apr 27 2017 02:11
@Korrah I'll figure out JS no matter what. I am determined to finish this course
JDW
@jd-wheaton
Apr 27 2017 02:11
Yeah, ok, write me up a native C app, any app, that's multithreaded and has good memory management.
Ralem Eomhd
@Korrah
Apr 27 2017 02:12
@jd-wheaton Oh, I'm not saying it's easy. I'm just saying, how they teach C, I finally see the logic that is used behind something like JS for example (declaring variables, loops, etc)
So if you're having trouble with JS, maybe you're hung up on syntax
when you should see the logic behind it
hekri-d
@hekri-d
Apr 27 2017 02:12
@jd-wheaton that's a completely different thing. C is as simple of a prog. language as it gets. Doing stuff with it where things start to get messy
Ralem Eomhd
@Korrah
Apr 27 2017 02:12
if that makes sense
Henry
@GitHub-Henry
Apr 27 2017 02:12
@jd-wheaton my first programming language was assembly, then advanced assembly
JDW
@jd-wheaton
Apr 27 2017 02:13
@GitHub-Henry Only the few the proud the strong, can say that.
Ray
@RayRay97
Apr 27 2017 02:13
function palindrome(str) {
  // Good luck!
  var string1 = str.replace(/[^A-Za-z0-9]/g, "");
  var string2 = string1.toLowerCase().split("").reverse().join("");
  //console.log(string1 + " " + string2);
  if (string2 === string1) {
    //console.log(true);
    return true;
  }
  //console.log(false);
  return false;
}

palindrome("A man, a plan, a canal. Panama");
Why is it not lower casing all the letters?
one of the 'A' remains in upper case
JDW
@jd-wheaton
Apr 27 2017 02:14
@GitHub-Henry what year did you take those classes?
Henry
@GitHub-Henry
Apr 27 2017 02:14
@jd-wheaton it was in the 1990s
hekri-d
@hekri-d
Apr 27 2017 02:15
@GitHub-Henry now here we've got a real badass programmer. Assembly is for the big guys. *Tips hat...
Christopher McCormack
@cmccormack
Apr 27 2017 02:15
@RayRay97 you're not lowercasing string1
Henry
@GitHub-Henry
Apr 27 2017 02:15
@GitHub-Henry the stuff of mainframes
JDW
@jd-wheaton
Apr 27 2017 02:15
@GitHub-Henry I loaded slackware 1.0 and OS2warp server beta the same day in '94.
@GitHub-Henry I think I was, 14 years old.
or 15.
Ray
@RayRay97
Apr 27 2017 02:18
Thanks @cmccormack
CamperBot
@camperbot
Apr 27 2017 02:18
rayray97 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 436 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Apr 27 2017 02:18
@RayRay97 np
Henry
@GitHub-Henry
Apr 27 2017 02:18
@jd-wheaton i was starting college, code, wait overnight, see results
JDW
@jd-wheaton
Apr 27 2017 02:18
@GitHub-Henry and I stand corrected, saying C gives you nothing, is a far cry from assembly.
Ralem Eomhd
@Korrah
Apr 27 2017 02:19
@hekri-d Thanks! (It's been awhile since I've used FFC's chat and forgot to properly thank you so that you get the cookies haha)
CamperBot
@camperbot
Apr 27 2017 02:19
korrah sends brownie points to @hekri-d :sparkles: :thumbsup: :sparkles:
:cookie: 327 | @hekri-d |http://www.freecodecamp.com/hekri-d
hekri-d
@hekri-d
Apr 27 2017 02:19
@Korrah thanks for the cookies. I got some of my own here though. They're making me a bit tipsy. :_
CamperBot
@camperbot
Apr 27 2017 02:19
hekri-d sends brownie points to @korrah :sparkles: :thumbsup: :sparkles:
:cookie: 167 | @korrah |http://www.freecodecamp.com/korrah
Henry
@GitHub-Henry
Apr 27 2017 02:19
@jd-wheaton yeah, C seems like a high level language compared to Assembly
JDW
@jd-wheaton
Apr 27 2017 02:19
@GitHub-Henry I've not done much with IBM zOS machines, I did move one from a Data Center across country by mirroring the storage and bringing it up on the other end but I was just the network guy.
Henry
@GitHub-Henry
Apr 27 2017 02:20
@jd-wheaton i did distributed mainframe programming for several years
JDW
@jd-wheaton
Apr 27 2017 02:20
@GitHub-Henry Well yeah, it is. Linking, object files, all that jazz.
@GitHub-Henry Not many folks can say that either. The place I worked at the time fired their zOS guy cause he was always really mean to the help desk people, I would crack up in my office when he was yelling into his phone at some poor helpdesk guy trying to reset a printer queue.
All that mainframe stuff was super archaic, to my eyes. Sorry guys, I can ping it, the network isn't causing your issue.
Ralem Eomhd
@Korrah
Apr 27 2017 02:23
What is your opinion on concurrently learning C and JavaScript? I'm back on FCC since this C assignment is really difficult for me at the moment, but meanwhile, from the little I've learned of C, I'm doing pretty alright so far in these JS lessons. I'm hoping that what I pick up in JS will make me go, "OH!" for something I'm having trouble with in C, and vice versa
Henry
@GitHub-Henry
Apr 27 2017 02:23
@GitHub-Henry surprisingly finance, health, and auto companies still use mainframe
JDW
@jd-wheaton
Apr 27 2017 02:23
I had to build some SNA crap over IP for the move. Was not fun.
@GitHub-Henry Yes, it was a large hospital I was at
@GitHub-Henry My $1200 GPU has more power than your $1000000 circa y2k mainframe.
Henry
@GitHub-Henry
Apr 27 2017 02:25
@jd-wheaton most phones have more power that was used to go to the moon
JDW
@jd-wheaton
Apr 27 2017 02:25
@GitHub-Henry I know, the pace of technology is hard to wrap ones mind around.
What been done in 50 years, I can't wait to see what the next 50 brings.
Of course that make me almost 90 years old, but hopefully by then I can just upload to the cloud.
hekri-d
@hekri-d
Apr 27 2017 02:27
@jd-wheaton LOL.
Henry
@GitHub-Henry
Apr 27 2017 02:27
@GitHub-Henry with stem cell technology, things will get quite interesting in terms of health care
JDW
@jd-wheaton
Apr 27 2017 02:28
the new amino acids they found in lab mice that reverse aging is where it's at
hekri-d
@hekri-d
Apr 27 2017 02:28
@jd-wheaton it's kinda hard to predict the future on this kind of stuff but I don't think the progress will go on like this for the next 50 years.
JDW
@jd-wheaton
Apr 27 2017 02:28
@hekri-d you never know, we might have a hard take off with AI.
Henry
@GitHub-Henry
Apr 27 2017 02:28
@hekri-d more knowledge leads to more knoweldege
hekri-d
@hekri-d
Apr 27 2017 02:29
@jd-wheaton right. LIke I said really hard to accurately predict the future in this regard.
JDW
@jd-wheaton
Apr 27 2017 02:29
if we have a hard take off with general AI, the world will change faster than we can imagine
hekri-d
@hekri-d
Apr 27 2017 02:29
@GitHub-Henry sure but it's also obvious that it can't go on forever like this.
Henry
@GitHub-Henry
Apr 27 2017 02:29
@jd-wheaton i'm kind of afraid of super smart and capable ai that one day determines that humans are in it's way
JDW
@jd-wheaton
Apr 27 2017 02:30
@GitHub-Henry many people have that same concern, there's 1000's of youtube videos on the subject, on both sides of the fence.
Patrick Koidal
@Koitis
Apr 27 2017 02:30
well, i thought i was doing pretty well up til i hit the JS lessons
JDW
@jd-wheaton
Apr 27 2017 02:30
As much as I enjoyed the Terminator franchise, I don't want a battle for humanity fought against Skynet.
Ralem Eomhd
@Korrah
Apr 27 2017 02:30
@Koitis What's tripping you up?
JDW
@jd-wheaton
Apr 27 2017 02:30
Like your name @Koitis
Patrick Koidal
@Koitis
Apr 27 2017 02:31
nothing in particular, just seems to kinda defy my nascent coding knowledge
not sure if the lessons are less specific
but it asks for a solution and i am completely drawing a blank
before i at least had an idea of what to do when i saw it :P
JDW
@jd-wheaton
Apr 27 2017 02:32
@Koitis well you can't break it, just plunk in some code
Patrick Koidal
@Koitis
Apr 27 2017 02:32
that is my solution so far
only a few lessons in, to be fair
JDW
@jd-wheaton
Apr 27 2017 02:32
that's by far how I've learned
Ralem Eomhd
@Korrah
Apr 27 2017 02:32
@Koitis I strongly recommend checking out Hardvard's CS50's course, like after two lectures, I have a better idea what FCC's lessons on JS are asking
Patrick Koidal
@Koitis
Apr 27 2017 02:32
i do love the a-ha feeling
Gabe Rotberg
@grotberg
Apr 27 2017 02:32
@jd-wheaton did you get your ng-class questions answered yet?
JDW
@jd-wheaton
Apr 27 2017 02:32
Just keep playing with the code, until it makes sense
@grotberg No, their documentation is horrible.
Patrick Koidal
@Koitis
Apr 27 2017 02:33
part of what keeps me coming back to hitting brick walls is the feeling of everything coming together
JDW
@jd-wheaton
Apr 27 2017 02:33
@grotberg The examples that I listed, I don't understand what's being tested?
@grotberg for example:
<some-element [ngClass]="'first second'">...</some-element>
<some-element [ngClass]="['first', 'second']">...</some-element>
<some-element [ngClass]="{'first': true, 'second': true, 'third': false}">...</some-element>
<some-element [ngClass]="stringExp|arrayExp|objExp">...</some-element>
<some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
in that last example, what's being tested?
Gabe Rotberg
@grotberg
Apr 27 2017 02:34
@jd-wheaton ah, I think in that example the "true" statement is where you would drop a conditional or boolean variable
@jd-wheaton so something like ng-class="{'dayclass' : isDayBoolean}"
JDW
@jd-wheaton
Apr 27 2017 02:35
so for me, I do <input class="normal classes here" [ngClass]="{'loading' : loading}">
my boolean is loading, as is the name of the css class I want to use to indicate loading is loading (convienent)
Gabe Rotberg
@grotberg
Apr 27 2017 02:36
@jd-wheaton Yeah, i think so. Although I've never used the [ngClass] notation, and have done it ng-class
JDW
@jd-wheaton
Apr 27 2017 02:36
@grotberg I think you can do it either way
@grotberg it is angular4.x
Gabe Rotberg
@grotberg
Apr 27 2017 02:37
@jd-wheaton to be fair, I haven't played much with angular 4
JDW
@jd-wheaton
Apr 27 2017 02:37
I wrote my wikipedia lookup with it
Henry
@GitHub-Henry
Apr 27 2017 02:37
@grotberg to be fair angular 4 just came out
JDW
@jd-wheaton
Apr 27 2017 02:38
is exactly why I'm using it
I didn't want to learn something that was on the way out
Kingsley
@Kingwindie
Apr 27 2017 02:38
can someone explain to me why the output is 26 printed out 4 times?https://codepen.io/pen/?editors=0010
Gabe Rotberg
@grotberg
Apr 27 2017 02:38
@jd-wheaton OK, in the version I used (3), the order was actually reversed. so it went ng-class="(statment that evaluates to a class string here)"
Adrienne Michelson
@AdriMichelson
Apr 27 2017 02:38
anyone can remember global scope and functions in javascript section of FCC
JDW
@jd-wheaton
Apr 27 2017 02:39
@grotberg awesome, anyway, that does answer my question thank you
CamperBot
@camperbot
Apr 27 2017 02:39
jd-wheaton sends brownie points to @grotberg :sparkles: :thumbsup: :sparkles:
:cookie: 272 | @grotberg |http://www.freecodecamp.com/grotberg
Gabe Rotberg
@grotberg
Apr 27 2017 02:39
@jd-wheaton so in particular, I did things like ng-class="boolean : 'trueclass' ? ' falseclass'"
JDW
@jd-wheaton
Apr 27 2017 02:39
@grotberg understood
Ryan Nelson
@iamryandnelson
Apr 27 2017 02:39
@SkyCoder01 I made the changes and it still doesn't work. I'm really at a loss... I'm only calling FreeCodeCamp and I know all the data I'm asking for is there. Why isn;t it displaying? http://codepen.io/iamryandnelson/pen/vmXzXz?editors=1011
Gabe Rotberg
@grotberg
Apr 27 2017 02:40
@Kingwindie , not sure that link worked
Kingsley
@Kingwindie
Apr 27 2017 02:40
@grotberg give me one sec
Christopher McCormack
@cmccormack
Apr 27 2017 02:42
@iamryandnelson you have a strange quote character in there, may want to look at it. In the HTML you're prepending to #channels
@iamryandnelson I fixed them up and the image and links appeared
Gabe Rotberg
@grotberg
Apr 27 2017 02:43
@Kingwindie OK, when you call the function (addSomething), instead of doing addSomething( num, string) you're sending addSomething(num + string)
@Kingwindie so effectively you're passing "26 26" as the num variable and the logic gets blown after that
JDW
@jd-wheaton
Apr 27 2017 02:43
@iamryandnelson I don't see any on click events
Ryan Nelson
@iamryandnelson
Apr 27 2017 02:44
@cmccormack I don;t see the quote, where is it?
Christopher McCormack
@cmccormack
Apr 27 2017 02:44
@iamryandnelson there are several, look closely - "’ alt=‘’ /></
they may work if they are paired properly, but some are not
iamjoshuacolon
@iamjoshuacolon
Apr 27 2017 02:45
@JLuboff These are my instructions:
Using bracket notation select an element from myArray such that myData is equal to 8.
JDW
@jd-wheaton
Apr 27 2017 02:45
@iamryandnelson nevermind your not quite that far
Ryan Nelson
@iamryandnelson
Apr 27 2017 02:45
@jd-wheaton Was just writing that, lol
iamjoshuacolon
@iamjoshuacolon
Apr 27 2017 02:45
How would I set that up in here?

// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[0][0];

Kingsley
@Kingwindie
Apr 27 2017 02:46
@grotberg @grotberg ok thank you so much,initially i wanted it to write 26 years old but after printing 26 years old it says undefined,so i changed a buch of things,thanks for the tip, have fixed it https://codepen.io/kingwindie/pen/YVNVVM?editors=0010#
CamperBot
@camperbot
Apr 27 2017 02:46
kingwindie sends brownie points to @grotberg :sparkles: :thumbsup: :sparkles:
:cookie: 273 | @grotberg |http://www.freecodecamp.com/grotberg
hekri-d
@hekri-d
Apr 27 2017 02:46
@iamjoshuacolon you need to access a element from the array 'myArray' so that myData is equal to 8
JDW
@jd-wheaton
Apr 27 2017 02:46
@iamryandnelson I don't see a data1.display_name?
hekri-d
@hekri-d
Apr 27 2017 02:47
@iamjoshuacolon arrays indexes start from 0
Gabe Rotberg
@grotberg
Apr 27 2017 02:47
@Kingwindie nice!
JDW
@jd-wheaton
Apr 27 2017 02:47
@iamryandnelson in your console.log
Ryan Nelson
@iamryandnelson
Apr 27 2017 02:47
@jd-wheaton It's there
JDW
@jd-wheaton
Apr 27 2017 02:47
@iamryandnelson gotchya - scrolled up
iamjoshuacolon
@iamjoshuacolon
Apr 27 2017 02:49
@hekri-d Confused about how to set that up...
Ryan Nelson
@iamryandnelson
Apr 27 2017 02:50
@cmccormack Ah! I see! So for href and src you don't need to include the quote marks. Thanks!! :))
CamperBot
@camperbot
Apr 27 2017 02:50
iamryandnelson sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 437 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Apr 27 2017 02:51
@iamryandnelson you need quotes, but you were using some special ones and they don't always match up properly
Ryan Nelson
@iamryandnelson
Apr 27 2017 02:51
@cmccormack 👍🏼
Christopher McCormack
@cmccormack
Apr 27 2017 02:52
@iamryandnelson maybe use '..' instead of ‘..’
hekri-d
@hekri-d
Apr 27 2017 02:52
@iamryandnelson you access the second element of a two dimensional array named someArray = [ [1, 2 .3], [4, 5, 6] ] like this someArray[1][1]
Ryan Nelson
@iamryandnelson
Apr 27 2017 02:53
@hekri-d What's the context?
Ralem Eomhd
@Korrah
Apr 27 2017 02:53
@iamjoshuacolon Okay, first, do you understand that in computer logic, "0" is the starting number? e.g. in this sequence: 1 2 3, the number 1 is considered "0" (the first value in that series)
Second, look how many brackets you have with numbers. [1, 2, 3] [4, 5, 6] [7, 8, 9]. Can you tell me, if you just number the bracket boxes, what bracket box is number 8 in?
hekri-d
@hekri-d
Apr 27 2017 02:53
@iamryandnelson the context of my last comment?
Pagnito
@Pagnito
Apr 27 2017 02:54
this is a lil off course on the fibonacci challenge, but iwas wondering. I figured out how to create the fibonaci algorithm, but i want to create an algorithm that will print out the next number on click not like a loop that prints out all the numbers at once, so im havin trouble coming up with a way that the number would get saved, would i have the interperter look at DOM after every click to see the number printed and use that number?
Ryan Nelson
@iamryandnelson
Apr 27 2017 02:55
@hekri-d What second element of what two dimensional array am I accessing?
Gabe Rotberg
@grotberg
Apr 27 2017 02:56
@Pagnito make a global variable that saves your number. so var savedNumber = 0; outside your click event, and then modify it inside the function
Pagnito
@Pagnito
Apr 27 2017 02:56
@grotberg k thanks, so global variables have that ability basically?
CamperBot
@camperbot
Apr 27 2017 02:56
pagnito sends brownie points to @grotberg :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @grotberg |http://www.freecodecamp.com/grotberg
Christopher McCormack
@cmccormack
Apr 27 2017 02:56
@Pagnito if you just want the next number, bind click to a function and store N and N-1 variables. Update the variables everytime you run the function with the new value as N and the previous value as N-1
hekri-d
@hekri-d
Apr 27 2017 02:57
@iamryandnelson keep that for future refernece. LOL. Sorry man. I mentioned you by mistake trying to help the other guy. It's pretty late here. Sorry
Christopher McCormack
@cmccormack
Apr 27 2017 02:57
@Pagnito when you say look at the DOM do you mean some element you're displaying the value in?
Gabe Rotberg
@grotberg
Apr 27 2017 02:57
@Pagnito yeah, pretty much. the functions should (usually) inherit the scope of the parent. that said, if you declare another var savedNumber inside the function, only that local one will be available...
Ralem Eomhd
@Korrah
Apr 27 2017 02:58
@hekri-d to be fair as well, their names are similar; even I was getting confused distinguishing between the two users lol
Ryan Nelson
@iamryandnelson
Apr 27 2017 02:58
@hekri-d Lol, no worries :). Thanks for the help. Without people like you me and the other guy would be lost, lol.
CamperBot
@camperbot
Apr 27 2017 02:58
iamryandnelson sends brownie points to @hekri-d :sparkles: :thumbsup: :sparkles:
:cookie: 328 | @hekri-d |http://www.freecodecamp.com/hekri-d
stunpop
@stunpop
Apr 27 2017 02:59
confused by this
decrement
anyone to help?
Pagnito
@Pagnito
Apr 27 2017 02:59
@cmccormack im not sure how i wouldve gone about it for this yet, but basically, when i was using ajax, and doing responve design, i needed to reassign ids for screen resize, and i wrapped the click bind in a function that i calledon resize
Ralem Eomhd
@Korrah
Apr 27 2017 02:59
@stunpop It means the value of something is decreasing by 1
Pagnito
@Pagnito
Apr 27 2017 02:59
@Pagnito so i was thinking something like that
stunpop
@stunpop
Apr 27 2017 03:00
@Korrah yes but I have written the solution but seems wrong
I have tried the following:
myvar--; and also tried 11--;
guess I am not understanding
intcreate
@intcreate
Apr 27 2017 03:00

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

// Only change code below this line;
playerNumber = testObj[16];
player = testObj[16];
var playerNumber;       // Change this Line
var player = testObj;   // Change this Line
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
You should be using the variable playerNumber in your bracket notation
can any1 help me with this 1
Ralem Eomhd
@Korrah
Apr 27 2017 03:01
Look how you're writing "myvar" there @stunpop
hekri-d
@hekri-d
Apr 27 2017 03:01
@intcreate change playerNumber like it says.
stunpop
@stunpop
Apr 27 2017 03:01
oh! oops stupid mistake
ok I have corrected that
Ralem Eomhd
@Korrah
Apr 27 2017 03:02
It happens haha.
Ryan Nelson
@iamryandnelson
Apr 27 2017 03:02
@cmccormack LOL! Okay, you're going to laugh. I was using Notepad to write the initial draft of my code and when I copy/pasted it into CodePen the single quote marks written in Notepad were unrecognizable. Thanks for your help :)!
CamperBot
@camperbot
Apr 27 2017 03:02
:warning: iamryandnelson already gave cmccormack points
Christopher McCormack
@cmccormack
Apr 27 2017 03:02
@Pagnito so if you have a function called fibb(), you can just do something like $(element).click(fibb); keep your N and N-1 in variables or an array if you like
CamperBot
@camperbot
Apr 27 2017 03:02
iamryandnelson sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
Ralem Eomhd
@Korrah
Apr 27 2017 03:02
I had a space in my line of code and it wouldn't pass me, understandably
stunpop
@stunpop
Apr 27 2017 03:02
so now I have myVar--; @Korrah
what I am misunderstanding please?
Christopher McCormack
@cmccormack
Apr 27 2017 03:02
@iamryandnelson wow that's strange, glad you figured it out! Windows Notepad?
hekri-d
@hekri-d
Apr 27 2017 03:02
@Korrah yup. That happens with notepad pretty often. Why don't use atom?
Ryan Nelson
@iamryandnelson
Apr 27 2017 03:03
@cmccormack Mac
Christopher McCormack
@cmccormack
Apr 27 2017 03:03
or at least Notepad++ for quick work
Ralem Eomhd
@Korrah
Apr 27 2017 03:03
@stunpop Did it not pass you?
stunpop
@stunpop
Apr 27 2017 03:03
no
Christopher McCormack
@cmccormack
Apr 27 2017 03:03
ah ok
stunpop
@stunpop
Apr 27 2017 03:03
says this " myVar should equal 10 "
as the error
Christopher McCormack
@cmccormack
Apr 27 2017 03:03
well now I know to look for that too!
stunpop
@stunpop
Apr 27 2017 03:03
this is what I have in total:

var myVar = 11;

// Only change code below this line
myVar = myVar - 1;
myVar--;

Ralem Eomhd
@Korrah
Apr 27 2017 03:03
@stunpop Get rid of something
A line should not be there
Pagnito
@Pagnito
Apr 27 2017 03:04
@cmccormack k, thanks
CamperBot
@camperbot
Apr 27 2017 03:04
pagnito sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 438 | @cmccormack |http://www.freecodecamp.com/cmccormack
stunpop
@stunpop
Apr 27 2017 03:04
but it needs to be 2 "--"
intcreate
@intcreate
Apr 27 2017 03:04
@hekri-d it says uu have to use bracket notation for the number how do i do that
hekri-d
@hekri-d
Apr 27 2017 03:05
bracket notation is []
intcreate
@intcreate
Apr 27 2017 03:05
```
hekri-d
@hekri-d
Apr 27 2017 03:05
@intcreate like array[1]
intcreate
@intcreate
Apr 27 2017 03:05

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

// Only change code below this line;


var playerNumber = testObj[16];       // Change this Line
var player = testObj[16];   // Change this Line
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
You should be using the variable playerNumber in your bracket notation
Ralem Eomhd
@Korrah
Apr 27 2017 03:05
@stunpop myVar-- is correct, which means anything else is not needed
intcreate
@intcreate
Apr 27 2017 03:05
thats what i did i used the number 16
Ralem Eomhd
@Korrah
Apr 27 2017 03:05
look what's typed above myVar--;
stunpop
@stunpop
Apr 27 2017 03:06
yes but the instuctions say: Change the code to use the -- operator on myVar.
OH!!
man that was a dumb moment for me
Ralem Eomhd
@Korrah
Apr 27 2017 03:07
@stunpop It's just the lesson trying to make you think; often, it will write incorrect code, prompting you to fix it or remove haha, no worries
stunpop
@stunpop
Apr 27 2017 03:07
@Korrah i was just forgetting that I had to change the code and NOT add more code
Ralem Eomhd
@Korrah
Apr 27 2017 03:07
Correct! :D
stunpop
@stunpop
Apr 27 2017 03:07
so sorry for the stupid quesion! @Korrah bit depressing
thanks for your patience though ;)
Ralem Eomhd
@Korrah
Apr 27 2017 03:08
@stunpop It's all good, it happens to me at times as well
stunpop
@stunpop
Apr 27 2017 03:08
thanks again - will do one more and then time for sleep! Have a good one and THANKS
Ralem Eomhd
@Korrah
Apr 27 2017 03:09
Most welcome, happy coding :smile:
stunpop
@stunpop
Apr 27 2017 03:11
thanks :)
Sarah Charrouf
@sarahcharrouf
Apr 27 2017 03:19
Hi all!
Ralem Eomhd
@Korrah
Apr 27 2017 03:19
Hello!
Sarah Charrouf
@sarahcharrouf
Apr 27 2017 03:19
I'm stuck on the lesson for converting celsius to Fahrenheit. Has anyone had success with this?
Ralem Eomhd
@Korrah
Apr 27 2017 03:19
I have yes
Sarah Charrouf
@sarahcharrouf
Apr 27 2017 03:20
Great!
Ralem Eomhd
@Korrah
Apr 27 2017 03:20
Do you have anything written yet or really unsure of how to approach it?
Sarah Charrouf
@sarahcharrouf
Apr 27 2017 03:20
I'm stuck on how to give convertToF the value of 0, -30, -10, etc
Ralem Eomhd
@Korrah
Apr 27 2017 03:21
Okay, first, we need to focus on your variable (var = fahrenheit)
Sarah Charrouf
@sarahcharrouf
Apr 27 2017 03:21
I'm pretty stuck overall, to be honest.
Erol Aliyev
@erolaliyev
Apr 27 2017 03:21
hi guys!
Sarah Charrouf
@sarahcharrouf
Apr 27 2017 03:22
hi Erol
Erol Aliyev
@erolaliyev
Apr 27 2017 03:22
can anyone help me with profile look up cahllenge?
Sarah Charrouf
@sarahcharrouf
Apr 27 2017 03:22

How does this look, Ralem?

var fahrenheit = var convertToF * 9/5 + 32;

TJ-strange
@TJ-strange
Apr 27 2017 03:23
var fahrenheit = convertToF * 9/5 + 32;
Ken Haduch
@khaduch
Apr 27 2017 03:23
@erolaliyev - what have you got for Profile Lookup?
Ralem Eomhd
@Korrah
Apr 27 2017 03:23
@sarahcharrouf You sorta have the right idea! One thing to consider is that faherenheit has already been declared
basically, no need to write var = fahrenheit again
since it's been "Declared" (defined) already a line above
Erol Aliyev
@erolaliyev
Apr 27 2017 03:24
@khaduch i cannot access objects inside the array
Ken Haduch
@khaduch
Apr 27 2017 03:24
@erolaliyev - can you post the code that you have (not the contacts data, just the function and body of the code that you have)
Ralem Eomhd
@Korrah
Apr 27 2017 03:24
@sarahcharrouf Also, the convertTo is not your focus
Sarah Charrouf
@sarahcharrouf
Apr 27 2017 03:25
@Korrah because it's the function, and not the variable?
Ralem Eomhd
@Korrah
Apr 27 2017 03:25
@sarahcharrouf Right!
Ken Haduch
@khaduch
Apr 27 2017 03:25
@sarahcharrouf - do you know what value is being passed as the function argument?
iamjoshuacolon
@iamjoshuacolon
Apr 27 2017 03:26
@Korrah bracket 3, number 1 in that bracket...
Ken Haduch
@khaduch
Apr 27 2017 03:26
@erolaliyev - you have something there that is on the right track - contacts[i] is definitely the way to access the objects, because they are in an array, and you are generating an index for the array. So that's a good start. The formatting of your code makes it hard to read, though.
Erol Aliyev
@erolaliyev
Apr 27 2017 03:26
@khaduch function lookUpProfile(firstName, prop){
// Only change code below this line
var i = 0;
while (i < 5) {
if(contacts[i].firstName == firstName ) {
if(contacts[i].prop == prop) {
return contacts[i].prop;
}
else {
return "No such property";
}
}
else if (contacts[i].firstName != firstName) {
return "No such contact";
}
i++;
}
Sarah Charrouf
@sarahcharrouf
Apr 27 2017 03:27
Aha I got it! not entirely sure why, but here it is...
fahrenheit = celsius * 9/5 + 32;
It looks so simple
Erol Aliyev
@erolaliyev
Apr 27 2017 03:27
@khaduch sorry but what do you mean by formatting?
Ralem Eomhd
@Korrah
Apr 27 2017 03:27
@iamjoshuacolon Yes, it's in bracket 3, but in computer logic, it doesn't go 1 2 3, but instead really 0 1 2, so really, what number is that bracket where 8 is?
Ken Haduch
@khaduch
Apr 27 2017 03:28
@erolaliyev - I'll re-post your code to show the indentations that are usually helpful to see where things are happening in the code:
function lookUpProfile(firstName, prop) {
  // Only change code below this line
  var i = 0;
  while (i < 5) {
    if (contacts[i].firstName == firstName) {
      if (contacts[i].prop == prop) {
        return contacts[i].prop;
      } 
      else {
        return 'No such property';
      }
    } 
    else if (contacts[i].firstName != firstName) {
      return 'No such contact';
    }
    i++;
  }
Erol Aliyev
@erolaliyev
Apr 27 2017 03:29
@khaduch in the browser i have written exactly like this but i dont know how to send code like this in message so i just copied and pasted it
Christopher McCormack
@cmccormack
Apr 27 2017 03:29
surround the code in backticks - ``` [code] ```
Vamp
@the-vampiire
Apr 27 2017 03:30
so I have been stuck on the sumPrimes algo for quite a while now. I started off kind of knowing what I was trying to do and then ended up mucking with the code until it worked. my inner function is aptly named…can anyone explain this..?
function sumPrimes(num){

    var i = 2, nums = [], primes = [];

    while(i <= num){
        nums.push(i);
        i++;
    }

    for(i in nums){
        primes.push(i_dont_know_how_this_works(nums[i], nums));
    }


    function flatten(a,b){
        return a.concat(b);
    }

    function sum(a,b){
        return a+b
    }


    function i_dont_know_how_this_works(num, arr){
        var i = 0;
        var primes = [];

        for(i; i < arr.length; i++){
            if(num % arr[i] === 0){
                if(arr[i] !== 1 || arr[i] !== num){
                    primes.push(arr[i]);
                }
            }
        }

        if(primes.length === 1){
            return primes;
        }

        else{
            return false;
        }

    }


    return primes.filter(function(nums){return nums}).reduce(flatten).reduce(sum);

}
CamperBot
@camperbot
Apr 27 2017 03:30
:bulb: to format code use backticks! ``` more info
:bulb: to format code use backticks! ``` more info
Christopher McCormack
@cmccormack
Apr 27 2017 03:32
@erolaliyev backticks - under the ~ key
Ralem Eomhd
@Korrah
Apr 27 2017 03:32

@sarahcharrouf
Basically, our variable fahrenheit needs to be defined to perform that operation. var = fahrenheit essentially sets it so JavaScript knows that you have a variable. That func of convertToF(celsius) is where it sets up the bottom part of the code where you see convertToF(75). So what you wrote, told the code to do this: fahrenheit = (75 * 9/5) + 32

Does that help a bit in understanding of what happened?

Ken Haduch
@khaduch
Apr 27 2017 03:32

@erolaliyev - I don't have too much time, but here are a few points - as I said, you are on the right track - just a few problems:

  • you should use contacts.length for your stop condition for the while loop, instead of the hardcoded 5
  • you can paste the code using the markdown format - read about it here: https://forum.freecodecamp.com/t/markdown-code-formatting/18391
  • prop is a variable - you can use it with dot notation, but you have to use bracket notation - contacts[i].prop is incorrect. contacts[i][prop] is what you need. Note that the reason .firstName is okay to access the property in the object is because "firstName" is an actual property name in the object, dot notation works there.
  • One more thing I thought of (adding this afterward) - you should use .hasOwnProperty() to check that the object has the property you are looking for, that will condition the return of the property or "No such property"
  • The return for No such contact is something that gets so many people confused. Within the loop, you have to make sure to look at all contacts for matching the firstName - if you do a return from within the loop, the function is ended. So if the first contact in the list does not match, you will return and never look at any others. Move that return "No such contact"; after the loop.

Those should be helpful hints, and I'm sure that someone will help you along with other problems.

Sarah Charrouf
@sarahcharrouf
Apr 27 2017 03:34
@Korrah yes that's awesome. thanks for your help!!
CamperBot
@camperbot
Apr 27 2017 03:34
sarahcharrouf sends brownie points to @korrah :sparkles: :thumbsup: :sparkles:
:cookie: 170 | @korrah |http://www.freecodecamp.com/korrah
Erol Aliyev
@erolaliyev
Apr 27 2017 03:35
function lookUpProfile(firstName, prop){
// Only change code below this line
  var i = 0;
  while (i < 5) {
    if(contacts[i].firstName == firstName ) {
      if(contacts[i].prop == prop) {
        return contacts[i].prop;
      }
      else {
        return "No such property";
      }
    }
    else if (contacts[i].firstName != firstName) {
      return "No such contact";
    }
    i++;
  }
// Only change code above this line
}
iamjoshuacolon
@iamjoshuacolon
Apr 27 2017 03:35
@Korrah 2
Erol Aliyev
@erolaliyev
Apr 27 2017 03:35
@cmccormack thank you :) i couldnt find backtick in my keyboard but i copied it from internet
CamperBot
@camperbot
Apr 27 2017 03:35
erolaliyev sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 439 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Apr 27 2017 03:36
@erolaliyev first - don't use a while loop, use a for lop over the length of the iterator
@erolaliyev second, when accessing an object's property, if you're using a variable, use [ ] bracket notation
iamjoshuacolon
@iamjoshuacolon
Apr 27 2017 03:36
@Korrah Got it, thanks!
CamperBot
@camperbot
Apr 27 2017 03:36
:cookie: 171 | @korrah |http://www.freecodecamp.com/korrah
iamjoshuacolon sends brownie points to @korrah :sparkles: :thumbsup: :sparkles:
Erol Aliyev
@erolaliyev
Apr 27 2017 03:36
@khaduch thanks
CamperBot
@camperbot
Apr 27 2017 03:36
erolaliyev sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2803 | @khaduch |http://www.freecodecamp.com/khaduch
Ralem Eomhd
@Korrah
Apr 27 2017 03:36
No problem!
Christopher McCormack
@cmccormack
Apr 27 2017 03:36
@erolaliyev that's rough if you don't have one!
@erolaliyev also looks like you're returning from your function after the first contact that doesn't match, you'll want to move that No Such Contact piece outside your loop
Erol Aliyev
@erolaliyev
Apr 27 2017 03:38
@cmccormack no wait a minute i find it. It is next to the enter :smile: but it writes two times in one click :)
Christopher McCormack
@cmccormack
Apr 27 2017 03:39
hmm sure that isn't just a double quote "?
Erol Aliyev
@erolaliyev
Apr 27 2017 03:40
@cmccormack no it is one, double quote is in another key
Daniel Zeff
@Diesirae9
Apr 27 2017 03:42
Hey guys can you help me understand a coding concept?
Christopher McCormack
@cmccormack
Apr 27 2017 03:43
We can try
Daniel Zeff
@Diesirae9
Apr 27 2017 03:44
So I am starting us learn objects
and I understand how give attributes, but once I put an object into a function I am having a hard time understanding how to manipulate the object within the function.
Christopher McCormack
@cmccormack
Apr 27 2017 03:46
@Diesirae9 do you have an example of something you're working on?
Daniel Zeff
@Diesirae9
Apr 27 2017 03:46

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

// Only change code below this line
var lookup = {
alpha: 'Adams',
bravo: 'Boston',
charlie: 'Chicago',
delta: 'Denver',
echo : 'Easy',
foxtrot: 'Frank'
};

result = lookup[val];
// Only change code above this line
return result;
}

// Change this value to test
phoneticLookup("charlie");

Jarod Guthrie
@jarodguthrie
Apr 27 2017 03:47

hi guys, I'm getting this error?
Reset Help Bug

TypeError: Cannot assign to read only property '0' of string 'i'm a little tea pot'

For:

function titleCase(str) {
str = str.toLowerCase();
var strSplit = str.split(' ');

for (var i = 0; i < strSplit.length; i++){
str[i] = str[i].charAt(0).toUpperCase() + str[i].slice(1);

}

return str.join (' ');
}

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

Sandesh Shrestha
@UnovaXan
Apr 27 2017 03:47
@jarodguthrie strings are immutable in javascript
Christopher McCormack
@cmccormack
Apr 27 2017 03:47
@Diesirae9 that looks good to me, are you getting an error?
Sandesh Shrestha
@UnovaXan
Apr 27 2017 03:47
you have to create a new array and use it
Daniel Zeff
@Diesirae9
Apr 27 2017 03:47
So that was the one I had to look up
Christopher McCormack
@cmccormack
Apr 27 2017 03:48
@Diesirae9 ah
Daniel Zeff
@Diesirae9
Apr 27 2017 03:48
So, I did fine on creating the var = lookup;
Vamp
@the-vampiire
Apr 27 2017 03:49
@jarodguthrie
function titleCase(str) {
str = str.toLowerCase();
var strSplit = str.split(' ');
for (var i = 0; i < strSplit.length; i++){
str[i] = str[i].charAt(0).toUpperCase() + str[i].slice(1);
}
return str.join (' ');
}
titleCase("I'm a little tea pot”);
Pagnito
@Pagnito
Apr 27 2017 03:49
cant understand why this doesnt work
var seqArr = [];
var savedNum = 2;
var prevNum = 1;
function sumFibs() {

    savedNum += prevNum
    seqArr.push(savedNum);
    var g = seqArr.length;
    prevNum = seqArr[g-1];
    $('#wtf').html(savedNum)


    console.log(g)
    console.log(seqArr)
    console.log(seqArr[g-1])

}
Daniel Zeff
@Diesirae9
Apr 27 2017 03:49
What I am not understanding is the following line: result = lookup[val];
Is my understanding issue an object issue or a function issue? :)
Manish Giri
@Manish-Giri
Apr 27 2017 03:50
@Diesirae9 what don't you understand?
stevenadrien
@stevenadrien
Apr 27 2017 03:51
hey guys, I was wondering if I could get some help with a question?
Ashish verma
@ashish1500616
Apr 27 2017 03:51
??
stevenadrien
@stevenadrien
Apr 27 2017 03:51
Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr

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

this is not working
and im kinda lost
as to why its not
Ashish verma
@ashish1500616
Apr 27 2017 03:52
@stevenadrien link to the question?
Christopher McCormack
@cmccormack
Apr 27 2017 03:52
@Diesirae9 there are two ways to access or modify objects using properties - the [ ] bracket notation and the . dot notation. Bracket is used when you don't have the explicit property name (example - bravo) but you do have a variable that has the value of that property name (example - var b = 'bravo'; return lookup[b];). Dot notation is used when you can reference the property using the actual name (example return lookup.alpha;).
Manish Giri
@Manish-Giri
Apr 27 2017 03:53
@stevenadrien for(var j=0; j<arr.length; j++) {
this is wrong
think about how long the inner loop should go through
Daniel Zeff
@Diesirae9
Apr 27 2017 03:54
so I am telling the script to return a property that is defined in some object within the function?
Ashish verma
@ashish1500616
Apr 27 2017 03:55
@stevenadrien
for(var j=0; j<arr[i].length; j++)
Manish Giri
@Manish-Giri
Apr 27 2017 03:55
lookup is the object
David Yang
@dyang4234
Apr 27 2017 03:55

function palindrome(str) {
// Good luck!
var newString = str.replace(/[_\d\s\W]/gi,"");
var lowerCaseString = newString.toLowerCase();
var stringArray = lowerCaseString.split('');
var reversedArray = stringArray.reverse();
var reversedArrayJoin = reversedArray.join('');

if (reversedArrayJoin == lowerCaseString) {
return true;
}
else {
return false;
}
}

palindrome("1 eye for of 1 eye.");

Daniel Zeff
@Diesirae9
Apr 27 2017 03:55
yes
Manish Giri
@Manish-Giri
Apr 27 2017 03:55
val is the property
you're looking up whatever property was passed in as val
Erol Aliyev
@erolaliyev
Apr 27 2017 03:55
hey guys can anyone help me with profile lookup challenge?
Manish Giri
@Manish-Giri
Apr 27 2017 03:55
and returning its value
stevenadrien
@stevenadrien
Apr 27 2017 03:55
ahhh
David Yang
@dyang4234
Apr 27 2017 03:55
I can't pass the last test
Daniel Zeff
@Diesirae9
Apr 27 2017 03:55
ok
stevenadrien
@stevenadrien
Apr 27 2017 03:55
the length of that array element's?
Sandesh Shrestha
@UnovaXan
Apr 27 2017 03:56
@stevenadrien yes
stevenadrien
@stevenadrien
Apr 27 2017 03:56
its weird having a hard time visualizing the solution for this problem
David Yang
@dyang4234
Apr 27 2017 03:56
It's supposed to return false but it returns true
Christopher McCormack
@cmccormack
Apr 27 2017 03:56
@Diesirae9 the object is lookup. Note the { }, this denotes an object.
David Yang
@dyang4234
Apr 27 2017 03:56
Am I not understanding something here?
Daniel Zeff
@Diesirae9
Apr 27 2017 03:56
and if there is an object with that attribute it prints the attribute.
Lhats0
@stahloliver
Apr 27 2017 03:56

Can anybody please help me with this challenge? Output should look like this:

FirstLine
\SecondLine\
ThirdLine

My code is:
var myStr="FirstLine\n\Secondline\\rThirdLine";

When I console log the line, it looks exactly as the example above. Is that a bug?

stevenadrien
@stevenadrien
Apr 27 2017 03:56
but oh well
thanks alot guys :)
Sandesh Shrestha
@UnovaXan
Apr 27 2017 03:57
@stahloliver you have to escape backslash itself
Christopher McCormack
@cmccormack
Apr 27 2017 03:57
@Pagnito walk through your code, filling in the numbers in your head - you'll find it doesn't quite do what you think after the first number
Erol Aliyev
@erolaliyev
Apr 27 2017 03:57
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (i = 0; i < contacts.length; i++) {
    if(contacts[i][firstName] == firstName ) {
      if(contacts[i].hasOwnProperty(prop) === true) {
        return contacts[i][prop];
      }
      else {
        return "No such property";
      }
    }
  }
  return "No such contact";
// Only change code above this line
}
Ashish verma
@ashish1500616
Apr 27 2017 03:57
@stevenadrien
you have to iterate through the elements of the each row
thats y
at first when i=0:arr[0],when i=2,arr[2]..similarly.
Lhats0
@stahloliver
Apr 27 2017 03:58
@UnovaXan how? I know it's \ but it just doesn't work
Two backslashes actually. Gitter strips the second one
Sandesh Shrestha
@UnovaXan
Apr 27 2017 03:58
@stahloliver its supposed to be //
oops
\
Lhats0
@stahloliver
Apr 27 2017 03:58
You see? :D
Sandesh Shrestha
@UnovaXan
Apr 27 2017 03:59
\\
Lhats0
@stahloliver
Apr 27 2017 03:59
Yeah. I have it like exactly like that
Sandesh Shrestha
@UnovaXan
Apr 27 2017 03:59
haha
well it's supposed to work
try refreshing the page
Lhats0
@stahloliver
Apr 27 2017 03:59
var myStr="FirstLine\n\\Secondline\\\rThirdLine";
stevenadrien
@stevenadrien
Apr 27 2017 04:00
well i get that part
Christopher McCormack
@cmccormack
Apr 27 2017 04:00
@erolaliyev use dot notation for the first conditional
stevenadrien
@stevenadrien
Apr 27 2017 04:00
but how does that relate to the product
lol something tells me im overthinking this
Lhats0
@stahloliver
Apr 27 2017 04:01
@UnovaXan no luck : /
Sandesh Shrestha
@UnovaXan
Apr 27 2017 04:01
@stahloliver link to the problem?
Daniel Zeff
@Diesirae9
Apr 27 2017 04:02
I think I got it guys!
Sandesh Shrestha
@UnovaXan
Apr 27 2017 04:02
i think you forgot to capitalize the L in SecondLine
XD
Lhats0
@stahloliver
Apr 27 2017 04:03
Lol
Daniel Zeff
@Diesirae9
Apr 27 2017 04:03
Thank you @cmccormack and @Manish-Giri
CamperBot
@camperbot
Apr 27 2017 04:03
diesirae9 sends brownie points to @cmccormack and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 440 | @cmccormack |http://www.freecodecamp.com/cmccormack
:star2: 5302 | @manish-giri |http://www.freecodecamp.com/manish-giri
Pagnito
@Pagnito
Apr 27 2017 04:03
@cmccormack k
Christopher McCormack
@cmccormack
Apr 27 2017 04:03
@Diesirae9 :thumbsup:
Lhats0
@stahloliver
Apr 27 2017 04:03
Thanks you @UnovaXan
CamperBot
@camperbot
Apr 27 2017 04:03
stahloliver sends brownie points to @unovaxan :sparkles: :thumbsup: :sparkles:
:cookie: 279 | @unovaxan |http://www.freecodecamp.com/unovaxan
Sandesh Shrestha
@UnovaXan
Apr 27 2017 04:03
@Revilo You're welcome :D
Joseph
@revisualize
Apr 27 2017 04:03
Hi.
Sandesh Shrestha
@UnovaXan
Apr 27 2017 04:03
Hello :D
Lhats0
@stahloliver
Apr 27 2017 04:04
@UnovaXan some real life JS debugging in practice : )
Erol Aliyev
@erolaliyev
Apr 27 2017 04:05
@cmccormack thank you so much it worked
CamperBot
@camperbot
Apr 27 2017 04:05
erolaliyev sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: erolaliyev already gave cmccormack points
Christopher McCormack
@cmccormack
Apr 27 2017 04:05
@erolaliyev np
Sandesh Shrestha
@UnovaXan
Apr 27 2017 04:05
@stahloliver haha yeah
Erol Aliyev
@erolaliyev
Apr 27 2017 04:05
@cmccormack but why did i use dot notation?
shouldnt it be bracket beacuse it is variable?
Christopher McCormack
@cmccormack
Apr 27 2017 04:06
@erolaliyev it's not a variable, the argument is a variable, but you want to access the actual property name for your comparison
Pagnito
@Pagnito
Apr 27 2017 04:07
@cmccormack cuz length doesnt start from zero, shit lol
Daniel Zeff
@Diesirae9
Apr 27 2017 04:07
the brackets are basically saying to use the proporty to look within an object, that is acting like a directory to find the results I am looking for :)
Christopher McCormack
@cmccormack
Apr 27 2017 04:07
otherwise you'll be looking for a property using an actual name
@Diesirae9 when you use brackets, you're looking in the object for a property that matches the variables value, not name. When you use dot notation, you're referencing the actual property name
@Diesirae9 so for the example lookUpProfile("Akira", "likes");, if (contacts[i][firstName] == firstName) { would look like if (contacts[i].Akira == firstName) {
Ashish verma
@ashish1500616
Apr 27 2017 04:11
@stevenadrien
var i is used to traverse through rows
var j is used to traverse through columns,
so arr[0][0] =1;arr[1][0] =2;arr[2][0] =3;
product=1;
product
=2;(1*2);
Pagnito
@Pagnito
Apr 27 2017 04:11
@cmccormack sweet, figured it out!!, i just started it out with the array holdin th 1 and 2 and the savedNum variable holding those vals
Christopher McCormack
@cmccormack
Apr 27 2017 04:12
@Pagnito nice, I was going to suggest that but didn't want to make you lose your train of thought
Pagnito
@Pagnito
Apr 27 2017 04:12
@cmccormack yea i appreciate u not giving it away
@cmccormack feel much better about it haha
Christopher McCormack
@cmccormack
Apr 27 2017 04:12
@Pagnito best feeling in the world :)
Pagnito
@Pagnito
Apr 27 2017 04:13
@cmccormack haha forreal
Austin Wiggins
@austinwiggins
Apr 27 2017 04:15
Hi everyone. I have absolutely no clue how to do the 'Seek and Destroy' JS Algorithm; any help would be really nice!
Christopher McCormack
@cmccormack
Apr 27 2017 04:16
@austinwiggins what are you having trouble with specifically?
Daniel Zeff
@Diesirae9
Apr 27 2017 04:18
I is the object, Akira a property of firstName.
right?
Christopher McCormack
@cmccormack
Apr 27 2017 04:19
@Diesirae9 contacts is the object. Akira is a string that you want to try and find, but to do so you need to reference the property name of the object.
Daniel Zeff
@Diesirae9
Apr 27 2017 04:19
got it
Christopher McCormack
@cmccormack
Apr 27 2017 04:19
@Diesirae9 Object syntax can be simply described as Object { property: value }
Daniel Zeff
@Diesirae9
Apr 27 2017 04:19
i is the property
Christopher McCormack
@cmccormack
Apr 27 2017 04:20
i is your iterator
Austin Wiggins
@austinwiggins
Apr 27 2017 04:20
@cmccormack Well, it gives a function, with parameters, function destroyer(arr). Then below it calls the function with this:
destoyer([1,2,3,1,2,3],2,3);
So what it wants is for the numbers outside of the array to be removed from the inside of the array and for the only numbers to be returned are those out of the array. So I am having trouble figuring out how to get these numbers when there is just one parameter for both the array and the numbers on the outside of the array
Christopher McCormack
@cmccormack
Apr 27 2017 04:21
@austinwiggins have you seen arguments before?
@Diesirae9 the properties of the contacts object are firstName, lastName, number, and likes
Austin Wiggins
@austinwiggins
Apr 27 2017 04:22
@cmccormack What do you mean?
Christopher McCormack
@cmccormack
Apr 27 2017 04:23
@austinwiggins arguments is a built-in Javascript object, similar to a simple array, that stores all arguments sent to a function. So even if your function only has a single parameter, like arr or whatever, the arguments object may have additional arguments in it, which you can interate over to see
Daniel Zeff
@Diesirae9
Apr 27 2017 04:23
@cmccormack Thank you so much :)
CamperBot
@camperbot
Apr 27 2017 04:23
diesirae9 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: diesirae9 already gave cmccormack points
Christopher McCormack
@cmccormack
Apr 27 2017 04:23
@Diesirae9 np
Austin Wiggins
@austinwiggins
Apr 27 2017 04:24
@cmccormack Can you direct me to a webpage so I can read more about this?
Austin Wiggins
@austinwiggins
Apr 27 2017 04:25
Thanks @cmccormack I'll read about it and try to incorporate it into this JS Challenge ;)
CamperBot
@camperbot
Apr 27 2017 04:25
austinwiggins sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 441 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Apr 27 2017 04:26
@austinwiggins gl!
Austin Wiggins
@austinwiggins
Apr 27 2017 04:26
thanks :D
intcreate
@intcreate
Apr 27 2017 04:27
```

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

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

// Test your code by modifying these values
checkObj("gift");
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
Benjamin
@XenoCoding
Apr 27 2017 04:27
function convertToRoman(num) {

  function convert(number, base, midpoint, next){
    var digitHolder = number;
    var holder;

    holder = digitHolder[0];
    digitHolder = '';

    if(holder <= 3){

      for (var j = 0; j < holder; j++){
        digitHolder += base;
      }

    }

    else if(holder == 4){
      digitHolder = base + midpoint;
    }

    else if(holder == 5){
      digitHolder = midpoint;
    }

    else if(holder > 5 && holder < 9){
      digitHolder = midpoint;

      for(var k = 0; k < (holder - 5); k++){
        digitHolder += base;
      }

    }

    else if(holder == 9){
      digitHolder = base + next;
    }

    return digitHolder;
  }

  var number = num.toString();
  number = number.split("");

  var digitHolder = [];
  var holder;

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

    if(number[i] === "0"){
      number.splice(i, 1);
    }

    else{
      for(var j = 0; j < number.length - (i+1); j++){
        number[i] += "0"; 
      }

      digitHolder.push(number[i]); 
    }

  }

  for(var k = 0; k < digitHolder.length; k++){

    if(digitHolder[k].length == 4){

      digitHolder[k] = convert(digitHolder[k], "M");

    }

    if(digitHolder[k].length == 3){

      digitHolder[k] = convert(digitHolder[k], "C", "D", "M"); 

    }

    if(digitHolder[k].length == 2){

      digitHolder[k] = convert(digitHolder[k], "X", "L", "C"); 

    }

    if(digitHolder[k].length == 1){

      digitHolder[k] = convert(digitHolder[k], "I", "V", "X"); 

    }
  }

  return digitHolder.join('');
}

convertToRoman(1234);
intcreate
@intcreate
Apr 27 2017 04:27
need help to figure out how to return properties' value
Benjamin
@XenoCoding
Apr 27 2017 04:28
Why is my code only working for certain numbers???
Austin Wiggins
@austinwiggins
Apr 27 2017 04:29
@cmccormack Oooohhhhh, now I get it; thanks again!
CamperBot
@camperbot
Apr 27 2017 04:29
austinwiggins sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: austinwiggins already gave cmccormack points
Christopher McCormack
@cmccormack
Apr 27 2017 04:29
np
@intcreate you need to return a value from myObj but you only return checkProp.
Jason Myers
@Jmyers1101
Apr 27 2017 04:31

var count = 0;

function cc(card) {
// Only change code below this line
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
val = count + 1;
return val + " Bet";
case 7:
case 8:
case 9:
val = count + 0;
return val + " Hold";
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
val = count - 1;
return val + " Hold";
}
// Only change code above this line
}

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

What am I doing wrong?
Christopher McCormack
@cmccormack
Apr 27 2017 04:33
@Jmyers1101 what is val?
Jason Myers
@Jmyers1101
Apr 27 2017 04:33
I wasn't sure what to put so I put val
Christopher McCormack
@cmccormack
Apr 27 2017 04:34
@Jmyers1101 you're supposed to be keeping count, so you'll need to modify count as you draw more cards
@Jmyers1101 you already have a very aptly named variable you declared at the beginning, you should use it!
Jason Myers
@Jmyers1101
Apr 27 2017 04:34
Yeah, how do I make it go through the switch multiple times to get the correct count?
hint taken
Christopher McCormack
@cmccormack
Apr 27 2017 04:37
@Jmyers1101 it will go through multiple times on it's own, as the function is tested. In the example, the same function is called 5 times. Count will keep the state so far
Jason Myers
@Jmyers1101
Apr 27 2017 04:37
so far with my current code it only goes through with whatever card is mentioned last
Christopher McCormack
@cmccormack
Apr 27 2017 04:39
@Jmyers1101 not sure what you mean by goes through.
Jason Myers
@Jmyers1101
Apr 27 2017 04:40
okay I tweeked it a bit to incorporate your suggestion and I'm still off by 2 objectives, but we are getting closer

function cc(card) {
// Only change code below this line
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count += 1;
return count + " Bet";
case 7:
case 8:
case 9:
count += 0;
return count + " Hold";
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count -= 1;
return count + " Hold";
}

// Only change code above this line
}

Christopher McCormack
@cmccormack
Apr 27 2017 04:41
@Jmyers1101 remember that your "Bet" and "Hold" are dependent on the count at the time, so returning one or the other simply because you drew a card isn't going to do what you want
rebeccatay92
@rebeccatay92
Apr 27 2017 04:45
The Bet and Hold actions are dependent on the resultant card count. They should not be in the switch. Try writing another ifelse in the function that checks if total count is >0 or <=0. Then the entire function should return count + " " + betOrHold;
Jason Myers
@Jmyers1101
Apr 27 2017 04:47
Ahhhhh, thank you both @rebeccatay92 and @cmccormack
CamperBot
@camperbot
Apr 27 2017 04:47
jmyers1101 sends brownie points to @rebeccatay92 and @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 198 | @rebeccatay92 |http://www.freecodecamp.com/rebeccatay92
:cookie: 442 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Apr 27 2017 04:47
np
rebeccatay92
@rebeccatay92
Apr 27 2017 04:47
wc
Ralem Eomhd
@Korrah
Apr 27 2017 04:55

``function resuableFunction() {
console.log("Hi World");
}

resuableFunction();``

Hm. How is my "resuableFunction" not a function, not defined?

Darth Skywalker
@adityaparab
Apr 27 2017 04:56
@Korrah Spelling mistakes
Austin Wiggins
@austinwiggins
Apr 27 2017 04:56
OK, so I am having trouble with the 'Seek and Destroy' JS challenge. I now know of the arguments object, but how to incorporate this into a function I do not know. Any help would be very much appreciated
Ralem Eomhd
@Korrah
Apr 27 2017 04:57
@adityaparab Thank you! Nearly 1AM and clearly I shouldn't be trying to spell at this hour XD
CamperBot
@camperbot
Apr 27 2017 04:57
korrah sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:star2: 1027 | @adityaparab |http://www.freecodecamp.com/adityaparab
Christopher McCormack
@cmccormack
Apr 27 2017 04:57
@austinwiggins do you know of the slice() Array method?
Abhi
@abhishek737
Apr 27 2017 04:58
var form = new FormData() ; form.append('name' : 'username'); form.append('mobile' : '0909090909');
Why I am getting 2 arrays
instead of one array
Austin Wiggins
@austinwiggins
Apr 27 2017 04:58
@cmccormack Yes
How is that supposed to be incorporated into the function?
Christopher McCormack
@cmccormack
Apr 27 2017 05:01
you can use that to put the remaining values after arr (arguments[0]) into an array. Slice the arguments object to get the values you need.
then work on iterating over the arr and doing your comparisons
Austin Wiggins
@austinwiggins
Apr 27 2017 05:02
OK, I'll try that
Rick
@r7uaz0n
Apr 27 2017 05:07

Heya, need some help w/ this one. Instructions
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found". ```// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

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

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

What am I doing wrong here?
Christopher McCormack
@cmccormack
Apr 27 2017 05:09
you're first line is overwriting your argument, and you have no need to assign myObj to anything as it is global
bilaal-s
@bilaal-s
Apr 27 2017 05:09
@forkerino Ah, didnt see your message last night ^_^ thanks!
CamperBot
@camperbot
Apr 27 2017 05:09
bilaal-s sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1953 | @forkerino |http://www.freecodecamp.com/forkerino
Christopher McCormack
@cmccormack
Apr 27 2017 05:10
@b00kwheat you're also using the function name as your argument to hasOwnProperty, but you should be using the function's argument instead
@b00kwheat and you're returning the global myObj, which is not what the instructions asked for
Rick
@r7uaz0n
Apr 27 2017 05:14
@cmccormack Ok, your first suggestion - if (myObj.hasOwnProperty(checkProp) === true){
Naveen Raju Mudhunuri
@naveenrajum
Apr 27 2017 05:16

function destroyer(arr) {
  // Remove all the values
  var arg = Array.from(arguments).shift();
  var aA = arr.filter(function(ele){
       return arg.indexOf(ele) === -1;
  });
  return aA;
}

destroyer([3, 5, 1, 2, 2], 2, 3, 5);
stuck in here.
ankurpatel4888
@ankurpatel4888
Apr 27 2017 05:17
I'm new to programming here is the question what is the difference between(1) "FirstLine newline backslash SecondLine backslash carriage-return ThirdLine"
(2)var myStr = "FirstLine\n \SecondLine\ \rThirdline";
as it showing me incorrect answer
Jor
@joreyesl
Apr 27 2017 05:18
@9aveen you are assigning the result of .shift() to arg.
Rick
@r7uaz0n
Apr 27 2017 05:18
how do I return property value?
Naveen Raju Mudhunuri
@naveenrajum
Apr 27 2017 05:19
thanks instead of shift I used slice and it worked @joreyesl
CamperBot
@camperbot
Apr 27 2017 05:19
9aveen sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 799 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Apr 27 2017 05:19
@b00kwheat you can access the property value using the key, ex: obj[key]. You can return the value of that expression.
Naveen Raju Mudhunuri
@naveenrajum
Apr 27 2017 05:20
could you explain me the difference between var arg = Array.from(arguments).slice(1); and var arg = Array.from(arguments).shift();
@joreyesl
james umali
@indefinite0212
Apr 27 2017 05:21
@ankurpatel4888 remove spaces and backslash is \\
Markus Kiili
@Masd925
Apr 27 2017 05:22
@9aveen Check what the return values of slice and shift methods are.
Jor
@joreyesl
Apr 27 2017 05:24
@9aveen .shift() removes the first element in the array and returns the element removed. .slice() creates a new array out of the elements starting at the given start and end indices and returns a reference to the new array.
var arr = [1,2,3];
var a = arr.shift(); 
console.log(a); // 1
console.log(arr); // [2,3]
var arr = [1,2,3];
var a = arr.slice(1);
console.log(a); // [2,3]
console.log(arr); // [1,2,3]
Rick
@r7uaz0n
Apr 27 2017 05:25
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
what's wrong with my return here?
Christopher McCormack
@cmccormack
Apr 27 2017 05:26
@b00kwheat you're still assigning myObj to checkProp, there is no reason to do so
Jor
@joreyesl
Apr 27 2017 05:26
@b00kwheat you are replacing the value of checkProp when you do checkProp=myObj;
Rick
@r7uaz0n
Apr 27 2017 05:27
Ok, I removed checkProp=myObj;
Christopher McCormack
@cmccormack
Apr 27 2017 05:28
@b00kwheat your return if myObj has the property checkProp is incorrect is well, you should be returning the value of the property of myObj
Rick
@r7uaz0n
Apr 27 2017 05:28
I got it. Thanks @cmccormack .
CamperBot
@camperbot
Apr 27 2017 05:28
b00kwheat sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 443 | @cmccormack |http://www.freecodecamp.com/cmccormack
Jor
@joreyesl
Apr 27 2017 05:28
@b00kwheat and your return should be object[key], so your object is myObj and the key you want is checkProp
Naveen Raju Mudhunuri
@naveenrajum
Apr 27 2017 05:28
thank you so much @joreyesl @Masd925
CamperBot
@camperbot
Apr 27 2017 05:28
9aveen sends brownie points to @joreyesl and @masd925 :sparkles: :thumbsup: :sparkles:
:warning: 9aveen already gave joreyesl points
:star2: 3939 | @masd925 |http://www.freecodecamp.com/masd925
Rick
@r7uaz0n
Apr 27 2017 05:29
I got it. Thanks @joreyesl
CamperBot
@camperbot
Apr 27 2017 05:29
b00kwheat sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 800 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Apr 27 2017 05:29
@b00kwheat :thumbsup:
gerome0123
@gerome0123
Apr 27 2017 05:29
how to detect value null in ng-change in controller
ankurpatel4888
@ankurpatel4888
Apr 27 2017 05:29
@indefinite0212 have already tried that but still getting same error "myStr should have encoded text with the proper escape sequences and no spacing."
james umali
@indefinite0212
Apr 27 2017 05:30
@ankurpatel4888 show your code again
ankurpatel4888
@ankurpatel4888
Apr 27 2017 05:33
@indefinite0212 given code "FirstLineNEWLINEBACKSLASHSecondLineBACKSLASHCARRIAGE_RETURNThirdLine" converted to actual code as"var myStr = "FirstLine\n\SecondLine\\rThirdline"; // Change this line"
james umali
@indefinite0212
Apr 27 2017 05:33
ThirdLine @ankurpatel4888
you use \\?
ankurpatel4888
@ankurpatel4888
Apr 27 2017 05:34
thats the comment
for change this line
Benji
@Benji-Leboe
Apr 27 2017 05:35
Hey so I wrote an algorithm that reverses an array in place without using the .reverse() method, but I feel like there must be a cleaner way to do this. Anyone got thoughts?
function reverseArrayInPlace(array){
    var count = array.length;
    var newArr = []

    for(i = 0; i < count; i++){
        newArr.push(array.pop());
        console.log("unit: "+newArr[i]);
    }
    for(j = 0; j < count; j++){
        array.push(newArr[j]);
    }
    console.log("total: "+newArr);
    return array;
}

console.log(reverseArrayInPlace([1,2,3,4]));
gerome0123
@gerome0123
Apr 27 2017 05:35
how to detect value null in ng-change in controller
james umali
@indefinite0212
Apr 27 2017 05:36
@ankurpatel4888 I mean are you using backslash \\?
ankurpatel4888
@ankurpatel4888
Apr 27 2017 05:37
yes
this is the expected result "FirstLine
\SecondLine\
ThirdLine"
Jor
@joreyesl
Apr 27 2017 05:38
@Benji-Leboe you can do it using a single loop and swapping 1st element with last element, 2nd element with 2nd last element, etc. No need for using temp array or push/pop.
Benji
@Benji-Leboe
Apr 27 2017 05:38
@joreyesl how would I do that? could you give a quick example?
james umali
@indefinite0212
Apr 27 2017 05:39
@ankurpatel4888 show your code and use '''
CamperBot
@camperbot
Apr 27 2017 05:39
:bulb: to format code use backticks! ``` more info
ankurpatel4888
@ankurpatel4888
Apr 27 2017 05:43
'''var myStr = "FirstLine\n\SecondLine\\rThirdline"; // Change this line'''
CamperBot
@camperbot
Apr 27 2017 05:43
:bulb: to format code use backticks! ``` more info
ankurpatel4888
@ankurpatel4888
Apr 27 2017 05:44
var myStr = "FirstLine\n\\SecondLine\\\rThirdline";
intcreate
@intcreate
Apr 27 2017 05:44
```
james umali
@indefinite0212
Apr 27 2017 05:44
it is ThirdLine not Thirdline
@ankurpatel4888
Jor
@joreyesl
Apr 27 2017 05:44
@ankurpatel4888 you have have to capitalize Line in Thirdline. It should be ThirdLine
intcreate
@intcreate
Apr 27 2017 05:44

// Example
var ourArray = [];

for (var i = 1; i < 6; i++) {
  myArray.push(i);
}

// Setup
var myArray = [];

// Only change code below this line.
You should be using a for loop for this.
myArray should equal [1,2,3,4,5].
sbechtold13
@sbechtold13
Apr 27 2017 05:44
ayyy
var myStr = "Jello";
myStr[0] = "Hello"; // Fix Me
whats the deal with this.
intcreate
@intcreate
Apr 27 2017 05:45
it is saying that .push(i) is not defined
ankurpatel4888
@ankurpatel4888
Apr 27 2017 05:45
@joreyesl thanx.... that was really a silly mistake....
CamperBot
@camperbot
Apr 27 2017 05:45
ankurpatel4888 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 801 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Apr 27 2017 05:48
@Benji-Leboe well the example would give away the code. But I can tell you the loop only has to run halfway through the array. And then you just have to figure out the indices of the two elements you have to swap. The 1st index will just be i, and the 2nd index will involve i and the length of the array.
@intcreate you should write your loop below where it says, // Only change code below this line.
Markus Kiili
@Masd925
Apr 27 2017 05:53
@Benji-Leboe You can also make a simple solution using recursion.
Jedifan200
@Jedifan200
Apr 27 2017 05:53

```function palindrome(str) {
// Good luck!

//str = str.replace();
var store = str.toLowerCase();

var lstr = str.length;
var newstr = [];
for(var a = (lstr-1);a > -1; a--)
{
newstr.push(str[a]);
}
if(store == newstr.join(""))
{
return true;
}
else{
return false;
}
}

palindrome("E?_-#&ye");
```
I need help getting rid of special characters

intcreate
@intcreate
Apr 27 2017 05:56
thanks @joreyesl
CamperBot
@camperbot
Apr 27 2017 05:56
intcreate sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 802 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Apr 27 2017 06:01
@Jedifan200 you can use .replace() and a regex, look at the \W meta character.
kreuel
@kreuel
Apr 27 2017 06:02
hi guys, I'm stuck in here (Profile Lookup in Javascript)
blob
Jedifan200
@Jedifan200
Apr 27 2017 06:04
@joreyesl How do I use a regex
kreuel
@kreuel
Apr 27 2017 06:04
I still need to add a condition on the prop value
Jor
@joreyesl
Apr 27 2017 06:05
@Jedifan200 you can read the docs that I linked.
@kreuel you will need another if statement inside the check if the contact has the property using .hasOwnProperty()
Long Nguyen
@longnt80
Apr 27 2017 06:08

hello, I'm trying to learn JSON. Here's the code to load the JSON file and print the content on the console. However, I don't see anything in the console?

var ourRequest = new XMLHttpRequest();


ourRequest.open('GET', 'https://learnwebcode.github.io/json-example/animals-1.json');


ourRequest.onLoad = function() {
  var ourData = JSON.parse(ourRequest.responseText);
  console.log(ourData[0]);
};


ourRequest.send();

What is wrong?

kreuel
@kreuel
Apr 27 2017 06:09
@joreyesl thanks, will try it out.
CamperBot
@camperbot
Apr 27 2017 06:09
kreuel sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 803 | @joreyesl |http://www.freecodecamp.com/joreyesl
diegoxro
@diegoxro
Apr 27 2017 06:12
@longnt80 what's the problem name?
Long Nguyen
@longnt80
Apr 27 2017 06:12
@diegoxro It's not in Free Code Camp
diegoxro
@diegoxro
Apr 27 2017 06:13
that explain why I could not find it lol
Long Nguyen
@longnt80
Apr 27 2017 06:13
@longnt80 the JSON part in FreeCodeCamp is not helpful so I have to find other tutorials
anderson
@anderson2825
Apr 27 2017 06:18

```
function destroyer(arr) {
// Remove all the values
var values=[];
for(var i=1;i<arguments.length;i++ ){
values.push(arguments[i]);
}
function arrfilter(val){
val=values;
}

return arr.fliter(arrfilter);

}

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

``` please help me check it ! why is wrong??

function destroyer(arr) {
// Remove all the values
var values=[];
for(var i=1;i<arguments.length;i++ ){
values.push(arguments[i]);
}
function arrfilter(val){
val=values;
}
return arr.fliter(arrfilter);
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
please help me check it ! why is wrong??
Markus Kiili
@Masd925
Apr 27 2017 06:20
@anderson2825 Inside the filter callback, you need to check whether val is found on values. You can use indexOf method.
Jor
@joreyesl
Apr 27 2017 06:20
@longnt80 .onLoad should be .onload
anderson
@anderson2825
Apr 27 2017 06:21
filter27142029.png
Long Nguyen
@longnt80
Apr 27 2017 06:21
@joreyesl
thank you! it's running now
CamperBot
@camperbot
Apr 27 2017 06:21
longnt80 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 804 | @joreyesl |http://www.freecodecamp.com/joreyesl
anderson
@anderson2825
Apr 27 2017 06:21
@Masd925

@Masd925 but ... Here are some helpful links:

Arguments object
Array.prototype.filter()

Jor
@joreyesl
Apr 27 2017 06:24
@anderson2825 inside arrfilter function you should be checking if val matches any elements in values. If it does then you should return false, otherwise return true. you can use a loop, .indexOf() or .includes().
Also you have a typo, arr.fliter(arrfilter);
anderson
@anderson2825
Apr 27 2017 06:24
how should i do??
Makrand R
@makrandr
Apr 27 2017 06:26
http://codepen.io/makrandr/pen/NjPmYE
I know I'm supposed to process it differently but over here I'm trying to show the coordinates within Location <div>,but it doesn't seem to work
Long Nguyen
@longnt80
Apr 27 2017 06:27

@anderson2825

function arrfilter(val){
val=values;
}

values is an array, not a value

and you missed "return" return val=values
rugano
@rugano
Apr 27 2017 06:28
Hello campers
anderson
@anderson2825
Apr 27 2017 06:28
okay! thanks ! @longnt80 @Masd925 @joreyesl
CamperBot
@camperbot
Apr 27 2017 06:28
anderson2825 sends brownie points to @longnt80 and @masd925 and @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 805 | @joreyesl |http://www.freecodecamp.com/joreyesl
:cookie: 196 | @longnt80 |http://www.freecodecamp.com/longnt80
:star2: 3940 | @masd925 |http://www.freecodecamp.com/masd925
Long Nguyen
@longnt80
Apr 27 2017 06:29
@anderson2825
:+1:
Makrand R
@makrandr
Apr 27 2017 06:34
eh anyone?
Jordi Hereu
@jhereu
Apr 27 2017 06:36
@makrandr you are creating a function getCurrentPosition but I dont see it being called anywhere
Makrand R
@makrandr
Apr 27 2017 06:37
@JHereu
$("#location").html("latitude: " + latitude + "<br>longitude: " + longitude);
alpox
@alpox
Apr 27 2017 06:37
@makrandr Thats no function call
@makrandr You have to use the function getCurrentLocation somewhere
rugano
@rugano
Apr 27 2017 06:38
function palindrome(str){
//Good luck !
var re = /(\W+)\s(W+)/;
strPalindrome = "str";
var strPalindrome = '1 eye for of eye';
var newstr = str.replace(re,'$2,$1').toLowerCase('');
if(strPalindrome === "str"){
return true;
}
return false;
}

palindrome("eye");
Makrand R
@makrandr
Apr 27 2017 06:38
@alpox ohkay let me try it out
rugano
@rugano
Apr 27 2017 06:38
how do i correct this?
Jordi Hereu
@jhereu
Apr 27 2017 06:39
@makrand @alpox thats right, you have to get the jquery call outside that function, then call the function to retrieve the coords and then do the ajax thing
@rugano which is the desired output? There are a few things wrong
Long Nguyen
@longnt80
Apr 27 2017 06:43
rugano
@rugano
Apr 27 2017 06:43
@JHereu output is a boolean
Long Nguyen
@longnt80
Apr 27 2017 06:44
@rugano
what's this: var strPalindrome = '1 eye for of eye';?
Makrand R
@makrandr
Apr 27 2017 06:45
@JHereu something like Document.onload? and call function within it? If I'm just trying to show the co-ordinates on the screen?
rugano
@rugano
Apr 27 2017 06:46
@longnt80 it is a string to check if it is a palindrome
Jordi Hereu
@jhereu
Apr 27 2017 06:47
@rugano why are you using regex? Use foo.split("").reverse().join("") to revert the input and just compare it to the current input
alpox
@alpox
Apr 27 2017 06:48
@JHereu Regex is actually needed for this exercise since the string has to be manipulated first - but probably not the way @rugano did
Jordi Hereu
@jhereu
Apr 27 2017 06:48
@alpox oh, ok then ;)
alpox
@alpox
Apr 27 2017 06:48
@rugano You should not use your variable str as "str" because "str" is only a string with s-t-r in it :D
Long Nguyen
@longnt80
Apr 27 2017 06:48
@rugano
you just declare a new string for strPalindrome
rugano
@rugano
Apr 27 2017 06:48
@alpox How should i correct it?
alpox
@alpox
Apr 27 2017 06:49
@rugano "str" --> str
@rugano And for the regex - you have to remove the not-word characters. but you replace only whitespaces between non-word characters by a ,
Look over that again
@rugano Also, you will need a reverse() (You want to compare the string with its reversed variation for testing for a palindrome
Long Nguyen
@longnt80
Apr 27 2017 06:55

@alpox @rugano

Also, you will need a reverse() (You want to compare the string with its reversed variation for testing for a palindrome

I think he was trying to reverse the string with str.replace(re,'$2,$1') , which is wrong anyway

John Crisostomo
@johncrisostomo
Apr 27 2017 06:58
Markus Kiili
@Masd925
Apr 27 2017 06:58
@johncrisostomo No.
alpox
@alpox
Apr 27 2017 06:59
@johncrisostomo Nope
John Crisostomo
@johncrisostomo
Apr 27 2017 06:59
My code seems to be returning the expected numbers but for some reasons it is not accepting it.
@Masd925 @alpox thanks
CamperBot
@camperbot
Apr 27 2017 06:59
johncrisostomo sends brownie points to @masd925 and @alpox :sparkles: :thumbsup: :sparkles:
:cookie: 986 | @alpox |http://www.freecodecamp.com/alpox
:star2: 3941 | @masd925 |http://www.freecodecamp.com/masd925
alpox
@alpox
Apr 27 2017 06:59
@johncrisostomo Try clearing your browser cache and reload
Markus Kiili
@Masd925
Apr 27 2017 06:59
@johncrisostomo Post the code if that doesn't help.
Long Nguyen
@longnt80
Apr 27 2017 07:00
@johncrisostomo
does it give any error warning?
rajeshraj472
@rajeshraj472
Apr 27 2017 07:00

Hi all...need help...I am a beginner...trying to convert switch statement into a lookup table but not working. see below code:// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line

var lookup = {"alpha": "Adams", "bravo": "Boston", "charlie": "Chicago", "delta": "Denver", "echo": "Easy", "foxtrot": "Frank"};

val = ["alpha", "bravo", "charlie", "delta", "echo", "foxtrot"];
result = JSON.stringify(lookup.val);

/ switch(val) {
case "alpha":
result = "Adams";
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
}
/

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

// Change this value to test
phoneticLookup("alpha");

John Crisostomo
@johncrisostomo
Apr 27 2017 07:01
@alpox thanks, I will try to do that
CamperBot
@camperbot
Apr 27 2017 07:01
johncrisostomo sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:warning: johncrisostomo already gave alpox points
John Crisostomo
@johncrisostomo
Apr 27 2017 07:02
@longnt80 no it does not give any, but I will try to clear my history first
Yash Puthran
@nottoobright
Apr 27 2017 07:02
Can someone show me how to solve Counting Cards exercise?
I have been trying for over an hour now
John Crisostomo
@johncrisostomo
Apr 27 2017 07:02
brb
rajeshraj472
@rajeshraj472
Apr 27 2017 07:02
@johncrisostomo what do you need?
Jordi Hereu
@jhereu
Apr 27 2017 07:02
@makrandr Ok i'm now on a PC and looking at your code, the navigator.geolocation.getCurrentPosition(succesCallback...) is ok, just try to use a $(document).ready() call to wrap it all up, cause right now the code is executing before having it all loaded yet
Long Nguyen
@longnt80
Apr 27 2017 07:02
@johncrisostomo
just close the tab/quit FCC and open again
Yash Puthran
@nottoobright
Apr 27 2017 07:03
Can someone show me how to solve Counting Cards exercise?
Markus Kiili
@Masd925
Apr 27 2017 07:04
@Yash1408 No, but we can help.
Jacob
@Haudz
Apr 27 2017 07:04
Hey everyone, so I'm making a tic tac toe game and decided to use flex-box. I'm planning to put 3 small boxes that would hold the score and player info.. 1 top left, 1 bottom left and 1 top right(these 3 boxes will go outside of the flex container.) I didnt know if I should make a new flex box that wraps the original flex box as you see or if I should just move the 3boxes using css without a 2nd flex boxhttps://www.w3schools.com/code/tryit.asp?filename=FF29QV8TWXFU
Jordi Hereu
@jhereu
Apr 27 2017 07:04
rajeshraj472
@rajeshraj472
Apr 27 2017 07:04
@Yash1408 How can we help you?
Markus Kiili
@Masd925
Apr 27 2017 07:04
@Yash1408 Test card and increment count. Then test count and make a return. Don't mix those two parts.
rajeshraj472
@rajeshraj472
Apr 27 2017 07:05
@Masd925
alpox
@alpox
Apr 27 2017 07:05
@JHereu That is not quite true since codepen adds the scripts at the end of the page so they all surely load when the page is fully loaded
rajeshraj472
@rajeshraj472
Apr 27 2017 07:05
@Masd925 can you see into my problem above?
Yash Puthran
@nottoobright
Apr 27 2017 07:05

var count = 0;

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

That is my code
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:06

:bulb: To format your code, please follow:
http://i.imgur.com/AZjg4lK.jpg

More details..

Markus Kiili
@Masd925
Apr 27 2017 07:06
@Yash1408 Don't append any quotes to the result.
Testing like this 1<card>7 doesn't work as expected.
Yash Puthran
@nottoobright
Apr 27 2017 07:07
Should I test individually like card ===2 || card===3?
Markus Kiili
@Masd925
Apr 27 2017 07:08
@Yash1408 That or two conditions combined with &&
rajeshraj472
@rajeshraj472
Apr 27 2017 07:08

I am trying to convert switch statement into lookup table but not working. need help...// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line

var lookup = {"alpha": "Adams", "bravo": "Boston", "charlie": "Chicago", "delta": "Denver", "echo": "Easy", "foxtrot": "Frank"};

val = ["alpha", "bravo", "charlie", "delta", "echo", "foxtrot"];
result = JSON.stringify(lookup.val);

/ switch(val) {
case "alpha":
result = "Adams";
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
}
/

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

// Change this value to test
phoneticLookup("alpha");

Aizaz Shahid
@aizazshahid
Apr 27 2017 07:08
@Yash1408 here switch statement is better !
Yash Puthran
@nottoobright
Apr 27 2017 07:08
What's the problem in doing 1<card>7 ?
Dan Sack
@DanPete
Apr 27 2017 07:09
Is this the right idea for the convert to celsius? Or should it be refactored more? fahrenheit = celsius * (9/5) + 32;
Markus Kiili
@Masd925
Apr 27 2017 07:09
@Yash1408 1<card evaluates to a Boolean value that is compared with 7.
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:09
@DanPete yes !
Dan Sack
@DanPete
Apr 27 2017 07:09
Great thank, @forwebtech
CamperBot
@camperbot
Apr 27 2017 07:09
danpete sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 336 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:09
@DanPete it's also mentioned in the instructions !
Markus Kiili
@Masd925
Apr 27 2017 07:10
@forwebtech Using if is perfectly fine here.
Dan Sack
@DanPete
Apr 27 2017 07:10
Yea, I just wasn't sure about the variable assigning. looked a little weird at first glance.
Yash Puthran
@nottoobright
Apr 27 2017 07:10

var count = 0;

function cc(card) {
// Only change code below this line
var str = "";
if(card===2 || card===3|| card===4|| card===5|| card===6){
count++;
}
else if(card===10 || card==='J'|| card==='Q' || card==='K' || card==='A'){
count--;
}
else{
count = 0;
}
if(count<0){
str="Hold";
}
else{
str="Bet";
}
return + count + " " +str;
// 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');

Aizaz Shahid
@aizazshahid
Apr 27 2017 07:11
@Masd925 well i don't think so !
Yash Puthran
@nottoobright
Apr 27 2017 07:11
It's not satisfying two conditions
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:11
@Yash1408 don't put + after return
Chetan Vashistth
@chetanhere
Apr 27 2017 07:11
@Yash1408 Why don't you try it with Switch instead of if-else
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:12
return count + " " + str;
Yash Puthran
@nottoobright
Apr 27 2017 07:12
@chetanhere Let me try switch. Thanks
Chetan Vashistth
@chetanhere
Apr 27 2017 07:12
return + count + " " +str; here is the problem
@Yash1408 don't put + after return
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:13
told him ! @chetanhere
Chetan Vashistth
@chetanhere
Apr 27 2017 07:13
@forwebtech okay, I missed that. My bad
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:14
its ok !
rajeshraj472
@rajeshraj472
Apr 27 2017 07:14
Whats wrong with my code?

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

// Only change code below this line

var lookup = {"alpha": "Adams", "bravo": "Boston", "charlie": "Chicago", "delta": "Denver", "echo": "Easy", "foxtrot": "Frank"};

val = ["alpha", "bravo", "charlie", "delta", "echo", "foxtrot"];
result = JSON.stringify(lookup.val);

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

// Change this value to test
phoneticLookup("alpha");

need help
Darth Skywalker
@adityaparab
Apr 27 2017 07:15
result = lookup[val];
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:15

@rajeshraj472 :bulb: To format your code, please follow:
Code Formatting

More details..

rajeshraj472
@rajeshraj472
Apr 27 2017 07:16
@adityaparab tried that but still not working.
Darth Skywalker
@adityaparab
Apr 27 2017 07:17
@rajeshraj472 that's becuase you're modifying value of val. Don't do anything to val
rajeshraj472
@rajeshraj472
Apr 27 2017 07:17
yeah got it. @adityaparab
wilful
@wilfulSChou
Apr 27 2017 07:18
var testString = "How many non-space characters are there in this sentence?";
var expression = /\S+/g;
var nonSpaceCount = testString.match(expression).length;
Makrand R
@makrandr
Apr 27 2017 07:19
@JHereu you mean use document.ready outside of
navigator.geolocation.getCurrentPosition(function(position) {
im getting this error in browser console
tCurrentPosition() and watchPosition() no longer work on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details. (anonymous) @ pen.js:28
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:20
@wilfulSChou where is the problem ?
wilful
@wilfulSChou
Apr 27 2017 07:21
你的正则表达式应该在 testString 中找到 49 个非空白的字符
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:21
can you write in english ?
wilful
@wilfulSChou
Apr 27 2017 07:21
Your regular expression should find 49 non-blank characters in testString
I got 9
Yash Puthran
@nottoobright
Apr 27 2017 07:22
switch(cc(card)){
case 2:case 3:case 4:case 5:case 6:
count++;
break;
case 10:case 'J':case 'Q':case 'K':case 'A':
count--;
break;
default:
count = 0;
}
return count + " " +str;
// Only change code above this line
}
Shows, maximum call stack size exceeded
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:23
@wilfulSChou don't use +, in you regex !
wilful
@wilfulSChou
Apr 27 2017 07:23
Yes! Thank you
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:24
@wilfulSChou please visit this Regex
you can play with regex, there !
wilful
@wilfulSChou
Apr 27 2017 07:24
OK! I'll try
Yash Puthran
@nottoobright
Apr 27 2017 07:26
I need help with the Counting Cards exercise
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:26
@Yash1408 yes !

@Yash1408 :bulb: To format your code, please follow:
Code Formatting

More details..

Yash Puthran
@nottoobright
Apr 27 2017 07:27
  switch(cc(card)){
  case 2:case 3:case 4:case 5:case 6:
      count++;
       break;
    case 10:case 'J':case 'Q':case 'K':case 'A':
      count--;
      break;
    default:
      count = 0;
  }
  if(count<0){
    str="Hold";
  }
  else{
    str="Bet";
  }
  return  count + " " +str;
  // Only change code above this line
}
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:27
@Yash1408 did you remove the function keyword ??
Yash Puthran
@nottoobright
Apr 27 2017 07:27
It shows maximum call stack size exceeded
No, this is just the switch logic. Rest of the code is still there
str is also declared
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:28
@Yash1408 ok !
Yash Puthran
@nottoobright
Apr 27 2017 07:29

var count = 0;

function cc(card) {
  // Only change code below this line
  var str = "";

  switch(cc(card)){
  case 2:case 3:case 4:case 5:case 6:
      count++;
       break;
    case 10:case 'J':case 'Q':case 'K':case 'A':
      count--;
      break;
    default:
      count = 0;
  }
  if(count<0){
    str="Hold";
  }
  else{
    str="Bet";
  }
  return  count + " " +str;
  // Only change code above this line
}
This is the entire code
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:29
@Yash1408 you did wrong in parameter of switch !
just put switch ( c )
rajeshraj472
@rajeshraj472
Apr 27 2017 07:29
switch(card)
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:29
why are you doing that !
JDW
@jd-wheaton
Apr 27 2017 07:29
Have you ever coded for several hours without looking up and wonder how the fuck it's 3:29am?!
Yash Puthran
@nottoobright
Apr 27 2017 07:30
It's now not satisfying two conditions
wilful
@wilfulSChou
Apr 27 2017 07:30
if(count>0)
Markus Kiili
@Masd925
Apr 27 2017 07:30
@Yash1408 Don't assign 0 to count.
wilful
@wilfulSChou
Apr 27 2017 07:30
else{}
default:
break;
Yash Puthran
@nottoobright
Apr 27 2017 07:31
Okay, did that. Still it doesn't satisfy one condition. To show 0 Hold on 7 8 9 sequence
rajeshraj472
@rajeshraj472
Apr 27 2017 07:31
agree with @Masd925 . Don't assign 0 to count
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:32
@rajeshraj472 right ! @Yash1408 don't use default !
wilful
@wilfulSChou
Apr 27 2017 07:32
if(count>0){}else{}
Yash Puthran
@nottoobright
Apr 27 2017 07:32
Solved. I did if(count<=0)
rajeshraj472
@rajeshraj472
Apr 27 2017 07:33
kudos
Yash Puthran
@nottoobright
Apr 27 2017 07:33
Thanks @Masd925, @rajeshraj472 @forwebtech
CamperBot
@camperbot
Apr 27 2017 07:33
yash1408 sends brownie points to @masd925 and @rajeshraj472 and @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 207 | @rajeshraj472 |http://www.freecodecamp.com/rajeshraj472
:cookie: 337 | @forwebtech |http://www.freecodecamp.com/forwebtech
:star2: 3942 | @masd925 |http://www.freecodecamp.com/masd925
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:33
@Yash1408, make condition like:
if(count > 0)
    str = "Bet";
  else
    str = "Hold";
and also you didn't need default at there !
Yash Puthran
@nottoobright
Apr 27 2017 07:34
I did this
rajeshraj472
@rajeshraj472
Apr 27 2017 07:34

do you find any mistake here:var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty(checkProp)){
return JSON.stringify(myObj[checkProp]);
}
return "Not Found";
}

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

Yash Puthran
@nottoobright
Apr 27 2017 07:34
  if(count<=0){
    str="Hold";
  }
  else{
    str="Bet";
  }
Is your way better than this and why?
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:34
@Yash1408 yes in my one operator isn't used, = :D
count <= 0 can be change to count > 0
but remember to change the statement below !
Yash Puthran
@nottoobright
Apr 27 2017 07:35
Did that. Thanks @forwebtech
CamperBot
@camperbot
Apr 27 2017 07:35
yash1408 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:warning: yash1408 already gave forwebtech points
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:36
You're Welcome !
JDW
@jd-wheaton
Apr 27 2017 07:36
can anyone tell me why x.id and x.game say they are not properties for strings
@Injectable()
export class UserService {
  constructor(private http: Http,
  @Inject(TWITCH_API_URL) private apiUrl: string,
  @Inject(TWITCH_CLIENT_ID) private clientId: string) { }

  lookupUser(term: string): Observable<UserResult[]> {
    return this.http.get(`${this.apiUrl}streams/${term}?client_id=${this.clientId}`)
    .do(this.logVerdict)
    .map(this.siftData)
    .catch(this.errTrap);
  }

  private errTrap(error: Response | any) {
    console.log('--@FUNC:errTrap(ERROR):lookupUser:--', error);
    return Observable.throw(error.json().error || 'Server is taking a nap, try later');
  }

  private logVerdict(response: Response) {
    console.log('--@FUNC:logVerdict:lookupUser:--', response.json());
  }

  private siftData(response: Response) {
    const itsAnObj = (<any>response.json().stream);
    const noObj = (Object.keys(itsAnObj.map(key => itsAnObj[key])));
    console.log('--@FUNC:siftData:lookupUser:--', noObj);
    return noObj.map(x => {
      return new UserResult({
        _id: x._id,
        game: x.game
      });
    });
  }
}
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:37
@jd-wheaton jquery ??
JDW
@jd-wheaton
Apr 27 2017 07:37
Not jquery, Angular4
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:37
oh, thanks !
i was wondering that !
how can we use private in JS
JDW
@jd-wheaton
Apr 27 2017 07:38
it's part of typescript
an extension of JS ES6
it gets transpiled into JS
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:38
ok !
@jd-wheaton thanks for that info !
CamperBot
@camperbot
Apr 27 2017 07:38
forwebtech sends brownie points to @jd-wheaton :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @jd-wheaton |http://www.freecodecamp.com/jd-wheaton
Markus Kiili
@Masd925
Apr 27 2017 07:39
@Yash1408 It is also possible to use a lookup object or if's to solve it. Something like this:
function cc(card) {
  // Only change code below this line
  var VALUES = {2:1,3:1,4:1,5:1,6:1,7:0,8:0,9:0,10:-1,J:-1,Q:-1,K:-1,A:-1};
  count += VALUES[card];
  return count + " " + (count>0 ? "Bet" : "Hold");
  // Only change code above this line
}

function cc(card) {
  // Only change code below this line
  if (card<=6) count++;
  else if (card<=9);
  else count--;
  return count + " " + (count>0 ? "Bet" : "Hold");  
  // Only change code above this line
}
flansolo
@flansolo
Apr 27 2017 07:39
watch @Masd925 show off the mad skillz
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:40
@Masd925 great !
sunny
@sunshinehelloworld
Apr 27 2017 07:40

// Setup
var myStr = "Jello World";

// Only change code below this line

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

where is wrong?
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:41
@Masd925 but our card can also be 'string'
@sunshinehelloworld strings are immutable, that means you can't just change their part but can change whole string !
so assign H to it without assigning with [0]
Claudio Restifo
@Marmiz
Apr 27 2017 07:42
@Masd925 chapeau for the clean solution :tophat:
Chetan Vashistth
@chetanhere
Apr 27 2017 07:42
@Masd925 How can I share my code screen like this? I also want to ask some question in my code and sharing screen like this would help a lot
Aizaz Shahid
@aizazshahid
Apr 27 2017 07:42

:bulb: To format your code, please follow:
Code Formatting

More details..

rajeshraj472
@rajeshraj472
Apr 27 2017 07:43
Need Help:

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

function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty(checkProp)){
return JSON.stringify(myObj[checkProp]);
}
return "Not Found";
}

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

Markus Kiili
@Masd925
Apr 27 2017 07:43
@forwebtech It is no problem on the lookup solution, because bracket notation coerces all values to strings, because property keys are strings. On the if solution it adds some confusion yes. It might be better with a typeof check.