These are chat archives for FreeCodeCamp/HelpJavaScript

7th
Apr 2016
Elbert Cortez
@trip16661
Apr 07 2016 00:02
@daemedeor why not? xD isn't more simple to do it in that way?
Justin
@daemedeor
Apr 07 2016 00:03
@trip16661 because its not a function… you can’t pass everything
Elbert Cortez
@trip16661
Apr 07 2016 00:04
it's a function that i stated first

    function buttonSc(button,plusLess) {

        $(button).on("click",function () {
        plusLess;
        $("#wiseWords").html(objShortcut[a]).quote;    
        });

    };
Shirley Hicks
@Velochic
Apr 07 2016 00:05

Hey everyone! New kid here.

Am working on the Complete Testing Objects for Properties tutorial.

Having a bit of trouble and haven't been able to figure it out for the past few hours.

The code that I've written is:

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

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

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

Any insights?
Diego Mayer
@Chrono79
Apr 07 2016 00:06
This message was deleted
CamperBot
@camperbot
Apr 07 2016 00:06
no wiki entry for: format @velochic
trainrail
@trainrail
Apr 07 2016 00:06

Does anyone know what timezone does the new Date function interpret its input if the string inside does not conform es6 standard 20.3.1.16 like http://www.ecma-international.org/ecma-262/6.0/index.html#sec-date-time-string-format

For example new Date("2016-08-14 23:59:59") the output is local timezone, but what is the input timezone

random-x
@random-x
Apr 07 2016 00:07
@Velochic welcome :) first up, please re-paste using formatted code by doing what camperbot says:
help format
CamperBot
@camperbot
Apr 07 2016 00:07

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Diego Mayer
@Chrono79
Apr 07 2016 00:07
@Velochic remove the "" around checkProp
"checkProp" is a string, checkProp is the var name that contains the value passed to the function
Justin
@daemedeor
Apr 07 2016 00:09
@trip16661 i was talking about the a++ and the a--
those are not functions….
Shirley Hicks
@Velochic
Apr 07 2016 00:10
@Chrono79 - removed setting a text value for var result. Ran the test again - same results. The else statement is running, but the myObj.hasOwnProperty("checkProp") is not.
Elbert Cortez
@trip16661
Apr 07 2016 00:10
so i can't pass in those?
Diego Mayer
@Chrono79
Apr 07 2016 00:10
@Velochic it should be like this:
myObj.hasOwnProperty(checkProp)
Elbert Cortez
@trip16661
Apr 07 2016 00:10
how can i ?
Justin
@daemedeor
Apr 07 2016 00:10
@trip16661 not like that
Elbert Cortez
@trip16661
Apr 07 2016 00:11
how then?
Jonathan
@jonathantimm
Apr 07 2016 00:11
can anyone help me with the seek and destroy challenge?
Justin
@daemedeor
Apr 07 2016 00:12
@trip16661 well … you can either make a named function that gets called at a certain time and do buttonSc(“#before”,minusA) and then call it in the buttonSc class like plusLess();
@trip16661 then also the a would be undefined
imo you’re trying to abstract too much
Elbert Cortez
@trip16661
Apr 07 2016 00:13
I was trying to improve the code xDD
make it look pretty
Diego Mayer
@Chrono79
Apr 07 2016 00:13

@Velochic and this is wrong too:

result = myObj.hasOwnProperty("checkProp");

You should return myObj[checkProp]

Elbert Cortez
@trip16661
Apr 07 2016 00:14
I made it normally but i thought "mby i could just write a function instead of writing too much"
Shirley Hicks
@Velochic
Apr 07 2016 00:16
@Chrono79 - that did it! Thank you for helping find what I wasn't understanding.
CamperBot
@camperbot
Apr 07 2016 00:16
velochic sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 353 | @chrono79 | http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Apr 07 2016 00:18
@Velochic No problem, note you only can use bracket notation to refer a property using a var, i.e. MyObj.checkProp <- doesn't exists
Justin
@daemedeor
Apr 07 2016 00:20
@trip16661 the way its currently written, its hard to make a function, its basically only 2 similar lines
Elbert Cortez
@trip16661
Apr 07 2016 00:21
y
but i wanted to apply the concept of not repeating myself
Justin
@daemedeor
Apr 07 2016 00:22
@trip16661 yeah but… sometimes you make your code work harder than it needs to for minimal gains
Elbert Cortez
@trip16661
Apr 07 2016 00:24
y i get it
but kjust for studies purposes how would you do it
if that was the case?
Eric Murta
@murtinha
Apr 07 2016 00:24
Guys I have a question. Is this first advanced javascript challenge really only based uppon ifs and elses?
Paul Borawski
@iAmNawa
Apr 07 2016 00:25
@murtinha which challenge?
Justin
@daemedeor
Apr 07 2016 00:25
@trip16661 last thing before i need to go
$(document).ready(function() {
    //api link
  var a = 0;
    function buttonSc(button, toAdd) {

        $(button).on("click",function () {
          if(toAdd) a++;
          else a—;
        $("#wiseWords").html(objShortcut[a]).quote;    
        });

    };
    $("#submit").on("click", function() {
        var newQuery = apiAuthor + $("#author").val();
        var apiLink = api + newQuery;
        $.get(apiLink, function(xml) {
            var jsonApi = xml2json(xml, "");
            var result = JSON.parse(jsonApi);

                objShortcut = result.results.result;

            $("#wiseWords").html(objShortcut[0].quote);
            $("#wiseAuthor").html(objShortcut[0].author);
                buttonSc("#next", true);
                                buttonSc("#before");


        });

    });
});
Diego Mayer
@Chrono79
Apr 07 2016 00:25
@murtinha No, try using regex as suggested if you're talking about Validate US Telephone Numbers
Elbert Cortez
@trip16661
Apr 07 2016 00:26
oh
that's really smart so using bolean
@daemedeor thanks man
CamperBot
@camperbot
Apr 07 2016 00:27
trip16661 sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:warning: trip16661 already gave daemedeor points
Justin
@daemedeor
Apr 07 2016 00:27
@trip16661 only keeping line with your logic
Elbert Cortez
@trip16661
Apr 07 2016 00:29
I see :D is my logic wrong?
oh nvm u told me you were leaving have a nice day @daemedeor
Stephane
@overmelo
Apr 07 2016 00:30
j'ai besoin d'aide s'il vous plait? javascript
Justin
@daemedeor
Apr 07 2016 00:31
@trip16661 its not that its wrong… just not what i would do, we all think differently. I just try to tack on to your logic already just minor modifications, i wouldn’t even do that function :)
Diego Mayer
@Chrono79
Apr 07 2016 00:31
@overmelo If you're lucky someone will answer you, but you'll have better luck trying in english
mjqblade
@mjqblade
Apr 07 2016 00:32

help

var myStr; // Change this line

it says You should use two double quotes (") and four escaped double quotes (\") and Variable myStr should equal to ("I am a "double quoted" string inside "double quotes""). #plz help

plz help

plz help
Elbert Cortez
@trip16661
Apr 07 2016 00:33
did u see the example
mjqblade
@mjqblade
Apr 07 2016 00:33

challenge name Escaping Literal Quotes in Strings

yes'
Eric Murta
@murtinha
Apr 07 2016 00:35
@iAmNawa @Chrono79 Validate US Telephone Numbers, but regex would be the condition of one of the ifss.. so I can do it only using regex?
Elbert Cortez
@trip16661
Apr 07 2016 00:35
@mjqblade basicall whatever is inside of " " is a string but since there are some "" it tell the code that you are ennding the str and opening another one
so to avoid that you need to scape the " " inside of the first and last "
Miloud Bouzeboudja
@yassineldn29
Apr 07 2016 00:36
Stand in Line
mjqblade
@mjqblade
Apr 07 2016 00:36
oh ok
Miloud Bouzeboudja
@yassineldn29
Apr 07 2016 00:36
i dont understand Stand in Line
Paul Borawski
@iAmNawa
Apr 07 2016 00:36
@murtinha If all the tests pass, then you pass the challenge
Stephane
@overmelo
Apr 07 2016 00:37
@Chrono79 thats alright i finally had what i wanted
Elbert Cortez
@trip16661
Apr 07 2016 00:37
the way to scape well it's in the description i believe
rkDeason
@rkDeason
Apr 07 2016 00:37
the first Switch challenge is on my nerves. to post my code, do i need to do a screenshot or is there another way?
Elbert Cortez
@trip16661
Apr 07 2016 00:37
@rkDeason there is a format
Paul Borawski
@iAmNawa
Apr 07 2016 00:37
@murtinha yes you can do it all in regex
Elbert Cortez
@trip16661
Apr 07 2016 00:37
help format
CamperBot
@camperbot
Apr 07 2016 00:37

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

mjqblade
@mjqblade
Apr 07 2016 00:38
@trip16661 still don't get it
Diego Mayer
@Chrono79
Apr 07 2016 00:38
@murtinha you have to use a regex to validate any format, you could solve any challenge using ifs, but that's not the goal of the challenges
rkDeason
@rkDeason
Apr 07 2016 00:38
thank you trip16661
thanks @trip16661
CamperBot
@camperbot
Apr 07 2016 00:38
rkdeason sends brownie points to @trip16661 :sparkles: :thumbsup: :sparkles:
Eric Murta
@murtinha
Apr 07 2016 00:38
@iAmNawa I see @Chrono79 I'm not very good at regex though, but I'm gonna study it, thanks guys
CamperBot
@camperbot
Apr 07 2016 00:38
murtinha sends brownie points to @iamnawa and @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 286 | @trip16661 | http://www.freecodecamp.com/trip16661
:star: 351 | @iamnawa | http://www.freecodecamp.com/iamnawa
:star: 354 | @chrono79 | http://www.freecodecamp.com/chrono79
mjqblade
@mjqblade
Apr 07 2016 00:38
@trip16661 still don't get it
kyle
@gnefkow
Apr 07 2016 00:39
like this?
Elbert Cortez
@trip16661
Apr 07 2016 00:39
@mjqblade what part of it? don't you get how to scape or don't you get what to do
mjqblade
@mjqblade
Apr 07 2016 00:39
all of it I'm 10 years old
Diego Mayer
@Chrono79
Apr 07 2016 00:40
@murtinha check these links:
http://regexone.com/
https://regex101.com/
kyle
@gnefkow
Apr 07 2016 00:40
Hey, I'm a little stuck on "Stand in Line"
Diego Mayer
@Chrono79
Apr 07 2016 00:41
@gnefkow Paste your code and let's see
kyle
@gnefkow
Apr 07 2016 00:41
I can get all of the checked requirements except for the first one "nextInLine([], 1) should return 1"
here is my code...
rkDeason
@rkDeason
Apr 07 2016 00:41
This message was deleted
kyle
@gnefkow
Apr 07 2016 00:41
function nextInLine(arr, item) {
  // Your code here
  var removedItem = arr[0];
  arr.push(item);
  arr.shift();
  return removedItem;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log(nextInLine([], 1));
console.log(nextInLine([2], 1));
console.log(nextInLine([5,6,7,8,9], 1));
console.log("After: " + JSON.stringify(testArr));
mjqblade
@mjqblade
Apr 07 2016 00:41
gtg eat supper @trip16661 if u can leave the help in chat ill find it
rkDeason
@rkDeason
Apr 07 2016 00:42

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

}

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

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

Paul Borawski
@iAmNawa
Apr 07 2016 00:42
@gnefkow there is an issue
Diego Mayer
@Chrono79
Apr 07 2016 00:42
@gnefkow you shouldn't use arr[0]
if arr is empty [] arr[0] is undefined
Eric Murta
@murtinha
Apr 07 2016 00:43
@Chrono79 thanks
CamperBot
@camperbot
Apr 07 2016 00:43
murtinha sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
kyle
@gnefkow
Apr 07 2016 00:43
use arr[0] where?
CamperBot
@camperbot
Apr 07 2016 00:43
:warning: murtinha already gave chrono79 points
rkDeason
@rkDeason
Apr 07 2016 00:43
in my above switch code, the output is correct but it still gives me errors. what to do?
caseInSwitch(1) should have a value of "alpha" etc. errors
Diego Mayer
@Chrono79
Apr 07 2016 00:44
@gnefkow google array.shift() to see what it does
kyle
@gnefkow
Apr 07 2016 00:44
sorry, I'll use @ since there are a couple of conversations going on here - @iAmNawa - where should I use arr=[0] ?
ah, ok...
rkDeason
@rkDeason
Apr 07 2016 00:45
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case 1:
      answer = "alpha";
      break;
    case 2:
      answer = "beta";
      break;
    case 3:
      answer = "gamma";
      break;
    case 4:
      answer = "delta";
      break;

  }


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

// Change this value to test
myTest(1);
Ghost
@ghost~56ea103685d51f252ab937b2
Apr 07 2016 00:47
@rkDeason i think you change function name
myTest should be caseInSwitch
Paul Borawski
@iAmNawa
Apr 07 2016 00:48
@gnefkow
first add the number to the end of the array
rkDeason
@rkDeason
Apr 07 2016 00:48
OMG! thank you! @printdhruv that was it
CamperBot
@camperbot
Apr 07 2016 00:48
rkdeason sends brownie points to @printdhruv :sparkles: :thumbsup: :sparkles:
Paul Borawski
@iAmNawa
Apr 07 2016 00:48
arr.push(item);
CamperBot
@camperbot
Apr 07 2016 00:48
:star: 210 | @printdhruv | http://www.freecodecamp.com/printdhruv
Ghost
@ghost~56ea103685d51f252ab937b2
Apr 07 2016 00:48
@rkDeason my pleasure!
Paul Borawski
@iAmNawa
Apr 07 2016 00:49
remove the element of the first array var removed = arr.shift();
return removed;
Ken Haduch
@khaduch
Apr 07 2016 00:49
@robdesautel - just came back to the computer... I'm here now...
Paul Borawski
@iAmNawa
Apr 07 2016 00:49
That’s the solution
kyle
@gnefkow
Apr 07 2016 00:49
ok...
Paul Borawski
@iAmNawa
Apr 07 2016 00:49
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  var removed = arr.shift();
  return removed;  // Change this line
}
kyle
@gnefkow
Apr 07 2016 00:50
oh!
Paul Borawski
@iAmNawa
Apr 07 2016 00:50
add it, remove it, return it
kyle
@gnefkow
Apr 07 2016 00:51
awesome, thanks!
yeah, I see what I was doing wrong
Paul Borawski
@iAmNawa
Apr 07 2016 00:52
no problem
Sometimes it helps to look very literally at what they are saying, they usually have the process in a sequence
abtak mustapha
@mustapha88
Apr 07 2016 00:53
HELP CSS
CamperBot
@camperbot
Apr 07 2016 00:53

:point_right: challenge change the css of an element using jquery [wiki]

Change the CSS of an Element Using jQuery

We can also change the CSS of an HTML element directly with jQuery.

Query has a function called .css() that allows you to change the CSS of an element.

<script>
  $(document).ready(function() {
    $("#target1").css("color", "red");

  });
</script>

:pencil: read more about challenge change the css of an element using jquery on the FCC Wiki

Ken Haduch
@khaduch
Apr 07 2016 01:00

@swimrr

@khaduch thanks, I was going through my portfolio to get to the last one I did, but by going through the Map I can go right there.

It seems to me that it always "remembers" the last challenge that I looked at, even if it was one that I already completed, so I would say that I expect it to sequence through them as you complete them and remember where you were? I hope it's working better for you?

CamperBot
@camperbot
Apr 07 2016 01:00
khaduch sends brownie points to @swimrr :sparkles: :thumbsup: :sparkles:
:star: 215 | @swimrr | http://www.freecodecamp.com/swimrr
Ghost
@ghost~56ea103685d51f252ab937b2
Apr 07 2016 01:05

var count = 0;

function cc(card) {
// Only change code below this line
switch(card)
{
case '2':

case '3':

case '4':

case '5':

case '6':
    count++;
    break;
  case '7':
    break;
  case '8':
    break;
  case '9':
    break;
  case '10':

  case 'J':

  case 'Q':

  case 'K':

  case 'A':
    count--;
    break;
  default:
    return "Change Me";
}
if(count>0)
  {
    return(count+" Bet");

  }

else if(count<0)
{
return(count+" Hold");
}

// Only change code above this line
}

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

Diego Mayer
@Chrono79
Apr 07 2016 01:07

@printdhruv

 default: // <- not needed
    return "Change Me";
}
if(count>0)
  {
    return(count+" Bet");

  }
else if(count<0) // condition not needed but if you want to put it you're missing the = case
{
return(count+" Hold");
}

Alos evaluate the cards 2 to 10 as numbers, not strings

Ghost
@ghost~56ea103685d51f252ab937b2
Apr 07 2016 01:09
@Chrono79 error was i put numbers in the string
BuoRotti
@BuoRotti
Apr 07 2016 01:10

hi printdhruv would you help me ? function phoneticLookup(val) {
var result = "";

// Only change code below this line
var good = {
"alpha":"Adams",

"bravo":"Boston",

 "charlie":"Chicago",

 "delta":"Denver",

 "echo":"Easy",

 "foxtrot":"Frank",

  "":"undefined",
   };

// Only change code above this line
return good[val];
}
var drink = phoneticLookup('charlie');
// Change this value to test
console.log(drink);
I hava blank result??

abtak mustapha
@mustapha88
Apr 07 2016 01:10
some one free to help me
Diego Mayer
@Chrono79
Apr 07 2016 01:11
@BuoRotti delete this:
,

  "":"undefined",
abtak mustapha
@mustapha88
Apr 07 2016 01:13
any one free t o help please
Diego Mayer
@Chrono79
Apr 07 2016 01:13
@mustapha88 with what?
abtak mustapha
@mustapha88
Apr 07 2016 01:14
@Chrono79 myabe i think i have problemes with css in my rundom quotes app
BuoRotti
@BuoRotti
Apr 07 2016 01:15
thank you Chrono79!!!
Diego Mayer
@Chrono79
Apr 07 2016 01:16
no problem
abtak mustapha
@mustapha88
Apr 07 2016 01:16
@Chrono79 do you have time for check my app
Diego Mayer
@Chrono79
Apr 07 2016 01:17
paste your link
@Chrono79 i want to put quotes in greeen box i try many times but still not working
Diego Mayer
@Chrono79
Apr 07 2016 01:19
@mustapha88 quote [1]="“You only live once, but if you do it right, once is enough. ― Mae West " <- you have "" in this line and a lot of missing ; in your code
if you want to display double quotes in a string you can escape them quote[0] = "this is an escaped double quote \" ";
abtak mustapha
@mustapha88
Apr 07 2016 01:21
@Chrono79 when i put semicolone it tell that is error
Ken Haduch
@khaduch
Apr 07 2016 01:23

@robdesautel - I was thinking about what I think your question was last night. I'll try to summarize what I was thinking, in case it isn't what you were asking. I think that the question was about using myObj.hasOwnProperty() in an if clause? Basically, that method returns true or false depending on whether or not the object has the property that you are testing for. I think we were discussing using it in the if statement as if ( myObj.hasOwnProperty)? The concept is similar to performing other tests, such as if ( a === b ) or if ( a === arr.length ) etc. All of those return either true or false as the result. Now you can write a test condition if ( (a === b) === true ) and you can write if ( myObj.hasOwnProperty(value) === true ) but I guess you would call it an idiom that you wouldn't normally include the check for === true because if the comparison (or the function) evaluates to true, or as they call them in the lessons truthy values, it is redundant to add that extra check, because the if condition is looking for a true outcome, and effectively you would be saying if ( true === true )! So the next thing is that anything that evaluates to true will trigger the if condition's block of code.

Another example that popped into my mind is that sometimes you might want to have some debug code in your program, and at least as I've done this in the past, would declare a variable such as debugFlag, and set it to either true or false depending on whether or not I wanted to execute the special debug code. So that looks like this:

var debugFlag = true;  // set it to 'true' to enable debug
if (debugFlag) {
    // execute some debug code, console.log statements, etc.
}

Now you could write that as:

var debugFlag = true;
if ( debugFlag === true ) {
    // execute some debug code, console.log statements, etc.
}

But that's redundant because writing if ( debugFlag ) { // etc. } does test that the value of that variable is true or false and act accordingly.

Maybe that wasn't what you were getting at in last night's question / answer thread, but I thought that it was? And sorry that it got kind of long...

tjhpae
@tjhpae
Apr 07 2016 01:40
hi guys i think i found a bug
Ken Haduch
@khaduch
Apr 07 2016 01:41
@tjhpae - what's the bug?
tjhpae
@tjhpae
Apr 07 2016 01:41
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(firstName, prop){
// Only change code below this line
  var result;
  for (var i = 0; i<contacts.length; i++) {
    if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop) === true) {
      return contacts[i][prop];
    }

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

  return result;
// Only change code above this line

}
// Change these values to test your function
lookUp("Akira", "address");
this is my code for Profile Lookup
I tested all the parameters and received all the solutions it's looking for
but i can't seem to "pass" the challenge
Diego Mayer
@Chrono79
Apr 07 2016 01:44
@tjhpae recently function names have been changed could it be the case?
tjhpae
@tjhpae
Apr 07 2016 01:44
no idea? lol
how would i know?
also, can anyone explain to me how the "return" feature works in a function if it's nested in Ifs and Else Ifs?
i think my issue here is that idk when it exits the function or when it doesn't
Ken Haduch
@khaduch
Apr 07 2016 01:45
@tjhpae - yeah, it is a new thing. Check the test code and results very carefully - see which function they are trying to call, and change your names to match them. It is a bit confusing, to say the least! I filed an issue to see about putting a test for the expected function name...
Diego Mayer
@Chrono79
Apr 07 2016 01:49
@tjhpae The function name is now lookUpProfile instead of lookUp
Ken Haduch
@khaduch
Apr 07 2016 01:49

@tjhpae - oh, yes, I didn't look at your code. In the for loop, you are looking for contacts that match. If you don't find one that matches, then you get that else if (contacts[i] != prop)... which actually is not correct anyway. contacts[i] would be referring to an entire object, which would never match the property... but - getting back to your question at hand. Any time you hit a return statement, the function exits at the point and returns the value that you've specified to the caller. So you need to make sure that you can get through the entire list of contacts before you return "No Such Contact"...

Basically you should review the tests that you're doing and make sure that you're checking for the right things. The first test looks good.

but you have to restructure the remainder of those tests.
I don't know if you want to go back and look at it - ask if you need more help?
Diego Mayer
@Chrono79
Apr 07 2016 01:52
@tjhpae change the function name to the new one
dwayneabutcher
@dwayneabutcher
Apr 07 2016 01:57
Hey everyone, Back at it again today. I'm struggling with "Accessing Objects Properties with Variables" Could someone please critique this and explain why it's not working.
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[16];      // Change this Line
var player = "Montana";   // Change this Line
Diego Mayer
@Chrono79
Apr 07 2016 01:58
@dwayneabutcher you have to define playerNumber as a number and player as testObj[playerNumber]
Gabriel Lopez
@ztarfrog
Apr 07 2016 01:58

hey guys can you helpme?
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++){

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

}

// Only change code above this line
}

dont know what the problem is
dwayneabutcher
@dwayneabutcher
Apr 07 2016 02:00
@Chrono79 Like so?
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;      // Change this Line
var player = testObj[16];   // Change this Line
Diego Mayer
@Chrono79
Apr 07 2016 02:00
@dwayneabutcher check your last line, that's not what I said
Ken Haduch
@khaduch
Apr 07 2016 02:00

@dwayneabutcher - the tests for that lesson are:

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

and it looks like you just posted the answer, so you got it! I hope it passed...

dwayneabutcher
@dwayneabutcher
Apr 07 2016 02:01
Unfortunately it didn't pass. I'm failing on "You should use bracket notation to access testObj"
I thought that's what I was doing? Lol
Diego Mayer
@Chrono79
Apr 07 2016 02:01
@dwayneabutcher you have to define playerNumber as a number and player as testObj[playerNumber] <- THIS
Ken Haduch
@khaduch
Apr 07 2016 02:02

@dwayneabutcher - using the test information as additional guidelines to generate or fix the code is sometimes helpful!

It looks like you're
using bracket notation?

Ariel
@abibliophile
Apr 07 2016 02:02
hi everyone! close to finishing the chunky monkey algorithm but having a bit of a hangup.
function chunkArrayInGroups(arr, size) {
var result=[];
for (var i=0;i<arr.length;i+=size){
 result.push(arr.slice(i));
}
  return result;
}
chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3);
Diego Mayer
@Chrono79
Apr 07 2016 02:03
@abibliophile You don't use size in your slice call, check that, google javascript array.slice
Ken Haduch
@khaduch
Apr 07 2016 02:03
@dwayneabutcher - oh, you should not have the 16 in the brackets, but you should be using the variable playerNumber
dwayneabutcher
@dwayneabutcher
Apr 07 2016 02:04
That worked, Thanks @Chrono79 and @khaduch
CamperBot
@camperbot
Apr 07 2016 02:04
dwayneabutcher sends brownie points to @chrono79 and @khaduch :sparkles: :thumbsup: :sparkles:
:star: 868 | @khaduch | http://www.freecodecamp.com/khaduch
:star: 355 | @chrono79 | http://www.freecodecamp.com/chrono79
Ken Haduch
@khaduch
Apr 07 2016 02:04
because [16] :arrow_left: having that is an array address syntax.
Ariel
@abibliophile
Apr 07 2016 02:05
@Chrono79 if I use arr.slice(i, size) it puts out one of the two arrays i need
if I just use arr.slice(i) it puts out the other
Leo19909
@Leo19909
Apr 07 2016 02:08
Guys. How to solve the problem. My website www.chudo-agenstvo.ru. Not working contact form says - Uncaught TypeError: $(...).datepicker is not a function
Diego Mayer
@Chrono79
Apr 07 2016 02:09
@Leo19909 check if jquery is called in your head
tjhpae
@tjhpae
Apr 07 2016 02:09
@Chrono79 that fixed it. Thanks you
CamperBot
@camperbot
Apr 07 2016 02:09
tjhpae sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
tjhpae
@tjhpae
Apr 07 2016 02:09
@khaduch thank you for the explanation
CamperBot
@camperbot
Apr 07 2016 02:09
:star: 356 | @chrono79 | http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Apr 07 2016 02:09
@abibliophile slice with only one parameter cut the string from that parameter to the string end
with 2 cut from the first parameter to the second <- I think this is what you really want
tjhpae
@tjhpae
Apr 07 2016 02:10
@khaduch can you help me understand the "returns" in this case?
Ken Haduch
@khaduch
Apr 07 2016 02:10
@ztarfrog - it looks like no one has responded? You are doing something that is a common problem - the "for" loop has to iterate through all of the contacts before it can determine "no such contact". So if the firstName you are given is not the first name in the array of contacts, you will immediately return no such contact without checking all of the others. that means you need to adjust how you are running that test.
tjhpae
@tjhpae
Apr 07 2016 02:10
with the code i sent before, it should go line by line right?
so if i type in lookUpProfile("Kristian", "lastName");
Ariel
@abibliophile
Apr 07 2016 02:11
@Chrono79 I'm not quite sure I follow.
tjhpae
@tjhpae
Apr 07 2016 02:11
shouldn't it stop at the first If statement?
since both of these parameters are present?
Diego Mayer
@Chrono79
Apr 07 2016 02:14
@abibliophile An example:
str = "Hello world";
newStr = str.slice(3); // "o world"
newStr = str.slice(3 , 6); // "o w";
Do you see why the second option is what you need?
Ken Haduch
@khaduch
Apr 07 2016 02:14

@tjhpae - I don't know how much to give you without giving the answer but here goes an explanation -
your for loop has the potential to look at all of the entries in the contacts array.
if you find a contact that matches the firstName, then you can decide whether or not the contact has the requested property.
if the contact that you are testing doesn't match the firstName, then you have to make sure that there is no other contact that could match that firstName. Only after you have given each contact a check, can you return No such contact. If there is a firstName match, then you can either return the requested property value, or "No such property". Each return that you take will end the for loop. Sometimes that isn't going to be correct, because if the firstName that you get for the search is the third contact in the list, you need to be able to get to that contact before taking action and returning.

Does that help? I might have been rambling there...

Ariel
@abibliophile
Apr 07 2016 02:16
@Chrono79 Yes, that makes sense, because otherwise I'll just make one cut and return the rest of the string. I'm just not sure now what to use as my parameters.
tjhpae
@tjhpae
Apr 07 2016 02:16
@khaduch well if it's any consolation, i know what the answer is. i found it by tweaking my "return" statements, but it still doesn't answer my question
Ariel
@abibliophile
Apr 07 2016 02:16
I thought it would make sense to use (0,i), but it doesn't work
tjhpae
@tjhpae
Apr 07 2016 02:16

"If there is a firstName match, then you can either return the requested property value, or "No such property"

i don't think this applies to me because the way my code is written, it will always pull the corresponding 'prop' with the first name

Diego Mayer
@Chrono79
Apr 07 2016 02:16
@abibliophile I'll suggest i+size as the end
tjhpae
@tjhpae
Apr 07 2016 02:16
since i wrote it as an && statement
Ken Haduch
@khaduch
Apr 07 2016 02:17

@tjhpae

shouldn't it stop at the first If statement?

To comment on that directly, the names that you passed in your example are in the third entry (index = 2) so you have to go through the for loop three times before you "see" that. So when you get to index = 2 and are looking at the contact "Kristian", then you can match it and return.

Leo19909
@Leo19909
Apr 07 2016 02:17
@Chrono79 if you remove the line <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>. It says Uncaught TypeError: Cannot read property 'datepicker' of null
Ariel
@abibliophile
Apr 07 2016 02:17
so, it worked with the parameters (i, i+size) @Chrono79
I guess that makes sense considering that i starts at 0
thanks! @Chrono79 need to consider more about how it works but it's coming clear and I passed the challenge!
CamperBot
@camperbot
Apr 07 2016 02:18
abibliophile sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 357 | @chrono79 | http://www.freecodecamp.com/chrono79
Ken Haduch
@khaduch
Apr 07 2016 02:19
@tjhpae - what does your code look like now - I don't understand what you changed?
Diego Mayer
@Chrono79
Apr 07 2016 02:19
@Leo19909 then that's not the problem
Could you paste your codepen or whatever you're using?
Leo19909
@Leo19909
Apr 07 2016 02:21
@Chrono79 ok
tjhpae
@tjhpae
Apr 07 2016 02:22
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  var result;
  for (var i = 0; i<contacts.length; i++) {
    if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop) === true) {
      return contacts[i][prop];
    }

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

  return result;
// Only change code above this line

}
// Change these values to test your function
lookUpProfile("Kristian", "lastName");
i guess idk why this combination works
with the return, result, return
Leo19909
@Leo19909
Apr 07 2016 02:24
@Chrono79 What then should choose to correctly paste code in chat?
Diego Mayer
@Chrono79
Apr 07 2016 02:25
@tjhpae I think this isn't right:
contacts[i] != prop
Jovan Curayag
@curayagjovan
Apr 07 2016 02:25
``
tjhpae
@tjhpae
Apr 07 2016 02:25
i pass the lesson though @Chrono79
Jovan Curayag
@curayagjovan
Apr 07 2016 02:25
``
``
Gabriel Lopez
@ztarfrog
Apr 07 2016 02:25
@khaduch thanks! ! , and thanks all for the answerS!
CamperBot
@camperbot
Apr 07 2016 02:25
ztarfrog sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 869 | @khaduch | http://www.freecodecamp.com/khaduch
Jovan Curayag
@curayagjovan
Apr 07 2016 02:26

``

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

return item; // Change this line
}

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

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

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

return item; // Change this line
}

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

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

tjhpae
@tjhpae
Apr 07 2016 02:26
@Chrono79 why do you think that isn't right?
If prop does not correspond to any valid properties then return "No such property"
Jovan Curayag
@curayagjovan
Apr 07 2016 02:26
function nextInLine(arr, item) {
  // Your code here


  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 10)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
how to answer this?
Diego Mayer
@Chrono79
Apr 07 2016 02:27
@tjhpae you are comparing an object to a string there I think
tjhpae
@tjhpae
Apr 07 2016 02:27
@curayagjovan if you want the answer, just google it. if you want help, please ask specific questions
Leo19909
@Leo19909
Apr 07 2016 02:27
var code = "formatted";
@Chrono79 (shift+enter for line break) var code = "formatted";
Alejandro Tejada
@wannabecoding
Apr 07 2016 02:27
var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 1;
};

// Only change code below this line.

var myCar = new Car();
  {
    wheels = 4;
    engines = 1;
    seats = 4;
    myCar.nickname = "slowpoke";
  }
is this done right?
Leo19909
@Leo19909
Apr 07 2016 02:28

@Chrono79 ```

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

<!-- Это необходимо добавить, чтобы все функционировало -->
<script src="js/jquery.maskedinput.js" type="text/javascript"></script>
<link rel="stylesheet" media="screen" type="text/css" href="css/datepicker.css" />
<link rel="stylesheet" media="screen" type="text/css" href="css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap-clockpicker.min.css">
<script>
    $(function () {
        $('.datepicker').datepicker ();
        $("#date").mask("99/99/9999");
        $("#phone").mask("+7 (999) 999-9999");
        $("#from").mask("99:99");
        $("#to").mask("99:99");

        $('#send').click(function() {
            var name = $('#name').val();
            var email = $('#email').val();
            var date = $('#date').val();
            var phone = $('#phone').val();
            var from = $('#from').val();
            var to = $('#to').val();

            if (name == "") {
                $('#msg').html('Введите имя');
                return false;
            } else if (email == "") {
                $('#msg').html('Введите Email');
                return false;
            } else if (date == "") {
                $('#msg').html('Вы не указали дату');
                return false;
            } else if (phone == "") {
                $('#msg').html('Укажите телефон');
                return false;
            } else if (from == "" || to == "") {
                $('#msg').html('Не указано время звонка');
                return false;
            }

            $.ajax({
                url:        '/ajax.php',
                type:        'POST',
                cache:         false,
                beforeSend: function() {
                    $('#msg').html('Секунду...');
                },
                data:       {'name':name, 'email':email, 'date':date, 'phone':phone, 'from':from, 'to':to},
                dataType:    'html',
                success: function(data){
                    $('#msg').html(data);
                }
            });
        });
    });
</script>

</head>
<body>

  <div class="well"> <!-- Можете удалить этот блок, кроме инпутов! class="well" просто для красоты -->
      <input type="text" class="datepicker form-control" style="width:200px" placeholder="Укажите дату (мм/дд/гггг)" name="date" id="date"><br>
      <input type="text" class="form-control" style="width:200px" placeholder="Имя" name="name" id="name"><br>
      <input type="email" class="form-control" style="width:200px" placeholder="Email" name="email" id="email"><br>
      <input type="text" class="form-control" style="width:200px" placeholder="Телефон" name="phone" id="phone"><br>
      <p>Время звонка</p>
      <input class="form-control single-input" value="" placeholder="Звонить с" style="width:100px" id="from"><br>
    <input class="form-control single-input" value="" placeholder="До" style="width:100px" id="to"><br>
      <div id="msg"></div>
      <button type="button" class="btn btn-success-outline" id="send">Отправить</button>
  </div>

<!-- Ниже все нужно для выбора времени -->
<script src="js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="js/bootstrap-clockpicker.min.js"></script>
<script type="text/javascript">
var input = $('.single-input').clockpicker({
    placement: 'bottom',
    align: 'left',
    autoclose: true,
    'default': 'now'
});
</script>

```

tjhpae
@tjhpae
Apr 07 2016 02:28
i'm so confused
Solomon Barayev
@sbarayev
Apr 07 2016 02:28

guys maybe you can help (this has nothing to do with FCC) just my own little project, can't seem to get a function to work, in short, when i click on a box (as seen from boxes event listener) all the notes play instead of just the corresponding index in the notes array...
'''
var h1 = document.querySelector("h1");
var boxes = document.querySelectorAll(".box");
var notes = document.querySelectorAll(".audio");

function playBoxes(){
for(i=0; i<boxes.length; i++){
boxes[i].addEventListener("click", function(){
for(j = 0; j < notes.length; j++){
if(i = j){
notes[i].currentTime = 0;
notes[i].play();
}
}
});
}
}

playBoxes();
'''

CamperBot
@camperbot
Apr 07 2016 02:28
:bulb: to format code use backticks! ``` more info
Leo19909
@Leo19909
Apr 07 2016 02:29
@Chrono79 if you remove the line <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>. It says Uncaught TypeError: Cannot read property 'datepicker' of null
Solomon Barayev
@sbarayev
Apr 07 2016 02:29
var h1 = document.querySelector("h1");
var boxes = document.querySelectorAll(".box");
var notes = document.querySelectorAll(".audio");


function playBoxes(){
    for(i=0; i<boxes.length; i++){
        boxes[i].addEventListener("click", function(){
            for(j = 0; j < notes.length; j++){
                if(i = j){
                    notes[i].currentTime = 0;
                    notes[i].play();
                }
            }
        });
    }
}

playBoxes();
^^^
guys maybe you can help (this has nothing to do with FCC) just my own little project, can't seem to get a function to work, in short, when i click on a box (as seen from boxes event listener) all the notes play instead of just the corresponding index in the notes array...
'''
CamperBot
@camperbot
Apr 07 2016 02:29
:bulb: to format code use backticks! ``` more info
Diego Mayer
@Chrono79
Apr 07 2016 02:30
@Leo19909 don't remove it
Leo19909
@Leo19909
Apr 07 2016 02:31
@Chrono79 if you do not delete it says Uncaught TypeError: $(...).datepicker is not a function
Diego Mayer
@Chrono79
Apr 07 2016 02:32
@Leo19909 are you sure this is file is there? <script src="js/bootstrap-datepicker.js"></script> also put type="text/javascript"
Jovan Curayag
@curayagjovan
Apr 07 2016 02:32
@tjhpae I dont understand the instruction.
Ken Haduch
@khaduch
Apr 07 2016 02:32

@tjhpae - ah, interesting... that might work depending on the way the tests are run, or maybe all the time. The reason is that now you are not doing the actual return from within the for loop, but you are setting a result variable which will be returned if the no contacts match. So it should be good. The first test will return if you match the firstname and the property exists. The second test will just set result, and it is likely that that will get set for three out of four contacts, or perhaps for all four. In that case, you are not returning but continuing through the loop. The third test is one that is suspicious looking... I guess that with the order that you have it, it will return "No such property", but it is really not a proper test, because contacts[i] is only referencing the array element which is a contact - I think that test will always pass because the object will not be equal to the property. It should really be a test that looks like this - a corollary to your first test:

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

but this could all be optimized a bit in that for the first test you are doing, and my suggested third test, both of them are predicated on the first name matching. So you could write it as:

for ( ... ) {
    if (contacts[i].firstName === firstName) {
        if ( contacts[i].hasOwnProperty(prop) ) {
            return contacts[i][prop];
        } else {
            return "No such property";
        }
    }
}
// and outside of the for loop
return "No such contact";
Leo19909
@Leo19909
Apr 07 2016 02:33

@Chrono79 No. Here is the correct file ```
<link href='http://fonts.googleapis.com/css?family=Lato:300' rel='stylesheet' type='text/css'>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="templates/pri_simple/js/jquery.maskedinput.js" type="text/javascript"></script>
<link rel="stylesheet" media="screen" type="text/css" href="templates/pri_simple/css/datepicker.css" />
<link rel="stylesheet" media="screen" type="text/css" href="templates/pri_simple/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="templates/pri_simple/css/bootstrap-clockpicker.min.css">
<script>
$(function () {
$('.datepicker').datepicker ();
$("#date").mask("99/99/9999");
$("#phone").mask("+7 (999) 999-9999");
$("#from").mask("99:99");
$("#to").mask("99:99");

        $('#send').click(function() {
            var name = $('#name').val();
            var email = $('#email').val();
            var date = $('#date').val();
            var phone = $('#phone').val();
            var from = $('#from').val();
            var to = $('#to').val();

            if (name == "") {
                $('#msg').html('Введите имя');
                return false;
            } else if (email == "") {
                $('#msg').html('Введите Email');
                return false;
            } else if (date == "") {
                $('#msg').html('Вы не указали дату');
                return false;
            } else if (phone == "") {
                $('#msg').html('Укажите телефон');
                return false;
            } else if (from == "" || to == "") {
                $('#msg').html('Не указано время звонка');
                return false;
            }

            $.ajax({
                url:        '/ajax.php',
                type:        'POST',
                cache:         false,
                beforeSend: function() {
                    $('#msg').html('Секунду...');
                },
                data:       {'name':name, 'email':email, 'date':date, 'phone':phone, 'from':from, 'to':to},
                dataType:    'html',
                success: function(data){
                    $('#msg').html(data);
                }
            });
        });
    });
</script>
</head>
<body <?php echo $this->helix->bodyClass('bg hfeed clearfix'); ?>>
    <div class="body-innerwrapper">
    <!--[if lt IE 8]>
    <div class="chromeframe alert alert-danger" style="text-align:center">You are using an <strong>outdated</strong> browser. Please <a target="_blank" href="http://browsehappy.com/">upgrade your browser</a> or <a target="_blank" href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</div>
    <![endif]-->
    <?php
        $this->helix->layout();
        $this->helix->Footer();
    ?>
    <jdoc:include type="modules" name="debug" />
    </div>
  <!-- BEGIN JIVOSITE CODE {literal} -->

<script type='text/javascript'>
(function(){ var widget_id = 'jkzNiuCKmK';
var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = '//code.jivosite.com/script/widget/'+widget_id; var ss = document.getElementsByTagName('script')[0]; ss.parentNode.insertBefore(s, ss);})();</script>
<!-- {/literal} END JIVOSITE CODE -->
<script src="templates/pri_simple/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="templates/pri_simple/js/bootstrap-clockpicker.min.js"></script>
<script type="text/javascript">
var input = $('.single-input').clockpicker({
placement: 'bottom',
align: 'left',
autoclose: true,
'default': 'now'
});
</script>
```

Elbert Cortez
@trip16661
Apr 07 2016 02:34
why json parse is giving an empty object?
tjhpae
@tjhpae
Apr 07 2016 02:35
@khaduch thank you
CamperBot
@camperbot
Apr 07 2016 02:35
tjhpae sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 870 | @khaduch | http://www.freecodecamp.com/khaduch
tjhpae
@tjhpae
Apr 07 2016 02:35
great explanation
tldr; i did it the long way
Diego Mayer
@Chrono79
Apr 07 2016 02:38
@sbarayev if(i = j){ is not a comparisson, use ===
Don't know if it's the only problem but that is one for sure
Solomon Barayev
@sbarayev
Apr 07 2016 02:39
that part of the function goes through tho
ur saying i should use a double equals?
Diego Mayer
@Chrono79
Apr 07 2016 02:40
@sbarayev yes, = assign, == or === compare
Solomon Barayev
@sbarayev
Apr 07 2016 02:41
i tried this now
```
var h1 = document.querySelector("h1");
var boxes = document.querySelectorAll(".box");
var notes = document.querySelectorAll(".audio");



for(i=0; i<boxes.length; i++){
    boxes[i].addEventListener("click", function(){
        for(j = 0; j < notes.length; j++){
            if(boxes[i] == notes[j]){
                notes[i].currentTime = 0;
                notes[i].play();
            }
        }
    });
}
still doesn't do it..
Diego Mayer
@Chrono79
Apr 07 2016 02:42
@sbarayev did you try i === j ?
Leo19909
@Leo19909
Apr 07 2016 02:43
@Chrono79 See please can't understand the reason..Writes datepicker is not a function. the website chudo-agenstvo.ru
Solomon Barayev
@sbarayev
Apr 07 2016 02:43
@Chrono79 yupp that doesn't do it (it just doesn't do anything)
Diego Mayer
@Chrono79
Apr 07 2016 02:52
@sbarayev do you have it hosted somewhere to see what the console shows?
Hang Hu
@theodorehu95
Apr 07 2016 03:04
Hey anyone know how to judge if an element equals NaN.
Alejandro Tejada
@wannabecoding
Apr 07 2016 03:06
wiki Make Object Properties Private
CamperBot
@camperbot
Apr 07 2016 03:06
no wiki entry for: make object properties private
Alejandro Tejada
@wannabecoding
Apr 07 2016 03:06
@camperbot boooooo
Elbert Cortez
@trip16661
Apr 07 2016 03:13
can i get a little help? i can't not find why i'm getting an empty object from a parse
Ken Haduch
@khaduch
Apr 07 2016 03:14
@trip16661 - did you post some code or a URL?
the random button part
Ken Haduch
@khaduch
Apr 07 2016 03:17
@trip16661 - it looks like you are getting a return, at least the console is showing it. I see where you are trying the parse, but you aren't using result anywhere?
Elbert Cortez
@trip16661
Apr 07 2016 03:18
I get the string completely but when i parse it just give back an ampty object
Alejandro Tejada
@wannabecoding
Apr 07 2016 03:18
silly question here, is there a pdf document of all the text in the javascript challenges section?
Ken Haduch
@khaduch
Apr 07 2016 03:19
@trip16661 - it looks like you are getting an object that contains your quote... let me see if I can get the correct syntax for gettting the quote out of there?
Elbert Cortez
@trip16661
Apr 07 2016 03:21
@khaduch if i log result (after parsin) it shows an empty object but if i log the var before jsonApi (before) it shows a proper json string
so what i asume is that the parse part don't work
but i don't know why if it works perfectly on the submit event
Ken Haduch
@khaduch
Apr 07 2016 03:23

@trip16661 - I'm not sure that this is the neatest way to do this, but this code, added after your JSON.parse, gives me the quote an author:

              var resQuote = result.results.result.quote;
              var resAuthor = result.results.result.author;

Then you can display that.

random-x
@random-x
Apr 07 2016 03:24
@trip16661 it's not a proper JSON string. a proper JSON string uses "double quotes" around the property names, and it doesn't use new lines I believe
Ken Haduch
@khaduch
Apr 07 2016 03:24
@trip16661 - one quote that I got, which I echoed out with console.log is:
"resQuote = There are children playing in the street who could solve some of my top problems in physics, because they have modes of sensory perception that I lost long ago."
"resAuthor = Julius Robert Oppenheimer"
random-x
@random-x
Apr 07 2016 03:24
@trip16661 so it seems like you're using a bad xml->JSON converter
Elbert Cortez
@trip16661
Apr 07 2016 03:25
blob
ive hear that it's one of the most common ways to
lol what did i press xDD that pic was for my gf xD
random-x
@random-x
Apr 07 2016 03:26
Per the $.parseJSON() description (which uses JSON.parse but is much more succinct :P):
Passing in a malformed JSON string results in a JavaScript exception being thrown. For example, the following are all invalid JSON strings:
    "{test: 1}" (test does not have double quotes around it).
    "{'test': 1}" ('test' is using single quotes instead of double quotes).
    "'test'" ('test' is using single quotes instead of double quotes).
    ".1" (a number must start with a digit; "0.1" would be valid).
    "undefined" (undefined cannot be represented in a JSON string; null, however, can be).
    "NaN" (NaN cannot be represented in a JSON string; direct representation of Infinity is also not permitted).
Ken Haduch
@khaduch
Apr 07 2016 03:27
I deciphered what you are getting in result with this: console.log("result = " + JSON.stringify(result)); then I just dereferenced the properties that were there. I don't know if there is something better to do, but you do have some data there...
Elbert Cortez
@trip16661
Apr 07 2016 03:27
@khaduch i just checked and i got the data D:
@random-x i was getting
"{
'results':{'result':{'quote':'The worst thing in the world next to anarchy, is government.','author':'Henry Ward Beecher'}}
}"
@khaduch i wonder why it's like that D:anyway if i can get information then it's not a problem but i wonder >_<
@khaduch but anyway really thanks
CamperBot
@camperbot
Apr 07 2016 03:31
trip16661 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 871 | @khaduch | http://www.freecodecamp.com/khaduch
Elbert Cortez
@trip16661
Apr 07 2016 03:31
@random-x you too that explanation was good :D
AaronCs
@AaronCs
Apr 07 2016 03:33
Is there a debug mode for the editor?
Ken Haduch
@khaduch
Apr 07 2016 03:33
@AaronCs - do you mean for the challenges?
AaronCs
@AaronCs
Apr 07 2016 03:33
Yes
random-x
@random-x
Apr 07 2016 03:34
@trip16661 I have good results after removing the newline character, btw
Norvin Burrus
@ndburrus
Apr 07 2016 03:34
where are he directions for pasting code (for a question)?
random-x
@random-x
Apr 07 2016 03:34
help format
CamperBot
@camperbot
Apr 07 2016 03:34

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Elbert Cortez
@trip16661
Apr 07 2016 03:35
@random-x newline character?
Janith Olagama
@JoleDev
Apr 07 2016 03:35
This message was deleted
Norvin Burrus
@ndburrus
Apr 07 2016 03:35
where are the backticks?
oh, i c it
Ken Haduch
@khaduch
Apr 07 2016 03:35
@AaronCs - I've had trouble getting into the debugger, what I've done is take my code and paste it into some other tool such as jsfiddle and play with it there.
AaronCs
@AaronCs
Apr 07 2016 03:36
Ok thanks
Ken Haduch
@khaduch
Apr 07 2016 03:36
But it seems that you should be able to run it. Let me go and check again, maybe I just forgot if I've ever done it?
Janith Olagama
@JoleDev
Apr 07 2016 03:36

Code Screen Print.jpg

What is the wrong with this code, I have done the exact same thing as explained in the example. I tried this three months before but couldn't solved it, and i again came back after three months, still could not resolve the same.

Norvin Burrus
@ndburrus
Apr 07 2016 03:36

```var count = 0;

function cc(card) {
// Only change code below this line
if card >= 2 && card =< 6 {
count = (count + 1);
}
else if (card = 10) {
count = (count - 1);
}
else if (card = "J") {
card = (card - 1);
}
else if (card ="Q") {
card = (card - 1);
}
else if (card = "K") {
card = (card - 1);
}
else if (card = "A") {
card = (card - 1);
} ```

Amir Ghafouri
@amirghafouri
Apr 07 2016 03:36
Why am I getting "type error: Cannot read property 'length' of undefined; "
function sumFibs(num) {
  var fibs = [1,1];

  //return fibs[fibs.length - 1] + fibs[fibs.length - 2] == i;

  for (var i=0; i<=num; i++) {    
    if (fibs[fibs.length - 1] + fibs[fibs.length - 2] == i) {
      fibs = fibs.push[i];
    }     
  }

  return fibs;
}

sumFibs(4);
Norvin Burrus
@ndburrus
Apr 07 2016 03:36
ok, that didnt work
im trying to get the if then comparison syntax correct
parvinder30
@parvinder30
Apr 07 2016 03:39
@khaduch Sir i'm trying do complete this exercise
But Its showing me an error .
```
// Only change code below this line

var remainder=11;

remainder = remainder %3;
Capture.PNG
random-x
@random-x
Apr 07 2016 03:41
@trip16661 ignore me.. I am crazy :P
parvinder30
@parvinder30
Apr 07 2016 03:42
@khaduch these are the condition to satisfy
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
Even after completing the exersice its saying to satisfy second condition
Ken Haduch
@khaduch
Apr 07 2016 03:42
@JoleDev - did you try removing the code at the top? My version of this solution only has the code from the // Setup to the bottom, and it seems to work?
@parvinder30 - which challenge is this, please?
parvinder30
@parvinder30
Apr 07 2016 03:44
@khaduch Finding a Remainder in JavaScript
random-x
@random-x
Apr 07 2016 03:45
@amirghafouri you're usage of push is not quite correct
Ken Haduch
@khaduch
Apr 07 2016 03:45
@parvinder30 @parvinder30 - I just looked at mine, it only has one line of code, with the operation being 11 % 3 - you should declare the variable and do the operation all on one line. Try that?
random-x
@random-x
Apr 07 2016 03:46
@amirghafouri check the MDN's description here of how push should be called and what it does: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push
khaduch @khaduch - I am going to leave the room in 5 minutes or less... time to turn in for the night! Any last questions or responses to anything I've tried to help with?
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 03:47
Guys
parvinder30
@parvinder30
Apr 07 2016 03:47
It Worked Sir.
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 03:48
How to access a subarray of an array using array filter?
parvinder30
@parvinder30
Apr 07 2016 03:48
@khaduch Is this mean that what I'm doing was wrong
Amir Ghafouri
@amirghafouri
Apr 07 2016 03:49

@random-x I thought so too, but when I just go fibs.push[i] it tells me "expected an assignment or function call and instead saw an expression"

the type error it is giving me seems to relate to reading the property length?

Ken Haduch
@khaduch
Apr 07 2016 03:49
@parvinder30 - great! The instructions seemed to indicate that it simply wanted to operation of 11 % 3, so you put a little too much effort into it.... what you did probably gave the correct answer, but the tests are often looking for very specific coding techniques, very specific variable names, etc.
parvinder30
@parvinder30
Apr 07 2016 03:50
Okieee Thankyou som much sir
So Much*
random-x
@random-x
Apr 07 2016 03:51
@amirghafouri trust me, the error is in how you are using push. remember: push is a function :)
@sudeepnarkar do you have code you're working on right now that I can help you with?
khaduch @khaduch - my time is up for tonight... good night (or good day, depending on where you are!) Happy coding!
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 03:52
@random-x Yes. I need help in one code challenge
random-x
@random-x
Apr 07 2016 03:52
night, @khaduch
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 03:53
function destroyer(arr) {
  // Remove all the values
  var arr2=[];
  var length=arr.length;
  var final= arr.filter(function(value,index,array){

                      });
      return final;


}




destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I need to remove the elements from the subarray
@random-x Seek and destroy challenge
Amir Ghafouri
@amirghafouri
Apr 07 2016 03:54
@random-x oh yeah whoops, just noticed the square brackets. haha thanks
CamperBot
@camperbot
Apr 07 2016 03:54
amirghafouri sends brownie points to @random-x :sparkles: :thumbsup: :sparkles:
:star: 116 | @random-x | http://www.freecodecamp.com/random-x
Mike Moss
@MMux
Apr 07 2016 03:55
working on wikipedia viewer, and having some character encoding, where some of the punctuation is coming back as question marks
http://codepen.io/MMux/pen/qZVyMa
anyone have this issue?
random-x
@random-x
Apr 07 2016 03:56
@sudeepnarkar I think you need to read the text for that question and read about the "Arguments" object. That array isn't a subarray at all... it's the first argument to the function call
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 03:57
@random-x Yes
random-x
@random-x
Apr 07 2016 03:57
so there's no subarray. it's just an array.
AaronCs
@AaronCs
Apr 07 2016 03:59
Hey guys, I was wondering what was wrong with my code
js
whoops
function titleCase(str) {
  var splitStr = str.toLowerCase().split(" ");
  // make an array that takes in a single word and then join it together;
  var splitStrStorage = [];
  var strStorage2 = [];
  var strStorageJoined = [];
  var strJoin;
  var strFinal = "";
  var str2 = [];
  for (var i = 0; i < splitStr.length; i++) {
    splitStrStorage.push(splitStr[i]);
    str2 = splitStrStorage[0][0].toUpperCase();
    strStorage2.push(str2);
    if (splitStrStorage[0].length !== 1){
      for (var j = 1; j < splitStr[i].length; j++) {
        strStorage2.push(splitStrStorage[0][j]);
      }
    }
    strStorage2.push(" ");
    strJoin = strStorage2.join("");
    splitStrStorage = [];
  }
  return strJoin;
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
I tried all the test cases, but they remain unfinished
Muhamad Firhat
@firhatsungkar
Apr 07 2016 04:02
Hello, i'm getting difficulties on Counting Card Tutorial. My Code is

var count = 0;

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

console.log(card);
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(3); cc(7); cc('K'); cc('A');

random-x
@random-x
Apr 07 2016 04:02
@AaronCs hmm.. you miiiight be making things a bit tougher than they have to be.
Muhamad Firhat
@firhatsungkar
Apr 07 2016 04:03
and this is the result of console : VM1073:6 2
VM1073:6 3
VM1073:6 7
VM1073:6 K
VM1073:6 A
VM1075:6 2
VM1075:6 3
VM1075:6 7
VM1075:6 K
VM1075:6 A
VM1073:6 2
VM1073:6 3
VM1073:6 4
VM1073:6 5
VM1073:6 6
VM1073:6 7
VM1073:6 8
VM1073:6 9
VM1073:6 10
VM1073:6 J
VM1073:6 Q
VM1073:6 K
VM1073:6 A
VM1073:6 3
VM1073:6 7
VM1073:6 Q
VM1073:6 8
VM1073:6 A
VM1073:6 2
VM1073:6 J
VM1073:6 9
VM1073:6 2
VM1073:6 7
VM1073:6 2
VM1073:6 2
VM1073:6 10
VM1073:6 3
VM1073:6 2
VM1073:6 A
VM1073:6 10
VM1073:6 K
random-x
@random-x
Apr 07 2016 04:03
@AaronCs that said, it still "mostly works" and the fix to make it work is pretty simple, actually.
Muhamad Firhat
@firhatsungkar
Apr 07 2016 04:03
where is 10 result come from?
AaronCs
@AaronCs
Apr 07 2016 04:03
@random-x ;_; can you give me a hint?
random-x
@random-x
Apr 07 2016 04:04
@AaronCs the hint for you is: read up on Array.join()
AaronCs
@AaronCs
Apr 07 2016 04:04
Thanks
random-x
@random-x
Apr 07 2016 04:04
it might let you remove one line of your code which would then "fix the problem"
@firhatsungkar please post your code formatted with backticks
help format
CamperBot
@camperbot
Apr 07 2016 04:05

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Muhamad Firhat
@firhatsungkar
Apr 07 2016 04:06
Ok, wait a minute
This message was deleted
CamperBot
@camperbot
Apr 07 2016 04:06
:bulb: to format code use backticks! ``` more info
AaronCs
@AaronCs
Apr 07 2016 04:07
omg I realized what I did wrong: there's a space behind the last word
random-x
@random-x
Apr 07 2016 04:08
@AaronCs indeed.
Muhamad Firhat
@firhatsungkar
Apr 07 2016 04:11
var count = 0;

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

  console.log(card);
  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(3); cc(7); cc('K'); cc('A');

and the console result :

 2
 3
 7
 K
 A
 2
 3
 7
 K
 A
 2
 3
 4
 5
 6
 7
 8
 9
 10
 J
 Q
 K
 A
 3
 7
 Q
 8
 A
 2
 J
 9
 2
 7
 2
 2
 10
 3
 2
 A
 10
 K

I have clear my console log before run it, it seem cc funtion run looping, and where is 10 result come from ?

Diego Mayer
@Chrono79
Apr 07 2016 04:19
@firhatsungkar to test your function the challenge calls it more times than your calls
see bottom left corner to see the full list against your function is tested
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 04:19
@random-x Hi. Can you see what is wrong now?
function destroyer(arr) {
  // Remove all the values
  var len=arguments[0].length;
  var arrlength=arr.length;
  var final=arr.filter(function(value,index,array){

        if(index!==0 && length>=1)
          {
             for(i=0;i<len;i++)
               {
                 return (arguments[0][i]!=arr[arrlength]);

               }
            arrlength--;
          }

  });

  return final;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Omar
@OmarLopezGro
Apr 07 2016 04:20

can anyone help me with this? im stuck // Setup
var myStr = "Jello World";

// Only change code below this line

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

random-x
@random-x
Apr 07 2016 04:20
@firhatsungkar where are you doing your coding? in codepen?
and are you using the browser console or something else?
@sudeepnarkar: hmm.. what is length in the above (&& length >= 1)?
Paul Borawski
@iAmNawa
Apr 07 2016 04:24
@OmarLopezGro
myStr = “Hello World”;
i think that was it
Muhamad Firhat
@firhatsungkar
Apr 07 2016 04:24
@Chrono79 Aha i see, i must try out of codecamp. Thanks
@random-x nope, i was code and try console on codecamp.
CamperBot
@camperbot
Apr 07 2016 04:24
firhatsungkar sends brownie points to @chrono79 and @random-x :sparkles: :thumbsup: :sparkles:
:star: 358 | @chrono79 | http://www.freecodecamp.com/chrono79
:star: 117 | @random-x | http://www.freecodecamp.com/random-x
random-x
@random-x
Apr 07 2016 04:26
@sudeepnarkar so filter's function can have 3 parameters, but it usually only uses 1. the 3 params are:
  1. the value of the current element in the array being evaluated for filtering (which is arr in your example)
  2. the index of the current element in the array being evaluated for filtering
  3. the entire array which is being filtered on
@sudeepnarkar in most cases, you end up just using the first.. e.g.,
var filteredArray = oldArray.filter(function(elem) {
    //do something with the current element (elem) to return a true or false
    //true = keep in the filtered array, false = throw it away
});
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 04:30
@random-x trying to compare elements
random-x
@random-x
Apr 07 2016 04:31
@sudeepnarkar well my hint for you is you will only need the first parameter for the filter callback function to make it work
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 04:31
@random-x Ok.
random-x
@random-x
Apr 07 2016 04:31
@sudeepnarkar think about it in terms of "with this element, elem, what do I need to compare it to to determine if I keep it or throw it away?"
AaronCs
@AaronCs
Apr 07 2016 04:32
@random-x Omg I did it! However, I had to start all over and I shortened it a lot.
function titleCase(str) {
  var splitStr = str.toLowerCase().split(" ");
  var strStorage2 = [];
  var str2 = "";
  for (var i = 0; i < splitStr.length; i++) {
    str2 = splitStr[i].charAt(0).toUpperCase();
    strStorage2.push(splitStr[i].replace(/\w/, str2));
  }
  return strStorage2.join(" ");
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 04:33
@random-x But in order to access all the elems of arguments[O] I would need to loop through it elems right?
random-x
@random-x
Apr 07 2016 04:34
@AaronCs great job :) that is an interesting use of the replace there! but hey, it works! :) AND it is much cleaner than before - congrats!!
AaronCs
@AaronCs
Apr 07 2016 04:34
Thanks :smile:
Joshua Minchew
@jminchew97
Apr 07 2016 04:35
Hey
can somebody please help me when they get the chance
random-x
@random-x
Apr 07 2016 04:36
@sudeepnarkar well, I think it would help you a lot if you separate the first argument from the other arguments before you get to your filter
@jminchew97 might be able to! but I won't know if you don't ask :)
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 04:40
@random-x Like this?
Joshua Minchew
@jminchew97
Apr 07 2016 04:40
Hey1
Elbert Cortez
@trip16661
Apr 07 2016 04:40
@jminchew97 just post your code in the correct format and im sure someone will help
Joshua Minchew
@jminchew97
Apr 07 2016 04:40
!
Elbert Cortez
@trip16661
Apr 07 2016 04:40
help format
CamperBot
@camperbot
Apr 07 2016 04:40

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Joshua Minchew
@jminchew97
Apr 07 2016 04:40
prepare for a long url
https://www.freecodecamp.com/challenges/record-collection#?solution=%2F%2F%20Setup%0Avar%20collection%20%3D%20%7B%0A%20%20%20%202548%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%202468%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%221999%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%201245%3A%20%7B%0A%20%20%20%20%20%20artist%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%205439%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%22ABBA%20Gold%22%0A%20%20%20%20%7D%0A%7D%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse(JSON.stringify(collection))%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20update(id%2C%20prop%2C%20value)%20%7B%0Aif%20(value%20!%3D%3D%20%22%22%20%26%26%20prop%20!%3D%3D%20%22tracks%22)%20%7B%0A%20%20%0A%7D%0A%0A%20%20return%20collection%3B%0A%7D%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0Aupdate(5439%2C%20%22artist%22%2C%20%22ABBA%22)%3B%0A%0A
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 04:40
function destroyer(arr) {
  // Remove all the values
  //var len=arguments[0].length;
  var arrlength=arguments.length;
  var final=arguments[0].filter(function(value){

    for(i=1;i<arrlength;i++)
     { 
    return (value!==arguments[i]);
     }
  });

  return final;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Joshua Minchew
@jminchew97
Apr 07 2016 04:40
this is the challenge
I literally have NO clue what to do
or where to start
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 04:40
@random-x ?
Joshua Minchew
@jminchew97
Apr 07 2016 04:40
I dont understand what it wants
Aman Barnwal
@amanbarnwalce
Apr 07 2016 04:41
i didn't understand math.random() function?
Elbert Cortez
@trip16661
Apr 07 2016 04:41
@jminchew97 use a proper format
Aman Barnwal
@amanbarnwalce
Apr 07 2016 04:41
any explanation?
random-x
@random-x
Apr 07 2016 04:41
@sudeepnarkar much much closer!
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 04:41
@random-x Aaaaah!
Elbert Cortez
@trip16661
Apr 07 2016 04:41
@amanbarnwalce it randomly pops a number from @amanbarnwalce 0 to 0.9
withing that range
random-x
@random-x
Apr 07 2016 04:42
@sudeepnarkar awesome.. ok.. now to do the last bit: what is a condition to "EXCLUDE" a number (e.g., a reason to return FALSE)?
V Arun Kumar
@arunvkumr
Apr 07 2016 04:42
@jminchew97 use code formatting to post code here...
```js [CTRL+ENTER] <paste your code> [CTRL+ENTER] ```
Elbert Cortez
@trip16661
Apr 07 2016 04:43
what happen if you want a number like 90?
easy you just have to use the number the math gives you and multiply it by 100
V Arun Kumar
@arunvkumr
Apr 07 2016 04:43
@jminchew97 read the instructions, it exactly tells you wnat to do.
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 04:44
@random-x value present in arguments0 array
Elbert Cortez
@trip16661
Apr 07 2016 04:44
hope that helps @amanbarnwalce
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 04:44
@random-x value present in arguments[0 ]array
Joshua Minchew
@jminchew97
Apr 07 2016 04:44
@arunkumrv Ive read them multiple times
I can do exactly what it tells me to do but I dont UNDERSTAND it, I want to learn it
Aman Barnwal
@amanbarnwalce
Apr 07 2016 04:45
@trip16661 how to call the function? and do i need to change the return value too?
Joshua Minchew
@jminchew97
Apr 07 2016 04:45
I dont understand it at all in fact
Elbert Cortez
@trip16661
Apr 07 2016 04:46
@jminchew97 man paste your code with the format we showed ```js (then shift enter) then in the middle you put the code
random-x
@random-x
Apr 07 2016 04:46
@sudeepnarkar well, you're using arguments[0] as your initial array to keep or throw elements out of
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 04:46
@random-x Yes
Aman Barnwal
@amanbarnwalce
Apr 07 2016 04:47
Anyone tell me how to use math.random() function
?
Elbert Cortez
@trip16661
Apr 07 2016 04:47
@amanbarnwalce just by using the Math.random()
V Arun Kumar
@arunvkumr
Apr 07 2016 04:47
@jminchew97 the objective of the challenge is to make you understand how to access object elements, how to update , how to delete. can you tell me what exactly you are not understanding in this.
Elbert Cortez
@trip16661
Apr 07 2016 04:47
it's a function call that js have already designed inside of it
random-x
@random-x
Apr 07 2016 04:47
@sudeepnarkar so you're really trying to find out: "does the current element match one of the arguments[1...], and if so, throw it out", right?
Aman Barnwal
@amanbarnwalce
Apr 07 2016 04:47
do i need to change the return value?
Elbert Cortez
@trip16661
Apr 07 2016 04:48
no but you need somewhere to save it or need something to alter it
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 04:48
@random-x Exactly
Elbert Cortez
@trip16661
Apr 07 2016 04:48
like var a = Math.random()*10
random-x
@random-x
Apr 07 2016 04:48
@sudeepnarkar ok. and the way you tell it to throw an element out is return false
Elbert Cortez
@trip16661
Apr 07 2016 04:48
what do you thin will be inside of the a var ?
random-x
@random-x
Apr 07 2016 04:49
@sudeepnarkar so give that a try - let me see what you get
Sudeep Narkar
@sudeepnarkar
Apr 07 2016 04:49
function destroyer(arr) {
  // Remove all the values
  //var len=arguments[0].length;
  var arrlength=arguments.length;
  var final=arguments[0].filter(function(value){

    for(i=1;i<arrlength;i++)
     { 
    return (value!==arguments[i]);
     }
  });

  return final;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
@random-x Current code
Eric Murta
@murtinha
Apr 07 2016 04:50
Guys, whats missing here?
function telephoneCheck(str) {
  // Good luck!
  var regExp=/^1?[\s-]?[^\(]?([0-9]{3})[\)$]?[\s\-]?([0-9]{3})[\s-]?([0-9]{4})$/;
  return regExp.test(str);
}



telephoneCheck("(275)76227382");
its challenge Validate US Telephone Numbers
Elbert Cortez
@trip16661
Apr 07 2016 04:50
@amanbarnwalce let me now what do you think variable a gives
V Arun Kumar
@arunvkumr
Apr 07 2016 04:51
@sudeepnarkar the problem is with arguments objects.. the arguments object use the arguments of the current function, when you are using it in the filter function with callback, the argument object is referring to the callback inside filter... try converting arguments into array and stroing it in another variable.
Aman Barnwal
@amanbarnwalce
Apr 07 2016 04:53

Won't it work?

function randomFraction() {

// Only change code below this line.

return math.random();

// Only change code above this line.
}

done!
finally!
The problem was, I was using "math" instead of "Math"
thanks @trip16661
CamperBot
@camperbot
Apr 07 2016 04:55
amanbarnwalce sends brownie points to @trip16661 :sparkles: :thumbsup: :sparkles:
:star: 288 | @trip16661 | http://www.freecodecamp.com/trip16661
V Arun Kumar
@arunvkumr
Apr 07 2016 04:57
@amanbarnwalce
Math.Random() * 10 this will give you random numbers from 0 - 10.
[Math.Random() * (20-6)]+6 will give you random values between 6 - 20.
in general case.
[Math.Random() * (max - min)] + min will give you random numbers between min and max.
Elbert Cortez
@trip16661
Apr 07 2016 04:57
@amanbarnwalce yep hapened to me too :D
Mauricio
@maudevelop
Apr 07 2016 04:59
Hello
I'm having a problem on the roman numeral converter, it is working but on the "Run tests" it doesn't recognize it
Jeff
@meankraken
Apr 07 2016 05:00
@maudevelop make sure you're returning it in the exact same format
Mauricio
@maudevelop
Apr 07 2016 05:00
var result = "";
var romans = ["M", "CM", "D", "CD", "C", "L", "X", "IX", "V", "IV", "I"];
var valromans = [1000, 900, 500, 400, 100, 50, 10, 9, 5, 4, 1];

function convertToRoman(num) {
    if (num >= 4000){
        return "Value is greater than permitted";
    } else{
    for (var i = 0; i < romans.length ; i++){

        while (num >= valromans[i]){
            result += romans[i];
            num= num - valromans[i];
        }

    }
       return result;   
    }
}
convertToRoman(9);
it's working fine and somehow FCC won't detect any of the test as passing
V Arun Kumar
@arunvkumr
Apr 07 2016 05:02
@maudevelop FCC doesn't work with global variables.. try creating another function inside convertToRoman and call that function.
Mauricio
@maudevelop
Apr 07 2016 05:04
@arunkumrv Hmmm, global variables you mean the ones declared at the top??
Elbert Cortez
@trip16661
Apr 07 2016 05:04
@arunkumrv as far as i know in Math. function 1 is not inclusive so you would never get 10 out of ()* 10
V Arun Kumar
@arunvkumr
Apr 07 2016 05:05
@maudevelop yup.. that one.
@trip16661 good catch.. yup it works at range [min,max).
:grinning:
so you have to add 1 to get the max value.
Elbert Cortez
@trip16661
Apr 07 2016 05:06
yep
V Arun Kumar
@arunvkumr
Apr 07 2016 05:09
@maudevelop convertToRoman(3999); returns MMMCMLXXXXIX. but it should return MMMCMXCIX.
Leo19909
@Leo19909
Apr 07 2016 05:09

Can you tell why this function is causing the conflict. Uncaught ReferenceError: spnoConflict is not defined.
``` (shift+enter for line break)
<script type="text/javascript">
jQuery(window).on('load', function() {
new JCaption('img.caption');
});
spnoConflict(function($){

                function mainmenu() {
                    $('.sp-menu').spmenu({
                        startLevel: 0,
                        direction: 'ltr',
                        initOffset: {
                            x: 0,
                            y: 0
                        },
                        subOffset: {
                            x: 0,
                            y: 0
                        },
                        center: 0
                    });
        }

        mainmenu();

        $(window).on('resize',function(){
            mainmenu();
        });


        });

window.setInterval(function(){var r;try{r=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}if(r){r.open("GET","./",true);r.send(null)}},3600000);
</script>;
```

Timofey Votyakov
@tvotyakov
Apr 07 2016 05:13
@Leo19909 You try to call spnoConflict. There do you define it?
GowthamReddyAmbati
@GowthamReddyAmbati
Apr 07 2016 05:14

Hi all, Here is my code.. i'm not able to complete challenge. would you please let me know the reason. ~~ function myTest(val) {
if (val > 10) {
return "Greater than 10";
}

else if (val < 5) {
return "Smaller than 5";
}
else{
return "Between 5 and 10";
}
}

// Change this value to test
myTest(12); ~~

`` function myTest(val) {
if (val > 10) {
return "Greater than 10";
}

else if (val < 5) {
return "Smaller than 5";
}
else{
return "Between 5 and 10";
}
}

// Change this value to test
myTest(12); ``

Mauricio
@maudevelop
Apr 07 2016 05:14
@arunkumrv, thanks! first error was the values were outside the function anddddd was missing some other roman numerals up there
CamperBot
@camperbot
Apr 07 2016 05:14
maudevelop sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 425 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Mauricio
@maudevelop
Apr 07 2016 05:14
working now :D
GowthamReddyAmbati
@GowthamReddyAmbati
Apr 07 2016 05:15
these are failing.. testElseIf(0) should return "Smaller than 5"
testElseIf(5) should return "Between 5 and 10"
testElseIf(7) should return "Between 5 and 10"
testElseIf(10) should return "Between 5 and 10"
testElseIf(12) should return "Greater than 10"
dwayneabutcher
@dwayneabutcher
Apr 07 2016 05:16
Could someone tell me why this is not working.
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  [1] =
  {"artist":"Hopsin",
   "title": "Ill Mind 8",
   "release_year":2016,
   "formats": [
     "CD",
     "Underground",
     "Digital",
   ]

  }
  ];
This is for Introducing Json, I think it has something to do with how I'm calling the second album but I can't figure it out.
Leo19909
@Leo19909
Apr 07 2016 05:17
@tvotyakov I don't know how to do it.( SpnoConflict file is in the folder helix - helix.core.js. Here is my website chudo-agenstvo.ru
Markus Kiili
@Masd925
Apr 07 2016 05:17
@dwayneabutcher It should be like = [{...},{...}]; Two objects on an array.
Leo19909
@Leo19909
Apr 07 2016 05:17
@Leo19909 And the conflict is probably with the menu
Kyle Morton
@kmorton1988
Apr 07 2016 05:18
put a commat after the first closign bracket.
comma*
Leo19909
@Leo19909
Apr 07 2016 05:18
@tvotyakov And the conflict is probably with the menu
dwayneabutcher
@dwayneabutcher
Apr 07 2016 05:19
@Masd925 so like this ?
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  [1] =[
  {"artist":"Hopsin",
   "title": "Ill Mind 8",
   "release_year":2016,
   "formats": [
     "CD",
     "Underground",
     "Digital",
   ]

  }
    ]
  ];
Markus Kiili
@Masd925
Apr 07 2016 05:19
@dwayneabutcher No. Remove [1]=[
Just [{...},{...}]; and properties inside.
dwayneabutcher
@dwayneabutcher
Apr 07 2016 05:21
@Masd925 I understand now, Thanks for the help!
CamperBot
@camperbot
Apr 07 2016 05:21
dwayneabutcher sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1322 | @masd925 | http://www.freecodecamp.com/masd925
Leo19909
@Leo19909
Apr 07 2016 05:23

Can you tell why this function is causing the conflict. Uncaught ReferenceError: spnoConflict is not defined.
``` <script type="text/javascript">
jQuery(window).on('load', function() {
new JCaption('img.caption');
});
spnoConflict(function($){

                function mainmenu() {
                    $('.sp-menu').spmenu({
                        startLevel: 0,
                        direction: 'ltr',
                        initOffset: {
                            x: 0,
                            y: 0
                        },
                        subOffset: {
                            x: 0,
                            y: 0
                        },
                        center: 0
                    });

```
Please look what I can do. SpnoConflict file is in the folder helix - helix.core.js. Here is my website chudo-agenstvo.ru

Timofey Votyakov
@tvotyakov
Apr 07 2016 05:27
@Leo19909 if SpnoConflict is defined in th helix.core.js, you should include this file in your html before you call SpnoCoflict
Leo19909
@Leo19909
Apr 07 2016 05:28
@tvotyakov Thank you. Now try
CamperBot
@camperbot
Apr 07 2016 05:28
leo19909 sends brownie points to @tvotyakov :sparkles: :thumbsup: :sparkles:
:star: 360 | @tvotyakov | http://www.freecodecamp.com/tvotyakov
Siddharth
@Sid225
Apr 07 2016 05:32
function lookUp(firstName, prop){
// Only change code below this line
if(firstName===true&&prop===true)
{
return prop;
}
else if(firstName!==true)
{
return "No such contact";
}
else if(prop!==true)
{
return "No such property";
}
want help in this code
hey anyone there
Vitor Lory
@vlory73
Apr 07 2016 05:34
@Sid225 firstName and prop need to be compared to something
not check if true
Siddharth
@Sid225
Apr 07 2016 05:35
for eg.
Vitor Lory
@vlory73
Apr 07 2016 05:35
help profile lookup
CamperBot
@camperbot
Apr 07 2016 05:35

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint profile lookup on the FCC Wiki

Markus Kiili
@Masd925
Apr 07 2016 05:37
@Sid225 You need a loop of some kind through the contacts.
GoranM88
@GoranM88
Apr 07 2016 05:45
Hi, I would need some help smallest common multiple problem. This is my code. It doesn't pass the last test [1, 13].
function smallestCommons(arr) {
  arr.sort();
  var num1 = arr[0], num2 = arr[1], range = [];

  for (var z = 0; z < num2; z++) {
    range.push(num1 + z);
  }

  var b = 2;
  var statement = true;
  var scm = num1 * num2;

  while(statement) {
    var a = 0;
    for(var i = 0; i < range.length; i++) {
      if(scm % range[i] === 0) {
        a += 1;  
      }
    }
    if (a != range.length) {
      scm *= range[range.length - b];
      b += 1;
    }
    else {
      return scm;
    }
  }
}
Jan Nissi Harrison
@NissiHarrison
Apr 07 2016 05:47
guys please help me with objects for properties....please look at whats wrong
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
Markus Kiili
@Masd925
Apr 07 2016 05:50
@NissiHarrison Use syntax obj[key] to accessing property value.
Jan Nissi Harrison
@NissiHarrison
Apr 07 2016 05:50
@Masd925 ok ill try that
@Masd925 thanks
CamperBot
@camperbot
Apr 07 2016 05:50
nissiharrison sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1323 | @masd925 | http://www.freecodecamp.com/masd925
Zach
@Moose1551
Apr 07 2016 05:53
I'm having a hard time understanding how to define something. In this code, is superCar not defined as "Zach Attack"?
var myCar = new superCar();
superCar = "Zach Attack";
Markus Kiili
@Masd925
Apr 07 2016 05:56
@Moose1551 No. superCar is a variable. You should use var superCar=... so you don't make a global variable. The right hand side is a string literal which makes a string value that is assigned with the assignment operator = to the variable superCar on the left side.
V Arun Kumar
@arunvkumr
Apr 07 2016 06:01
wiki stand
CamperBot
@camperbot
Apr 07 2016 06:01

:point_right: challenge understand boolean values [wiki]

Understand Boolean Values

Booleans can only hold the value of either true or false. They are basically little on-off switches.

:pencil: read more about challenge understand boolean values on the FCC Wiki

Akshay Bhatt
@itmonksakshay
Apr 07 2016 06:01
i am have issuses with truncate string. i do not know what to suppose do
V Arun Kumar
@arunvkumr
Apr 07 2016 06:01
wiki stand in
CamperBot
@camperbot
Apr 07 2016 06:01

:point_right: checkpoint stand in line [wiki]

Checkpoint: Stand In Line

About queues

In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

Instructions

Write a function queue which takes an "array" and an "item" as arguments.

Add the item onto the end of the array, then remove the first element of the array.

The queue function should return the element that was removed.

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint stand in line on the FCC Wiki

this is the challenge link
V Arun Kumar
@arunvkumr
Apr 07 2016 06:03
@itmonksakshay @AndyRoush follow code formating..
```js [shift+enter] <paste you code here> [shift+enter] ```
find format
CamperBot
@camperbot
Apr 07 2016 06:03

find format

:zero: code formatting

V Arun Kumar
@arunvkumr
Apr 07 2016 06:03
click the link by camperbot for more info on formatting.. :point_up: April 7, 2016 11:33 AM
Markus Kiili
@Masd925
Apr 07 2016 06:04
@AndyRoush You need to make a function that adds a number to the end of array and then removes and returns the first element of the array. The array and number that are passed to the function are stored on parameters arr and item. Use them to define the function content.
Arnaud Casamé
@arnaudcasame
Apr 07 2016 06:05
help Everything Be True
CamperBot
@camperbot
Apr 07 2016 06:05

:point_right: algorithm everything be true [wiki]

Explanation:

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

Hint: 1

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

Hint: 2

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

Hint: 3

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

Spoiler Alert!

687474703a2f2f7777772e796f75726472756d2e636f6d2f796f75726472756d2f696d616765732f323030372f31302f31302f7265645f7761726e696e675f7369676e5f322e676966.gif

Solutions ahead!

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

Jan Nissi Harrison
@NissiHarrison
Apr 07 2016 06:05
help
CamperBot
@camperbot
Apr 07 2016 06:05

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

Basic Commands:

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

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Zach
@Moose1551
Apr 07 2016 06:06

I think I understand, @Masd925 . But, once I've done what you said, it states that superCar is not a constructor.

var myCar = new superCar();
var superCar = "Zach Attack";

Is "new superCar();" not the constructor that FCC teaches in the chapter?

Andy Roush
@AndyRoush
Apr 07 2016 06:06
thanks @Masd925
CamperBot
@camperbot
Apr 07 2016 06:06
andyroush sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1324 | @masd925 | http://www.freecodecamp.com/masd925
Jan Nissi Harrison
@NissiHarrison
Apr 07 2016 06:07
wiki Introducing JavaScript Object Notation JSON
CamperBot
@camperbot
Apr 07 2016 06:07

:point_right: challenge introducing javascript object notation json [wiki]

Challenge: Introducing JavaScript Object Notation JSON

JavaScript Object Notation or JSON uses the format of JavaScript Objects to store data. JSON is flexible because it allows for Data Structures with arbitrary combinations of strings, numbers, booleans, arrays, and objects.

Here is an example of a JSON object:

var ourMusic = [
  {
    "artist": "Daft Punk",
    "title": "Homework",
    "release_year": 1997,
    "formats": [ 
      "CD", 
      "Cassette", 
      "LP" ],
    "gold": true
  }
];

:pencil: read more about challenge introducing javascript object notation json on the FCC Wiki

Markus Kiili
@Masd925
Apr 07 2016 06:08
@Moose1551 Post the whole code. I didn't know of any constructor.
Jan Nissi Harrison
@NissiHarrison
Apr 07 2016 06:08
guys please help me with this code
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  },
  {
    "myMusic[1]":
      {
        "artist":"Ray",
        "title":"990",
        "release_year":1234,
        "formats":["help","hello"],
      }
  }
  // Add record here
];
V Arun Kumar
@arunvkumr
Apr 07 2016 06:09
@AndyRoush
  • Add the item onto the end of the array, using the item variable passed to function.(Push Operation)
  • Then remove the first element of the array, the queue function should return the element that was removed.(Shift Operation)
    read about push and shift function.
Ryan Price
@rsprice
Apr 07 2016 06:09
@NissiHarrison what is your question?
Zach
@Moose1551
Apr 07 2016 06:09
@Masd925 , here it is:
var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 1;
};

// Only change code below this line.

var myCar = new superCar();
var superCar = "Zach Attack";
Markus Kiili
@Masd925
Apr 07 2016 06:10
@Moose1551 Car is a constructor. The way to make cars is new Car();
Jan Nissi Harrison
@NissiHarrison
Apr 07 2016 06:11
@rsprice it says to add another myMusic[1] object....and the properties but it doesnt pass....i wonder if theres something wrong in the syntax
Markus Kiili
@Masd925
Apr 07 2016 06:13
@NissiHarrison It should be like: =[{...},{...}];
Two elements on an array.
swishk
@swishk
Apr 07 2016 06:13
@NissiHarrison do you need to add the line "myMusic1": I think you only need to add an album
Jan Nissi Harrison
@NissiHarrison
Apr 07 2016 06:15
thanks @Masd925 @swishk for the help
CamperBot
@camperbot
Apr 07 2016 06:15
nissiharrison sends brownie points to @masd925 and @swishk :sparkles: :thumbsup: :sparkles:
:warning: nissiharrison already gave masd925 points
:star: 233 | @swishk | http://www.freecodecamp.com/swishk
Zach
@Moose1551
Apr 07 2016 06:20

@Masd925 , like this?

var Car = new Car();
Car.Car = "Zach Attack";

It doesn't pass all the tests.

Markus Kiili
@Masd925
Apr 07 2016 06:21
@Moose1551 Car is the name of the constructor function. Don't use the same name for your variable.
Robert Uivarosi
@URobert
Apr 07 2016 06:22
@Moose1551 var myCar...
Zach
@Moose1551
Apr 07 2016 06:24
var myCar = new nickname();
myCar.nickname = "Zach Attack";
Going insane.
Markus Kiili
@Masd925
Apr 07 2016 06:25
@Moose1551 var myCar = new Car();
Zach
@Moose1551
Apr 07 2016 06:27
@Masd925 , Thank you for your patience.
var myCar = new nickname();
myCar.nickname = "Zach Attack";
CamperBot
@camperbot
Apr 07 2016 06:27
moose1551 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1325 | @masd925 | http://www.freecodecamp.com/masd925
Zach
@Moose1551
Apr 07 2016 06:28
Sorry. Meant to send this:
var myCar = new Car();
Car.nickname = "Zach Attack";
Robert Uivarosi
@URobert
Apr 07 2016 06:30
@Moose1551 you probably want to do:
myCar.nickname = "Zach Attack"
Zach
@Moose1551
Apr 07 2016 06:32
That was it, @URobert . I could have sworn that I had already typed that in 50 times...
Robert Uivarosi
@URobert
Apr 07 2016 06:33
@Moose1551 you might be tried. Take a break if you feel you need to
Zach
@Moose1551
Apr 07 2016 06:34
Just started:( It's 3:34 pm where I am. I'm just stupid:'(
Robert Uivarosi
@URobert
Apr 07 2016 06:36
@Moose1551 LOL. It has nothing to do with that. Sometimes you don't see the most basic mistake, you'll get better at it with time. Don't worry about that
Markus Kiili
@Masd925
Apr 07 2016 06:37
@Moose1551 No, you only have thick skull.
Zach
@Moose1551
Apr 07 2016 06:38
@URobert , thanks, brother. It's a war of attrition at this point. @Masd925, haha. I'm pretty sure you've tried to help me a few times in the last month.
CamperBot
@camperbot
Apr 07 2016 06:38
moose1551 sends brownie points to @urobert and @masd925 :sparkles: :thumbsup: :sparkles:
:warning: moose1551 already gave masd925 points
:star: 768 | @urobert | http://www.freecodecamp.com/urobert
Zach
@Moose1551
Apr 07 2016 06:43
Making dark little jokes like this is what keeps me going:
var myCar = new Car (6, 6, 6);
While I'm on here, is it bad Github etiquette to paste code in the way I just did if it's only one line?
Markus Kiili
@Masd925
Apr 07 2016 06:45
@Moose1551 I think you are doing it right. Except for that number of the beast you just wrote.
Robert Uivarosi
@URobert
Apr 07 2016 06:48
@Moose1551 yw
Zach
@Moose1551
Apr 07 2016 06:48
That was the dark little joke I was referring to, @Masd925 , haha
AaronCs
@AaronCs
Apr 07 2016 06:49
Can someone give me a hint as to why this is not working?
js
Markus Kiili
@Masd925
Apr 07 2016 06:49
@Moose1551 Every code bangs their heads on the wall all the time. I'm trying to make things work on old Internet Explorers at the moment.
AaronCs
@AaronCs
Apr 07 2016 06:49
function largestOfFour(arr) {
  var arrLargest = [];
  for (var i = 0; i < arr.length; i++) { // Loops through each array
    for (var j = 0; j < arr[i].length; j++){ // Loops through the inside of an individual array
      if (arr[i][j] > arr[i][j + 1]) {
       arrLargest.push(arr[i][j]);
     }
    }
  }
  return arrLargest;
}
thomas-duval
@thomas-duval
Apr 07 2016 06:51

Hey guys,
Trying to do the Inventory Update challenge.
I wrote 3 functions :

  • One to loop through the new inv
  • One to loop though the current inv
  • One to update the current inv based on the new inv
    But my loops doesn't seem to work :

    function updateInventory(arr1, arr2) {
      function loopNewInv() {
          console.log('Passed 0 !');
          arr2.forEach(loopCurInv());
      }
    
      function loopCurInv(objNewInv) {
          console.log('Passed 1 !');
          arr1.forEach(updater());
      }
    
      function updater(objCurInv) {
          console.log('Passed 2 !');
      }
    
      return loopNewInv();
    }
    updateInventory(curInv, newInv); // logs : Passed 0 ! Passed 1 ! Passed 2 ! TypeError: updater(...) is not a function

    Any idea why this is not working ?
    Thanks !

Zach
@Moose1551
Apr 07 2016 06:51
@Masd925 , I can't even imagine how that must feel.
Markus Kiili
@Masd925
Apr 07 2016 06:52
@AaronCs You are comparing numbers next to each other. You should make a variable that holds the largest number that you have found on a subarray. Initialize for each subarray and test it against subarray elements, and push it to arrLargest after subarray element loop.
AaronCs
@AaronCs
Apr 07 2016 06:53
What do you mean by 'comparing numbers next to each other'?
Markus Kiili
@Masd925
Apr 07 2016 06:55
@AaronCs arr[i][j] > arr[i][j + 1]
AaronCs
@AaronCs
Apr 07 2016 06:55
Oh I get it.
Thanks
Markus Kiili
@Masd925
Apr 07 2016 06:56
@AaronCs You can also use Math.max.apply(null,array) to find the largest number on an array (subarray here).
swishk
@swishk
Apr 07 2016 07:00
I have answer to the 'Profile Lookup' lesson that's correct and working, I just want feed back on the way i approached it. Is it okay to post solutions here or is there another room for that?
swishk
@swishk
Apr 07 2016 07:03
@Masd925 perfect thank you :)
CamperBot
@camperbot
Apr 07 2016 07:03
swishk sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1326 | @masd925 | http://www.freecodecamp.com/masd925
Eva Crawford
@grooveva
Apr 07 2016 07:09
This message was deleted
yuriik83
@yuriik83
Apr 07 2016 07:10
Hi! Please help. Need convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.

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

// Only change code below this line
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";
break;

}

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

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

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

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

  }
    return collection;

}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Okay I think I'm roughly on track up above
Markus Kiili
@Masd925
Apr 07 2016 07:11
@grooveva Use value!==""
@grooveva Figure out how to access particular record with given id. This is wrong: [id][prop]
Eva Crawford
@grooveva
Apr 07 2016 07:13
hmm okay do I need collection[id][prop] instead?
Ankit Panwar
@coderNoob
Apr 07 2016 07:14
This message was deleted
Markus Kiili
@Masd925
Apr 07 2016 07:16
@grooveva Yes.
Jan Nissi Harrison
@NissiHarrison
Apr 07 2016 07:19
help Record Collection
CamperBot
@camperbot
Apr 07 2016 07:19

:point_right: checkpoint record collection [wiki]

Checkpoint: Record Collection

Instructions

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

If value is blank, delete that prop.

Always return the entire collection object.

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint record collection on the FCC Wiki

Eva Crawford
@grooveva
Apr 07 2016 07:19
This message was deleted
This message was deleted
This message was deleted
lemme try pasting that code one more time!
This message was deleted
This message was deleted
Shivam Arora
@shivamarora13
Apr 07 2016 07:24
how to convert just first letter of a word to upper case?
Markus Kiili
@Masd925
Apr 07 2016 07:24
@grooveva Your if's should test value and prop. On if blocks you should access collection.
Eva Crawford
@grooveva
Apr 07 2016 07:24
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

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

  }
    return collection;

}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
there we go okay @Masd925 I think i know what you mean lemme see
Eldar Tinjić
@EldarT90
Apr 07 2016 07:25

´´´js function reverseString(str) {
var newArr = [];
var arrsplit = str.split("");
for (i = 0; i < arrsplit.length; i++) {
newArr.unshift([i]);
}
return newArr;
}

reverseString("hello");

what was the following "command" to embed code in the website?
i tought it was something like ´´´js
Shivam Arora
@shivamarora13
Apr 07 2016 07:26
how to convert just first letter of a word to upper string?
Markus Kiili
@Masd925
Apr 07 2016 07:27
@EldarT90 Unshift str.charAt(i) and join the array to a string at the end.
@shivamarora13 You have to construct a new string and assign it to a variable or array element. Use string operations like .charAt(), .slice(),and .toUpperCase().
Ankit Panwar
@coderNoob
Apr 07 2016 07:28
Why does if(typeof bool==="boolean") work but not if(typeof bool===Boolean)?
Markus Kiili
@Masd925
Apr 07 2016 07:28
@shivamarora13 Strings are immutable, so changing a character is not possible.
@coderNoob typeof returns a string, and Boolean is a function.
Ankit Panwar
@coderNoob
Apr 07 2016 07:29
@Masd925 Oh. Thanks.
CamperBot
@camperbot
Apr 07 2016 07:29
codernoob sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1327 | @masd925 | http://www.freecodecamp.com/masd925
Jan Nissi Harrison
@NissiHarrison
Apr 07 2016 07:30
@Masd925 kindly help me with this one
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Shivam Arora
@shivamarora13
Apr 07 2016 07:30
@Masd925 thanks!
CamperBot
@camperbot
Apr 07 2016 07:30
shivamarora13 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1328 | @masd925 | http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Apr 07 2016 07:30
@NissiHarrison The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
So .prop and .id don't work there.
Eldar Tinjić
@EldarT90
Apr 07 2016 07:31
@Masd925 nice, thanks , gosh i have problem with accessing the "right" key/piece of something
CamperBot
@camperbot
Apr 07 2016 07:31
eldart90 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1329 | @masd925 | http://www.freecodecamp.com/masd925
Eva Crawford
@grooveva
Apr 07 2016 07:31
@Masd925 but that's what it's doing right? The final if else if looks at collection[id][prop] and if the value is equal to nothing. I'm guessing I'm not referencing that value correctly?
Eldar Tinjić
@EldarT90
Apr 07 2016 07:31
@Masd925 i mean, i usually forget about it, because in last 2-3 problems i had a hint from chat, it was always the same thing :/
Eva Crawford
@grooveva
Apr 07 2016 07:33
@NissiHarrison the one thing I can tell you is won't be able to use dot notation as you aren't referencing specific id's you'll need to use brackets
Markus Kiili
@Masd925
Apr 07 2016 07:34
@grooveva You should be checking if the value is empty.
Jan Nissi Harrison
@NissiHarrison
Apr 07 2016 07:34
@grooveva @Masd925 thanks ididnt know that....because i thought that bracket notation are for properties with spaces
CamperBot
@camperbot
Apr 07 2016 07:34
nissiharrison sends brownie points to @grooveva and @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1330 | @masd925 | http://www.freecodecamp.com/masd925
:star: 223 | @grooveva | http://www.freecodecamp.com/grooveva
Eva Crawford
@grooveva
Apr 07 2016 07:35
@Masd925 but isn't that what ==="" is doing?
Markus Kiili
@Masd925
Apr 07 2016 07:36
@grooveva It should be if (value==="") delete collection[id][prop];
@grooveva If the user gives an id and property key and empty value, you need to delete the property. You don't care what the property value is that you need to delete.
Eva Crawford
@grooveva
Apr 07 2016 07:38
@Masd925 totally get that makes sense, but it doesn't seem to work
@Masd925 actually sorry yes it does but doesn't seem to work for the "tracks" double checking now
Jan Nissi Harrison
@NissiHarrison
Apr 07 2016 07:45
@Masd925 this is the revised code please review....still doesnt pass
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
th log says cannot read property 'ABBA' of undefined
Markus Kiili
@Masd925
Apr 07 2016 07:48
@grooveva All tests are on value and prop. Not on collection...
@grooveva First should be if (value !=="" && prop!=="tracks")
@grooveva You test user input, not collection content. Depending on the user input, you do things to collection.
Eva Crawford
@grooveva
Apr 07 2016 07:51
// Only change code below this line
function updateRecords(id, prop, value) {
   if (value !=="" && prop!=="tracks") {
    collection[id][prop]=value;

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

  }
    return collection;

}
@masd925 That all works great except for my push statement apparently
Aman Barnwal
@amanbarnwalce
Apr 07 2016 07:51
What is a constructor?
Markus Kiili
@Masd925
Apr 07 2016 07:52
@grooveva It works.
Eva Crawford
@grooveva
Apr 07 2016 07:53
@Masd925 OOPS you are totally right I had some stray syntax floating around below thank you for everything that makes so much more sense now
CamperBot
@camperbot
Apr 07 2016 07:53
grooveva sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
Markus Kiili
@Masd925
Apr 07 2016 07:53
@amanbarnwalce Any function in JS can be used to create objects by using new keyword. Such functions that are made for that are called constructors.
CamperBot
@camperbot
Apr 07 2016 07:53
:star: 1331 | @masd925 | http://www.freecodecamp.com/masd925
Jan Nissi Harrison
@NissiHarrison
Apr 07 2016 07:54
ty @Masd925 i have completedthe challenge...ty for the help
Markus Kiili
@Masd925
Apr 07 2016 07:54
@NissiHarrison You're wellcome.
thomas-duval
@thomas-duval
Apr 07 2016 07:56

Hey guys,
Trying to do the Inventory Update challenge.
I wrote 3 functions :

  • One to loop through the new inv
  • One to loop though the current inv
  • One to update the current inv based on the new inv
    But my loops doesn't seem to work :
    ```function updateInventory(arr1, arr2) {

    function loopNewInv() {
        console.log('Passed 0 !');
        arr2.forEach(loopCurInv());
    }
    
    function loopCurInv(objNewInv) {
        console.log('Passed 1 !');
        arr1.forEach(updater());
    }
    
    function updater(objCurInv) {
        console.log('Passed 2 !');
    }
    
    return loopNewInv();

    }
    updateInventory(curInv, newInv); // logs : Passed 0 ! Passed 1 ! Passed 2 ! TypeError: updater(...) is not a function

```
Any idea why this is not working ?
Thanks !

Eldar Tinjić
@EldarT90
Apr 07 2016 08:00
```js

function palindrome(str) {

for (var i = 0; i< str.length; i++) {
if (i === "1" || i === "2" || i === "3" || i === "4" || i === "5" || i === "6" || i === "7" || i === "8" || i === "9" || i === "0" || i === "." || i === "," || i ===" ") {
str[i].replace("");
}
}

var adasd = "";
var newArr = [];
var arrsplit = str.split("");
for (i = 0; i < arrsplit.length; i++) {
newArr.unshift(str[i]);
}
var part1 = newArr.join("");
var arrsplitrev = part1.toLowerCase();

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

palindrome("eySe");

can some1 tell me how can i embedd the code? something like ```js ?
´´´js
ztchia
@ztchia
Apr 07 2016 08:06
 function myTest(num) {
  // Only change code below this line
  if (num < 5) {

  return "Tiny";

  } else if (num < 10 && num >= 5) {

  return "Small";

  } else if (num < 15 && num >= 10) {

    return "Medium";

  } else if (num < 20 && num  >= 15) {

    return "Large";

  } else {

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

// Change this value to test
myTest(5);
Hi guys, I am suppose to do the "Chaining If Else Statements". At the terminal, I get the response I want but for some reasons the system doesn't let me pass the challenge. Can you guys help me and take a look at what I did wrong?
Write chained if/else if statements to fulfill the following conditions:

num < 5 - return "Tiny"
num < 10 - return "Small"
num < 15 - return "Medium"
num < 20 - return "Large"
num >= 20 - return "Huge"
This is the challenge instruction.
Eldar Tinjić
@EldarT90
Apr 07 2016 08:08
function palindrome(str) {

 for (var i = 0; i< str.length; i++) {
   if (i === "1" || i === "2" || i === "3" || i === "4"  || i === "5" || i === "6" || i === "7"  || i === "8" || i === "9" || i === "0" || i === "." || i === "," || i ===" ") {
     str[i].replace("");
   }
 }



  var adasd = "________________________________";
  var newArr = [];
  var arrsplit = str.split("");
  for (i = 0; i < arrsplit.length; i++) {
    newArr.unshift(str[i]);
  }
  var part1 = newArr.join("");
  var arrsplitrev = part1.toLowerCase();

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

palindrome("eySe");
Vivek
@vivek28111992
Apr 07 2016 08:08
@ztchia looks fine to me, can you reset the challenge and then solve it
Mohammedaadem As
@mohamma548
Apr 07 2016 08:09
@ztchia i would suggest first change the arrangement of the < or > positions i,e check first num>=5&&num<10 then first checks if it is greater than 5 then checks if less than 10
ztchia
@ztchia
Apr 07 2016 08:10
Oh resetting. solved the challenge! thx guys
Aman Barnwal
@amanbarnwalce
Apr 07 2016 08:12

What's wrong?

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

//Try it out here
var myCar = new Car(6, 3, 1);

Mohammedaadem As
@mohamma548
Apr 07 2016 08:14
hello guys can you please suggest me any idea on how to change to characters

function rot13(str) { // LBH QVQ VG!
var stringArr=[];
var changeTo=[];
var finalWord=[];
for(var i=0;i<str.length;i++){ stringArr[i]=str.charCodeAt(i); if(stringArr[i]>64&&stringArr[i]<78){

  changeTo.push(stringArr[i]+13);
}
else if(stringArr[i]>77&&stringArr[i]<91){
  changeTo.push(stringArr[i]-13);

}

}

return changeTo;

}

// Change the inputs below to test
rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK");

i did it like this

function rot13(str) { // LBH QVQ VG!
var stringArr=[];
var changeTo=[];
var finalWord="";
for(var i=0;i<str.length;i++){ stringArr[i]=str.charCodeAt(i); if(stringArr[i]>64&&stringArr[i]<78){

  changeTo.push(stringArr[i]+13);
}
else if(stringArr[i]>77&&stringArr[i]<91){
  changeTo.push(stringArr[i]-13);

}

}
for(var j=0;j<changeTo.length;j++){
finalWord[j]=changeTo.fromCharCode(j);
}

return finalWord;
}

Aleksander Gębicki
@Takumar
Apr 07 2016 08:17

@mohamma548 use backticks for formatting your code:

```
your code
```
Don't put anything in lines with backticks

Eldar Tinjić
@EldarT90
Apr 07 2016 08:20
function palindrome(str) {

 for (var i = 0; i< str.length; i++) {
   if (i === "1" || i === "2" || i === "3" || i === "4"  || i === "5" || i === "6" || i === "7"  || i === "8" || i === "9" || i === "0" || i === "." || i === "," || i ===" ") {
    str[i].pop();
   }
 }



  var adasd = "________________________________";
  var newArr = [];
  var arrsplit = str.split("");
  for (i = 0; i < arrsplit.length; i++) {
    newArr.unshift(str[i]);
  }
  var part1 = newArr.join("");
  var arrsplitrev = part1.toLowerCase();

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

palindrome("eySe adas");
still need help, especially first part with removing unnecesary symbols
Mohammedaadem As
@mohamma548
Apr 07 2016 08:20
@Takumar it says u need to use version Es6
alpox
@alpox
Apr 07 2016 08:21
@EldarT90 take a look into regex and str.replace
Aleksander Gębicki
@Takumar
Apr 07 2016 08:22

@mohamma548 I wanted you to only display it like that:

function rot13(str) { // LBH QVQ VG!
  var stringArr=[];
  var changeTo=[];
  var finalWord="";
  for(var i=0;i<str.length;i++){
    stringArr[i]=str.charCodeAt(i);
    if(stringArr[i]>64&&stringArr[i]<78){

      changeTo.push(stringArr[i]+13);
    }
    else if(stringArr[i]>77&&stringArr[i]<91){
      changeTo.push(stringArr[i]-13);

    }
  }
  for(var j=0;j<changeTo.length;j++){
    finalWord[j]=changeTo.fromCharCode(j);
  }

  return finalWord;
}

Where you got message about Es6?

Mohammedaadem As
@mohamma548
Apr 07 2016 08:23
@Takumar I always wanted to do it like that but i couldnt
can you please tell me how
i tried ```
Brian
@sludge256
Apr 07 2016 08:23
The ES6 is just a warning.
Mohammedaadem As
@mohamma548
Apr 07 2016 08:23
but doesnt work
Brian
@sludge256
Apr 07 2016 08:23
If your browser supports it you can ignore the message.
Most modern up to date browsers support ES6.
Mohammedaadem As
@mohamma548
Apr 07 2016 08:24

```function rot13(str) { // LBH QVQ VG!
var stringArr=[];
var changeTo=[];
var finalWord="";
for(var i=0;i<str.length;i++){ stringArr[i]=str.charCodeAt(i); if(stringArr[i]>64&&stringArr[i]<78){

  changeTo.push(stringArr[i]+13);
}
else if(stringArr[i]>77&&stringArr[i]<91){
  changeTo.push(stringArr[i]-13);

}

}
for(var j=0;j<changeTo.length;j++){
finalWord[j]=changeTo.fromCharCode(j);
}

return finalWord;
}

// Change the inputs below to test
rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK");```

Aleksander Gębicki
@Takumar
Apr 07 2016 08:25
@EldarT90 Palindromes challenge is meant to make you learn something about regular expressions - they are useful, I had them on last interview too.
Check this link: http://regexone.com/ to learn the basics. And train on that site: http://regexr.com/ creating them.
After you remove unnecessary characters with regular expression, rest of challenge is quite easy.
mtmorawska
@mtmorawska
Apr 07 2016 08:25
Hi guys, I'm trying to sum up all numbers in a range. I declare a variable 'counter' at the beginning and set it to 0. Then I make a loop where values are added to a counter. I return counter outside the loop and it is still set to 0. I know it's a problem of local/global variables but I have no idea how to fix it.

function sumAll(arr) {
var counter = 0;
for (i = Math.min(arr); i <= Math.max(arr); i++) {
counter += i;
}
return counter;
}

sumAll([1, 4]);

Aleksander Gębicki
@Takumar
Apr 07 2016 08:25
@mohamma548 you have to put three backticks before and after your code, and you cannot put anything in lines with backticks.
Mohammedaadem As
@mohamma548
Apr 07 2016 08:26

@Takumar ```
function rot13(str) { // LBH QVQ VG!
var stringArr=[];
var changeTo=[];
var finalWord="";
for(var i=0;i<str.length;i++){ stringArr[i]=str.charCodeAt(i); if(stringArr[i]>64&&stringArr[i]<78){

  changeTo.push(stringArr[i]+13);
}
else if(stringArr[i]>77&&stringArr[i]<91){
  changeTo.push(stringArr[i]-13);

}

}
for(var j=0;j<changeTo.length;j++){
finalWord[j]=changeTo.fromCharCode(j);
}

return finalWord;
}

// Change the inputs below to test
rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK");

```

@Takumar still same
Aleksander Gębicki
@Takumar
Apr 07 2016 08:27
@mohamma548 also my nick cannot be before backticks, I know it is frustrating :-)
```
// some code
```
mtmorawska
@mtmorawska
Apr 07 2016 08:27
'''
CamperBot
@camperbot
Apr 07 2016 08:27
:bulb: to format code use backticks! ``` more info
Mohammedaadem As
@mohamma548
Apr 07 2016 08:27
function rot13(str) { // LBH QVQ VG!
  var stringArr=[];
  var changeTo=[];
  var finalWord="";
  for(var i=0;i<str.length;i++){
    stringArr[i]=str.charCodeAt(i);
    if(stringArr[i]>64&&stringArr[i]<78){

      changeTo.push(stringArr[i]+13);
    }
    else if(stringArr[i]>77&&stringArr[i]<91){
      changeTo.push(stringArr[i]-13);

    }
  }
  for(var j=0;j<changeTo.length;j++){
    finalWord[j]=changeTo.fromCharCode(j);
  }

  return finalWord;
}

// Change the inputs below to test
rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK");
Aleksander Gębicki
@Takumar
Apr 07 2016 08:27
@mohamma548 well done :thumbsup:
mtmorawska
@mtmorawska
Apr 07 2016 08:27

'''function sumAll(arr) {
var counter = 0;
for (i = Math.min(arr); i <= Math.max(arr); i++) {
counter += i;
}
return counter;
}

sumAll([1, 4]);'''

CamperBot
@camperbot
Apr 07 2016 08:27
:bulb: to format code use backticks! ``` more info
Mohammedaadem As
@mohamma548
Apr 07 2016 08:27
@Takumar thx it works
CamperBot
@camperbot
Apr 07 2016 08:27
mohamma548 sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 3018 | @takumar | http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Apr 07 2016 08:28
@mtmorawska backticks are usually on the left side of 1 digit key (on US keyboard layout )
Mohammedaadem As
@mohamma548
Apr 07 2016 08:29
@Takumar what do you think whats wrong with my code?
Aleksander Gębicki
@Takumar
Apr 07 2016 08:29
@mtmorawska your code is not working?
mtmorawska
@mtmorawska
Apr 07 2016 08:30
nope
function sumAll(arr) {
  var counter = 0;
  for (i = Math.min(arr); i <= Math.max(arr); i++) {
    counter += i;
    }
  return counter;
}

sumAll([1, 4]);
hianita
@hianita
Apr 07 2016 08:30
hello, here's basic question for
// Example
/*var ourName; /
// Define myName below this line
hello, here's basic question for declare JavaScript Variables.
the following is my code.
// Example
/*var ourName; /
// Define myName below this line
mtmorawska
@mtmorawska
Apr 07 2016 08:32
As I said, the counter is still 0 after the code executes
hianita
@hianita
Apr 07 2016 08:33
oh sorry, I found the solution~
Denis
@bestkid74
Apr 07 2016 08:33
@mtmorawska VAR i need
for(VAR i=...
Eldar Tinjić
@EldarT90
Apr 07 2016 08:33
@Takumar oke, i am checking this atm
mtmorawska
@mtmorawska
Apr 07 2016 08:34
@bestkid74 still not working
Hang Hu
@theodorehu95
Apr 07 2016 08:35
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var arr1=arr.slice();
  arr1.sort();

  for(var i=0;i<arr1.length;i++){
    if(arr1[i]>=num){
      return i;
    }
  }

  return i;
}

getIndexToIns([5, 3, 20, 3], 5);
Why this code can output the right index for this input?
It seems that arr1.sort() doesn't work
Mohammedaadem As
@mohamma548
Apr 07 2016 08:37
@theodorehu95 you need to declare a counter from zero then increments as i increase
then returns the counter
not i
Hang Hu
@theodorehu95
Apr 07 2016 08:38
The problem of scope?
mtmorawska
@mtmorawska
Apr 07 2016 08:38
@Takumar any ideas what could be wrong?
Hang Hu
@theodorehu95
Apr 07 2016 08:39
But the weird thing is when I return the arr1.sort(). it's also wrong.
Mohammedaadem As
@mohamma548
Apr 07 2016 08:40
@theodorehu95 first arrange them in assending order
Aleksander Gębicki
@Takumar
Apr 07 2016 08:40

@mohamma548 you have some errors in your code.
If you want to assign values to finalWord array (not string) you have to declare it as array.

var finalWord = [];

Assignment is made wrong, you should check how fromCharCode() String method works. Try this:

finalWord[j]= String.fromCharCode(changeTo[j]);

And the third thing, you should not modify elements which are not letters from given range, you need else statement in your conditions. Now you are removing characters other than letters (for example spaces between words)

Svetlana Linuxenko
@linuxenko
Apr 07 2016 08:41
@theodorehu95 sort() sorts in unicode order
Hang Hu
@theodorehu95
Apr 07 2016 08:41
Yes. but why [5,3,20,3].sort() is [20,3,3,5];
Coy Sanders
@coymeetsworld
Apr 07 2016 08:41
@linuxenko has it right
Hang Hu
@theodorehu95
Apr 07 2016 08:41
@linuxenko what does that mean
Svetlana Linuxenko
@linuxenko
Apr 07 2016 08:41
@theodorehu95 you have to implement your own sorting function
if u would sort it like 1, 2,3,...
Mohammedaadem As
@mohamma548
Apr 07 2016 08:42
@theodorehu95 use compare function compare(a,b) return a-b
Hang Hu
@theodorehu95
Apr 07 2016 08:42
@linuxenko @mohamma548 I will go to see the document of sort() Thanks. This is really weird.
CamperBot
@camperbot
Apr 07 2016 08:42
theodorehu95 sends brownie points to @linuxenko and @mohamma548 :sparkles: :thumbsup: :sparkles:
:star: 268 | @mohamma548 | http://www.freecodecamp.com/mohamma548
:star: 346 | @linuxenko | http://www.freecodecamp.com/linuxenko
Miloud Bouzeboudja
@yassineldn29
Apr 07 2016 08:44
Stuck with this assigment
Aleksander Gębicki
@Takumar
Apr 07 2016 08:44
@mtmorawska you should check documentation of max() and min() methods:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min
they don't take array as argument! You have to give them values
Miloud Bouzeboudja
@yassineldn29
Apr 07 2016 08:45

My code:

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

return item; // Change this line
}

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

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

Aleksander Gębicki
@Takumar
Apr 07 2016 08:46

@mtmorawska try this:

  for (i = Math.min(arr[0], arr[1]); i <= Math.max(arr[0], arr[1]); i++) {

but read documentation in link I gave you.

Aman Barnwal
@amanbarnwalce
Apr 07 2016 08:47

isn't it supposed to work?

array.sort(function(a, b) {
return a + b;
});

Aleksander Gębicki
@Takumar
Apr 07 2016 08:47
@amanbarnwalce rather not, try difference a - b or b - a

@amanbarnwalce from documentation https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort :

If compareFunction is supplied, the array elements are sorted according to the return value of the compare function. If a and b are two elements being compared, then:
If compareFunction(a, b) is less than 0, sort a to a lower index than b, i.e. a comes first.
If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other, but sorted with respect to all different elements. Note: the ECMAscript standard does not guarantee this behaviour, and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.
If compareFunction(a, b) is greater than 0, sort b to a lower index than a.
compareFunction(a, b) must always return the same value when given a specific pair of elements a and b as its two arguments. If inconsistent results are returned then the sort order is undefined.

Mohammedaadem As
@mohamma548
Apr 07 2016 08:49
@Takumar I got the letters but how can i get the spaces?
Aleksander Gębicki
@Takumar
Apr 07 2016 08:50
@mohamma548 I've told you that you should create else statement after if/else if because you cannot modify rest of characters, but you should put them to array.
mtmorawska
@mtmorawska
Apr 07 2016 08:50
@Takumar thanks a tone! I will check it out
CamperBot
@camperbot
Apr 07 2016 08:50
mtmorawska sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 3019 | @takumar | http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Apr 07 2016 08:51
@mohamma548 of course at the end you should join all letters in array to string using join() method.
@mtmorawska you are welcome :-)

@yassineldn you have to do three things in this challenge:

  • add item to the end of arr array
  • remove first element of arr array
  • return removed element from your function

Do you have any idea about this? You learned about array methods used for such purposes.

Mohammedaadem As
@mohamma548
Apr 07 2016 08:55
@Takumar this is how it looks like my code
function rot13(str) { // LBH QVQ VG!
  var stringArr=[];
  var changeTo=[];
  var finalWord=[];
  for(var i=0;i<str.length;i++){
    stringArr[i]=str.charCodeAt(i);
    if(stringArr[i]>64&&stringArr[i]<78){

      changeTo.push(stringArr[i]+13);
    }
    else if(stringArr[i]>77&&stringArr[i]<91){
      changeTo.push(stringArr[i]-13);

    }
  }
  for(var j=0;j<changeTo.length;j++){
    finalWord[j]=String.fromCharCode(changeTo[j]);
  }
  var word = finalWord.join('');

  return word;
}

// Change the inputs below to test
rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK");
what do i add in the else statement any idea?
Aleksander Gębicki
@Takumar
Apr 07 2016 08:57
@mohamma548 you need that part:
    changeTo.push(stringArr[i]-13);
  }
  else {
     changeTo.push(...
  }
@mohamma548 read this again:
Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.
Markus Kiili
@Masd925
Apr 07 2016 08:59
@Takumar Hi. Glad to hear that it went well. More than one hour trip to work gets annoying in the long run. But what can you do but to bear it for a while at least.
Aleksander Gębicki
@Takumar
Apr 07 2016 09:01
Hi @Masd925 worse thing is that I've thought that my daughter can stay at school till 17:30 and it appeared they take care of children only to 16:30 and I have a big problem now :-(
Now I have to find a solution for that.
@Masd925 so I was happy on Monday and I am worried on Thursday :-)
Markus Kiili
@Masd925
Apr 07 2016 09:03
@Takumar Grandma to the rescue or something like that.
Mohammedaadem As
@mohamma548
Apr 07 2016 09:04
@Takumar I am almost there but I ried to push with empty spaces in the else statement but doest work
Aleksander Gębicki
@Takumar
Apr 07 2016 09:04
@Masd925 my mother is 120km away, my wife's mother 35km and I hope she will help us at the moment. There are 3 months till summer holidays and maybe I will find another solution in this time (or another work)
@mohamma548 show how you did this.
Mohammedaadem As
@mohamma548
Apr 07 2016 09:05
function rot13(str) { // LBH QVQ VG!
  var stringArr=[];
  var changeTo=[];
  var finalWord=[];
  for(var i=0;i<str.length;i++){
    stringArr[i]=str.charCodeAt(i);
    if(stringArr[i]>64&&stringArr[i]<78){

      changeTo.push(stringArr[i]+13);
    }
    else if(stringArr[i]>77&&stringArr[i]<91){
      changeTo.push(stringArr[i]-13);

    }
    else{
      changeTo.push();
    }
  }
  for(var j=0;j<changeTo.length;j++){
    finalWord[j]=String.fromCharCode(changeTo[j]);
  }
  var word = finalWord.join('');

  return word;
}

// Change the inputs below to test
rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK");
Aleksander Gębicki
@Takumar
Apr 07 2016 09:05
@mohamma548 you don't push anything with push() where are lost characters?
Mohammedaadem As
@mohamma548
Apr 07 2016 09:05
  changeTo.push(' ');
Aleksander Gębicki
@Takumar
Apr 07 2016 09:06
@mohamma548 Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.
you cannot change all characters to spaces.
pass them on !
Mohammedaadem As
@mohamma548
Apr 07 2016 09:08
@Takumar thx man
CamperBot
@camperbot
Apr 07 2016 09:08
mohamma548 sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:warning: mohamma548 already gave takumar points
Aleksander Gębicki
@Takumar
Apr 07 2016 09:09
@mohamma548 does it mean you've completed this?
Sandeep Prasad Bhatt
@sandy100
Apr 07 2016 09:09
hi , can anyone help me with switch statement into a lookup table .
Mohammedaadem As
@mohamma548
Apr 07 2016 09:09
@Takumar yap
i did it
rphares
@rphares
Apr 07 2016 09:11
Hi, @sandy100 ! Im pretty sure if you paste the code you are trying for challenge 'using objects for lookups' , @Takumar or one of the other rockstars here will help :blush:
(or me... just i know they like to a lot :) )
Markus Kiili
@Masd925
Apr 07 2016 09:12
@rphares Hi.
Sandeep Prasad Bhatt
@sandy100
Apr 07 2016 09:13
@rphares I have created object replacing the switch
but i am stuck at passing object key to the funtion parameter
rphares
@rphares
Apr 07 2016 09:13
hi, @Masd925 !
Could you paste what you tried, please, @sandy100 ? these experts can explain it pretty well :)
Sandeep Prasad Bhatt
@sandy100
Apr 07 2016 09:14

/ 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"
};

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

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

rphares
@rphares
Apr 07 2016 09:16
Okay, cool. So next, lets look at the example. their table is named var alpha and they want to get what is associated with 2 from it, so they write, alpha[2], @sandy100
your table is named var lookup and you want to get what is associated with val , so you could write...?
Markus Kiili
@Masd925
Apr 07 2016 09:17
@sandy100 Use syntax obj[key] to access objects property value. Where is the object and what is the key?
rphares
@rphares
Apr 07 2016 09:17
(sorry, I'm not good at using terms, hence my pushing you to the experts in the room)
Yay! @Masd925 , leaving @sandy100 with you :blush:
Markus Kiili
@Masd925
Apr 07 2016 09:17
@rphares You put such pressure to our thin shoulders.
rphares
@rphares
Apr 07 2016 09:18
lol, just wanted to make sure they get help as i sent them here... and i know you are more than capable :blush:
Spartano
@Spartano
Apr 07 2016 09:18
@moigithub thanks
CamperBot
@camperbot
Apr 07 2016 09:18
spartano sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 828 | @moigithub | http://www.freecodecamp.com/moigithub
Sandeep Prasad Bhatt
@sandy100
Apr 07 2016 09:19
@Masd925 for eg: the key is alpha and value is Adams
but requirement is phoneticLookup("alpha") should equal "Adams"
Markus Kiili
@Masd925
Apr 07 2016 09:20
@sandy100 You should use the object lookup and key val, so your function works on any key passed to the function.
Blauelf
@Blauelf
Apr 07 2016 09:20
As the function returns the content of variable result, you should set that to the value (preferably after you have constructed your lookup object).
Sandeep Prasad Bhatt
@sandy100
Apr 07 2016 09:23
but i need to pass the key of an lookup object to the function
for all key value pairs
Blauelf
@Blauelf
Apr 07 2016 09:26
The function gets called with a key in argument named val. You are meant to assign the associated value (associated by lookup) to result.
Sandeep Prasad Bhatt
@sandy100
Apr 07 2016 09:31
@Blauelf sorry i didn't get you .
i know what i need to do in the problem but i am unable to do that
:(
@Blauelf let me explain .
lookup.alpha gives "Adams "
similarly lookup.bravo gives boston
Aleksander Gębicki
@Takumar
Apr 07 2016 09:33
@sandy100 may I add one word to that. You should do something similar to accessing element of array.
var myArr= [3, 6, 1]; how would you access element with index i from that array? i=1;
@sandy100 var result = myArr... what is the answer? (use i index)
Sandeep Prasad Bhatt
@sandy100
Apr 07 2016 09:34
myArr[i];
within the for loop
to access all the elements
@Takumar
Aleksander Gębicki
@Takumar
Apr 07 2016 09:34
@sandy100 very good. Now you can access property of object using bracket notation like in example with array.
But instead of index i you got val variable which contains name of property you want to get value.
Blauelf
@Blauelf
Apr 07 2016 09:35
@sandy100 lookup["alpha"] also gives "Adams" :)
Aleksander Gębicki
@Takumar
Apr 07 2016 09:36
@sandy100 I hope it helped you instead of messing up :-)
Sandeep Prasad Bhatt
@sandy100
Apr 07 2016 09:36
ok i will try once again @Takumar @Blauelf :)
Aleksander Gębicki
@Takumar
Apr 07 2016 09:37
@sandy100 now @Blauelf showed you how to access that value using name of property ("alpha"), but you have that name hidden in val parameter of function, just use it.
Sandeep Prasad Bhatt
@sandy100
Apr 07 2016 09:47
yes :) !!
Done !!
THank you @Blauelf
Thanks @Takumar
CamperBot
@camperbot
Apr 07 2016 09:47
sandy100 sends brownie points to @blauelf and @takumar :sparkles: :thumbsup: :sparkles:
:star: 1539 | @blauelf | http://www.freecodecamp.com/blauelf
:star: 3021 | @takumar | http://www.freecodecamp.com/takumar
rphares
@rphares
Apr 07 2016 09:49
Oooh, congrats, @sandy100 ~
Aman Barnwal
@amanbarnwalce
Apr 07 2016 09:56

Hi there, i was creating a program to find out the factorials and it works pretty well but the problem arises when it tries to find out the factorial of 0. I can use an if statement which will pass the value 1 to factorial if the given number is 0 but i want to know if there's any other way to do it?
This is what i wrote
function factorialize(num) {
for(i=1; i<num; i++) {
num *= i;
}
return num;
}

factorialize(5);

cannelflow
@cannelflow
Apr 07 2016 09:58
if(num===0||num===1){
      return 1;
else follow you for loop
@amanbarnwalce
Aman Barnwal
@amanbarnwalce
Apr 07 2016 09:59
I know that way but why to do that? i mean why the factorial of 0 is 1?
cannelflow
@cannelflow
Apr 07 2016 10:00
Aman Barnwal
@amanbarnwalce
Apr 07 2016 10:02
err.. I am not so good with math let's do this with if statement
anyways thanks @cannelflow
CamperBot
@camperbot
Apr 07 2016 10:02
amanbarnwalce sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 1045 | @cannelflow | http://www.freecodecamp.com/cannelflow
Islam Ibakaev
@dagman
Apr 07 2016 10:02
is it me or people build js calculator not correctly?
Aman Barnwal
@amanbarnwalce
Apr 07 2016 10:06

What the hell em' doing wrong??

if(num===0||num===1){
return 1;
}
else{
for(i=1; i<num; i++) {
num *= i;
}
return num;
}
}

Craig Banach
@CraigBanach
Apr 07 2016 10:10
@amanbarnwalce Can you please format your code
help format
CamperBot
@camperbot
Apr 07 2016 10:10

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Craig Banach
@CraigBanach
Apr 07 2016 10:11
@dagman Not sure, can you give an example?
Rithvik Vibhu
@rithvikvibhu
Apr 07 2016 10:12
use `Shift + Enter` for multiline
<your code here>
oops
i mean ``` at the beginning and end
3 backticks
Blauelf
@Blauelf
Apr 07 2016 10:13
@amanbarnwalce num changes in each iteration, making i impossible to reach it. You could do it the other way around:
  for (var fact=1; num>0; num--) {
    fact *= num;
  }
  return fact;
Prosvia
@Prosvia
Apr 07 2016 10:13
I'm stuck on "No repeats please" task. I made my factorial function and I made a function to determine how many repeating characters there are in a string. So with those two functions I thought that I could calculate how many permutations there are without any repeating characters, but it turns out that my naive algorithm in my head was naive and doesn't work. So, I dunno, I'm stuck. I don't even know whether I can figure the amount of permutations without repeating characters by what those two functions of my give me.
ObedJosiah
@obedjosiah
Apr 07 2016 10:13
help Ceasars Cipher
CamperBot
@camperbot
Apr 07 2016 10:13
no wiki entry for: ceasars cipher
Craig Banach
@CraigBanach
Apr 07 2016 10:13
@Prosvia Post your code formatted and mentioned all failed test. WE will help out
help format
CamperBot
@camperbot
Apr 07 2016 10:13

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

ObedJosiah
@obedjosiah
Apr 07 2016 10:14
help Caesars Cipher
CamperBot
@camperbot
Apr 07 2016 10:14

:point_right: algorithm caesars cipher [wiki]

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

:checkered_flag: Problem Explanation:

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

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

Blauelf
@Blauelf
Apr 07 2016 10:14
@Prosvia Most people generate a list of permutations and then count those without repeats.
Islam Ibakaev
@dagman
Apr 07 2016 10:15
@CraigBanach just calculate 4 + 6 * 10 here http://www.online-calculator.com/ and in your calculator to see defference
Craig Banach
@CraigBanach
Apr 07 2016 10:16
@dagman The user stories for the FCC calculator explicitly wants it to work differently than the link you provided
Islam Ibakaev
@dagman
Apr 07 2016 10:17
@CraigBanach you are wrong
@CraigBanach chaining with right output
Craig Banach
@CraigBanach
Apr 07 2016 10:18
@dagman User Story: I can keep chaining mathematical operations together until I hit the equal button, and the calculator will tell me the correct output.
No I'm not
4+6*10 = 64
Prosvia
@Prosvia
Apr 07 2016 10:18
@Blauelf Yeah, I wanted to do that at first but then realised how processor intensive that stuff is and decided to try something more lighter. But now I'm stuck.
Islam Ibakaev
@dagman
Apr 07 2016 10:18
@CraigBanach with the right output for user
@CraigBanach you are right from math point
Craig Banach
@CraigBanach
Apr 07 2016 10:19
@dagman That is the only point possible to be right from...
Islam Ibakaev
@dagman
Apr 07 2016 10:20
@CraigBanach but when user writes it he actually wanna see 100
Prosvia
@Prosvia
Apr 07 2016 10:20
@CraigBanach
Craig Banach
@CraigBanach
Apr 07 2016 10:20
@dagman And you know that becuase?
Prosvia
@Prosvia
Apr 07 2016 10:20
@CraigBanach ```
function permAlone(str) {

  //sorted elements of str into arr  
  var arr = str.split("");

  arr = arr.sort();

  //gets factorials  
  function factorial(n) {
    var total = 1;
    for (var i = n; i >= 1; i--) {
      total *= i;
    }
    return total;
  }
  // returns how many repeats there are and how many characters there are in an array.
  function repeat(arr) { 

        var prev;
        var repeats = [];  
    for ( var i = 0; i < arr.length; i++ ) {
        if ( arr[i] !== prev ) {
            repeats.push(1);
        } else {
            repeats[repeats.length-1]++;
        }
        prev = arr[i];
    }     
   return repeats.filter(function(a){
     return a != 1;
   });
}

var total = factorial(str.length);
var repeats = repeat(arr);


for (var i = 0; i<repeats.length; i++){
  while (repeats[i]>=1){
  total = total - factorial(str.length - repeats[i]+1)*factorial(repeats[i]);
  repeats = repeats[i] - 1;  
  }
}  
return total;  

}
permAlone("aabb");
I'm entirely sure how to explain the last for loop which is my magical algorithm ...
Craig Banach
@CraigBanach
Apr 07 2016 10:23
@Prosvia You have stuff sitting outside of functions that shouldn't be.
@dagman Given the example application I highly doubt that.
Markus Kiili
@Masd925
Apr 07 2016 10:24
@CraigBanach Everything is inside permAlone.
Islam Ibakaev
@dagman
Apr 07 2016 10:25
@CraigBanach i just want to say when i put 5 + 5 * 10 in chain i as user actually wanna see `5 +5 evaluating to 10 in background then * 10 return 100
Prosvia
@Prosvia
Apr 07 2016 10:26
@Masd925 The tabs aren't tidy, my bad.
Craig Banach
@CraigBanach
Apr 07 2016 10:26
@dagman Well then you are not fulfilling the user stories and examples and will fail the scenario when it comes to be graded :D
Islam Ibakaev
@dagman
Apr 07 2016 10:26
@dagman i mean when i write 5 + 5 and click multiple sign the expression should evaluate to 10 in background
Craig Banach
@CraigBanach
Apr 07 2016 10:27
@Prosvia What tests are you failing?
Prosvia
@Prosvia
Apr 07 2016 10:27
4th and 6th both are too large.
Craig Banach
@CraigBanach
Apr 07 2016 10:28
@Prosvia what result do you get for them?
Denis
@bestkid74
Apr 07 2016 10:30
function permAlone(str) {
  var a=str.length;
  var b=1;
  for(var i=1; i<=a; i++){
    b*=i; // total combination
  }
  var c=[];
  var h=0;
  for(var j=0; j<(a-1); j++){
    c[h]=1;
    for(var k=(j+1); k<a; k++){
      if(str[j]==str[k]){
        c[h]++;
      }
    }
    if(c[h]>1){
      j+=(c[h]-2);
      h++;
    }
    if(j==(a-2)) break;
  }
  var d=c.filter(function(item){
    return item!=1;
  });
  // Arr d - the number of repeated characters
  var l=1;
  if(!d.length) return false;
  for(i=1; i<=(a-1); i++){
    l*=i;
  }
  if(d.length==1){
    l*=d[0]; // extra combination
  }
  b=b-l;
  return b;
}

permAlone('aab');
Prosvia
@Prosvia
Apr 07 2016 10:30
permAlone("aabb") gives me 12 and permAlone("abfdefa") gives 3600 even though they should be giving 8 and 2640. So I would assume that my algorithm is messed up with improper logic.
Blauelf
@Blauelf
Apr 07 2016 10:30
@Prosvia No idea how that algorithm is supposed to work (I counted them, only had some fail-early optimization to speed things up).
But if you struggle with code indentation, and your editor does not help, you could try jsbeautifier.org ;)
Prosvia
@Prosvia
Apr 07 2016 10:31
@Blauelf Well it is a very magical algorithm. Lemme try to explain it to you.
Craig Banach
@CraigBanach
Apr 07 2016 10:31
@Prosvia I'm also struggling with your algorithm as this wasn't my easiest challenge.
Denis
@bestkid74
Apr 07 2016 10:31
it doesn`t work if more then 1 pair
Prosvia
@Prosvia
Apr 07 2016 10:31
Okay, okay I'll try to explain my logic
Denis
@bestkid74
Apr 07 2016 10:33
can you help me how to get extra combination if more than 1 pair repeated characters ?
Aman Barnwal
@amanbarnwalce
Apr 07 2016 10:34
Hi there! is there any way to replace the multiple characters of a string at once?
Markus Kiili
@Masd925
Apr 07 2016 10:35
@amanbarnwalce .replace() and regExp
Prosvia
@Prosvia
Apr 07 2016 10:41

So the first part of the algorithm is this:

So you got a string "aab" it has a total of 3! permutations.

Let that be var total.

Now lets assume that the repeating characters are actually a single element.

So now the string has [aa]b two elements. This string now has 2! permutations, each of which has repeating elements.

Let that number be called var repeats.

But the two a's also have two permutations, right, because they can be switched places.

So you multiply the repeats by the amount of permutions they can have and then subtract that from the total.

Basically:

total - repeats*repeats!

Prosvia
@Prosvia
Apr 07 2016 10:46
So if there are two different repeating characters you do that thing to both of them and subtract that from the total.

And if there are more than 2 repeating characters of the same sort you do the same , but you subtract one character from the coagulation of elements and add it to the string.
So you do the above process to the "aaab" like [aaa]b then [aa]ab until it is two.

Oh jeez. I just realized that this bit here is kind of dumb because it would subtract the same thing multiple times ...

Did anything of that make any sense?
Denis
@bestkid74
Apr 07 2016 10:52
just tell how to get extra combination for 2 pairs repeated characters
if you know...
Lawrence Eagles
@lawrenceagles
Apr 07 2016 11:03

please guys I'm stuck here. need help: function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
if (str.substr(-1)!= target) {
return false;
} else {
return true;
}

}

confirmEnding("Bastian", "n");

Markus Kiili
@Masd925
Apr 07 2016 11:07
@lawrenceagles You cannot use -1 there. You have to use target.length somehow. So the end part of str, that you slice, is as long as target.
Rich Keyzor
@Web-Dev-Rich
Apr 07 2016 11:12
@lawrenceagles It is working but you are not outputting anything. If you put console.log(true); instead of return true; you will see true in the console.
Lawrence Eagles
@lawrenceagles
Apr 07 2016 11:14
Rich Keyzor
@Web-Dev-Rich
Apr 07 2016 11:14
@lawrenceagles or even just console.log(confirmEnding("Bastian", "n")); and check the console.
@Masd925 -1 works for me!
Markus Kiili
@Masd925
Apr 07 2016 11:15
@Web-Dev-Rich It doesn't work.
Rich Keyzor
@Web-Dev-Rich
Apr 07 2016 11:18
This message was deleted
Markus Kiili
@Masd925