These are chat archives for FreeCodeCamp/HelpJavaScript

15th
Nov 2016
Jan
@burning-monk
Nov 15 2016 00:00
@JJcreated no you shoul encode it not decode
Rob Gaston
@robgaston1
Nov 15 2016 00:00
@ctinaa sure I just pulled up my solution
gabi
@gikwu1
Nov 15 2016 00:00
@sjames1958gm , can u help pls
Jan
@burning-monk
Nov 15 2016 00:00
no you should decode it and not encode
alf
@alfmoh
Nov 15 2016 00:00
Tried using Boolean Objects but just couldn't get my head around it
Gabi
@JJcreated
Nov 15 2016 00:00
@gikwu1 its Zero based indexing so arr[0] means the zeroeth character in the arr array, which is [1, 2, 3]
Jordy weerwag
@TheCodeWriter1
Nov 15 2016 00:01

```js
var myVar = 87;

// Only change code below this line

myVar = myVar++ +1;

Jan
@burning-monk
Nov 15 2016 00:01
so if you encode A will be N but if you decode it N will be A
gabi
@gikwu1
Nov 15 2016 00:01
@JJcreated , yes i know this
Jordy weerwag
@TheCodeWriter1
Nov 15 2016 00:01
var myVar = 87;

// Only change code below this line

myVar = myVar++ +1;
Rob Gaston
@robgaston1
Nov 15 2016 00:01
@TheCodeWriter1 you do not need the +1 in addition to the ++
myVar++ wil increment the variable by one already
Gabi
@JJcreated
Nov 15 2016 00:02
@burning-monk you need to tell the console what the encoding means first, then you decode it so the computer understands what to do
gabi
@gikwu1
Nov 15 2016 00:02
how does
arr[3][0][1]; // equals 11
Iqbal
@mibaldobaghi
Nov 15 2016 00:02
@JohnnyBizzel got it done brooo
gabi
@gikwu1
Nov 15 2016 00:02
@JJcreated ?
Iqbal
@mibaldobaghi
Nov 15 2016 00:02
thanks
Jan
@burning-monk
Nov 15 2016 00:03
@JJcreated Write a function which takes a ROT13 encoded string as input and returns a decoded string.
Jordy weerwag
@TheCodeWriter1
Nov 15 2016 00:03
oke but one ting it says is that i shoud myVay =myVar change @JJcreated
Jan
@burning-monk
Nov 15 2016 00:03
the string is encoded and you have to decode it
Johnny
@JohnnyBizzel
Nov 15 2016 00:03
@mibaldobaghi Top man!! :tada: :sparkles:
gabi
@gikwu1
Nov 15 2016 00:03
@JohnnyBizzel >
Iqbal
@mibaldobaghi
Nov 15 2016 00:03
@JohnnyBizzel have a beer on me
gabi
@gikwu1
Nov 15 2016 00:03
anyone?
Will
@Will-is-Coding
Nov 15 2016 00:03
@gikwu1 arr is a multi-dimensional array.
var example = [0, 1, 2]; where example[0] is equal to 0. You access the elements of the array by the index, but in your arr it contains other arrays.
In your example arr[0] will be the array object at the 0 index, which is [1, 2, 3]. So following suit, it shows you how to access the deepest array at index 3 in arr
Johnny
@JohnnyBizzel
Nov 15 2016 00:04
@mibaldobaghi Thanks :beers:
CamperBot
@camperbot
Nov 15 2016 00:04
johnnybizzel sends brownie points to @mibaldobaghi :sparkles: :thumbsup: :sparkles:
:cookie: 348 | @mibaldobaghi |http://www.freecodecamp.com/mibaldobaghi
Rob Gaston
@robgaston1
Nov 15 2016 00:04
@TheCodeWriter1 I am sorry, I don't understand. If you can provide more context
Will
@Will-is-Coding
Nov 15 2016 00:04
@ctinaa Is that the recursive algorithm?
Iqbal
@mibaldobaghi
Nov 15 2016 00:04
@gikwu1 whats the question?
Christina Cook
@ctinaa
Nov 15 2016 00:05
@robgaston1 I don't know how to make it so that I don't have to type out (n - 1) (n - 2) (n -3) etc
@Will-is-Coding I don't know haha. Am I supposed to do it recursively?
gabi
@gikwu1
Nov 15 2016 00:05
@Will-is-Coding , i know this, biut how then do i get my data to equal 8? just as
```
arr[3]0; // equals 11
Gabi
@JJcreated
Nov 15 2016 00:05
@gikwu1 the the second element, in the 1st element in the 4th element of the aray is 11
array*
Jordy weerwag
@TheCodeWriter1
Nov 15 2016 00:05
var myVar = 87;

// Only change code below this line

myVar = myVar++ +1;

myVar should equal 88
-->myVar = myVar should be changed<--
Use the ++ operator
Do not change code above the line

thats what i must do xD

Jan
@burning-monk
Nov 15 2016 00:06
@ctinaa is that Factorialize a Number?
Will
@Will-is-Coding
Nov 15 2016 00:07
@gikwu1 Well in your example, to get the value of 8 you would access it as arr[2][1] as arr[2] is [7, 8, 9] ( or second index inside of arr ). Then you want the first index of this array, which is 8
Gabi
@JJcreated
Nov 15 2016 00:07
@TheCodeWriter1 myVar = myVar +1
why are you using ++ here, is it in the question?
Christina Cook
@ctinaa
Nov 15 2016 00:07
@burning-monk yeah
Jan
@burning-monk
Nov 15 2016 00:07
@ctinaa you don't need a recursion for that, just take a for loop
Rob Gaston
@robgaston1
Nov 15 2016 00:07
@ctinaa have you thought about trying to generate all the numbers that need to be multiplied?
Justin Pierson
@jpmitchellpierson
Nov 15 2016 00:07
@TheCodeWriter1 try just myVar++ without anything else
Christina Cook
@ctinaa
Nov 15 2016 00:07
OHHH
Will
@Will-is-Coding
Nov 15 2016 00:07
@ctinaa Well have you done recursion before? That would be one way. Or another way would involve a loop and saving the value
Christina Cook
@ctinaa
Nov 15 2016 00:07
LOL I totally forgot for loops existed for a second
I'm not sure how you would do it recursively though
Will
@Will-is-Coding
Nov 15 2016 00:08
Just do it as a loop, that'll do just fine as @burning-monk said.
Jan
@burning-monk
Nov 15 2016 00:08
@ctinaa that's a little bit more complicated
Will
@Will-is-Coding
Nov 15 2016 00:08
Recursion is another thing to wrap your head around that you don't need now lol.
Iqbal
@mibaldobaghi
Nov 15 2016 00:08
@TheCodeWriter1 ++ is to incrementally increase a number i think. myVar += 1 should do it
Christina Cook
@ctinaa
Nov 15 2016 00:08
Haha Recursion is when you call the function it self so it's more efficent right?
Will
@Will-is-Coding
Nov 15 2016 00:09
Correct, it's a function that calls itself until the job is done
Christina Cook
@ctinaa
Nov 15 2016 00:09
Ah so we can use recursion here to call itself until the factorial gets to 1
Jan
@burning-monk
Nov 15 2016 00:09
is that more efficient?
Christina Cook
@ctinaa
Nov 15 2016 00:10
Idk how to prove it's more efficient
Time complexity?
I will be back lol in a few minutes
Jan
@burning-monk
Nov 15 2016 00:10
you can write both functions and stop the time
Will
@Will-is-Coding
Nov 15 2016 00:10
I wouldn't say it is typically more 'efficient,' depends on what you mean. Processing time wise, hell if I know. But can make the code cleaner
Jan
@burning-monk
Nov 15 2016 00:11
start with !100 000
Coy Sanders
@coymeetsworld
Nov 15 2016 00:11
@ctinaa depends on what you're doing, sometimes recursion is more efficent but may not be
Will
@Will-is-Coding
Nov 15 2016 00:11
Yeah, that'd be a bad idea
Kaloyan K
@Kaloyan-K
Nov 15 2016 00:21
Hi guys, has anyone done the Escape Sequences in Strings lesson recently?
yourpalsneakers
@yourpalsneakers
Nov 15 2016 00:21

Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a ... ending.

Note that inserting the three dots to the end will add to the string length.

However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string.

function truncateString(str, num) {
var aNum = num - 3;
var aStr = str.slice(0, aNum);
var bSrt = str.slice(0, num);
if (str.length > num) {
return aStr + "...";
}
else if (num <= 3) {
return bStr + "...";
}

}
truncateString("A-tisket a-tasket A green and yellow basket", 11);

Any advice on where to go with this??
it solves the first two tests
Will
@Will-is-Coding
Nov 15 2016 00:24
What do you have so far @Kaloyan-K ?
Kaloyan K
@Kaloyan-K
Nov 15 2016 00:27
@Will-is-Coding Hi I have this: var myStr ="FirstLine\n\SecondLine\rThirdLine";
the whole thing with escaping is kind of confusing
Will
@Will-is-Coding
Nov 15 2016 00:28
Btw you need to use ` marks ` when doing using \ as they get escaped here too
__mifflin__
@cdrainxv
Nov 15 2016 00:28
@Kaloyan-K: you should have 6 \ total.
Kaloyan K
@Kaloyan-K
Nov 15 2016 00:29
hmm okay thanks both of you
__mifflin__
@cdrainxv
Nov 15 2016 00:30
@yourpalsneakers: What about the case where str.length == num?
Will
@Will-is-Coding
Nov 15 2016 00:31
@Kaloyan-K I think you're missing a \ after SecondLine (Guessing since they've been escaped here)
yourpalsneakers
@yourpalsneakers
Nov 15 2016 00:34
@cdrainxv hmm, the instructions don't say what to do if str == num, (truncate a string if it is longer than the given maximum string length) so I assume don't return anything right?
__mifflin__
@cdrainxv
Nov 15 2016 00:34

@Kaloyan-K:

Single line Code

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

@yourpalsneakers: If the num and str.length are the same or the num is larger than the str.length then there would be no need to truncate the str… you would just return the str.
drammeh
@drammeh
Nov 15 2016 00:36
Hello Guys.... Any help for Converting Celsius to Fahrenheit...
am stuck and i need help
hudoodesign
@hudoodesign
Nov 15 2016 00:38
Hey guys, how do I add a screenshot?
__mifflin__
@cdrainxv
Nov 15 2016 00:40

@hudoodesign: You can just drag the image onto the chat area… or just post your code:

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 ⏎]

drammeh
@drammeh
Nov 15 2016 00:40
on your keyboard press on the prt sc key to screenshoot then come in here and press ctrl + v @hudoodesign
hudoodesign
@hudoodesign
Nov 15 2016 00:45
function nextInLine(arr, item) {
  // Your code here
  var a = arr.shift();
  var b = arr.push(item);


  return a;  // 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));
```
@cdrainxv Thanks! I really need some help with this one... I can't seem to get it to return both vars... but I could be on the wrong track.
CamperBot
@camperbot
Nov 15 2016 00:46
hudoodesign sends brownie points to @cdrainxv :sparkles: :thumbsup: :sparkles:
:cookie: 940 | @cdrainxv |http://www.freecodecamp.com/cdrainxv
yourpalsneakers
@yourpalsneakers
Nov 15 2016 00:47

@cdrainxv function truncateString(str, num) {
var aNum = num - 3;
var aStr = str.slice(0, aNum);
var bSrt = str.slice(0, num);
if (str.length > num) {
return aStr + "...";
}
else if (num <= 3) {
return bStr + "...";
}

}
truncateString("A-tisket a-tasket A green and yellow basket", 11);

hudoodesign
@hudoodesign
Nov 15 2016 00:48
I also don't understand the //Modify this line to test.
yourpalsneakers
@yourpalsneakers
Nov 15 2016 00:48
still doesn't pass last 2 tests I don't know why!!!
__mifflin__
@cdrainxv
Nov 15 2016 00:48
You want to push first… and then shift… you also don’t need to assign it to variables like a or b.
yourpalsneakers
@yourpalsneakers
Nov 15 2016 00:49
@cdrainxv I added else { return str; }
drammeh
@drammeh
Nov 15 2016 00:49
blob
Conor Murphy
@cmurphy580
Nov 15 2016 00:51
Hey i'm working on the wiki viewer. I have code that works but when i search the searchterm is always the last item on the search output. I'm trying to reverse the order of the object, but am having no luck. Any ideas? here's what I was working on.
 $("#searchBtn").click(function() {
    //Gets search input
    var search = $("#search").val();
    // api url with search 
    var api = "https://en.wikipedia.org/w/api.php?action=opensearch&search=" + search + "&format=json&callback=?";
    //show output table
    $("#listContainer").show();
    $("#output").show();

    //another way to getJSON 
    $.ajax({
      type: "GET",
      url: api,
      async: false,
      dataType: "json",
      success: function(data) {

        //Writes out prior content with blank content--
        $("#output").html("");
        for (var i = 0; i < data[1].length; i++) {

               //Get Heading --
        var heading = data[1][i];
          var rHeading = heading.reverse();
          console.log(rHeading);
        //Get Description -- 
        var descrition = data[2][i];
          var rDescription = description.reverse();
          console.log(rDescription);
        //Get Link -- 
        var link = data[3][i];
          var rLink = link.reverse();
          console.log(rLink);


          $("#output").prepend("<div class='listContainer'><li><a class='btn-default' href=" + rLink + "><h2>" + rHeading + "</h2><hr><p>" + rDescription + "</p></a></li></div>").appendTo("#list").addClass("animated fadeInUpBig");
hudoodesign
@hudoodesign
Nov 15 2016 00:53
@cdrainxv that did it! Thanks for your reply. It still worked with the assigned vars, but I'll check it without. Did you know what the test line was for?
CamperBot
@camperbot
Nov 15 2016 00:53
hudoodesign sends brownie points to @cdrainxv :sparkles: :thumbsup: :sparkles:
:warning: hudoodesign already gave cdrainxv points
Greg Duncan
@GregatGit
Nov 15 2016 00:56
@cmurphy580 prepend try using append instead
__mifflin__
@cdrainxv
Nov 15 2016 00:58
@hudoodesign: That line gave you the array that you used for parameter arr.
Terryd12345
@Terryd12345
Nov 15 2016 01:01

Hey guys any clue why this doesn't work:function titleCase(str) {
str = str.toLowerCase();
str = str.split(" ");

for(var i=0; i < str.length; i++){
str[i][0].toUpperCase();
}
return str;
}

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

hudoodesign
@hudoodesign
Nov 15 2016 01:01
@cdrainxv That's somethingconfusing about the setup. How is var testArr referenced? How is arr a reference to the array shown?
Greg Duncan
@GregatGit
Nov 15 2016 01:05
@Terryd12345 if you split() you often have to join() as well
Conor Murphy
@cmurphy580
Nov 15 2016 01:06
@GregatGit Sweet I'll give it a try
@GregatGit You
Greg Duncan
@GregatGit
Nov 15 2016 01:07
@cmurphy580 append puts to the back and prepend to the front
Terryd12345
@Terryd12345
Nov 15 2016 01:07
@GregatGit Ah yes but the first letter isn't becoming uppercase. I tried just going str[0][0].toUpperCase() which worked but I'm not sure why i cant do that in a loop.
Conor Murphy
@cmurphy580
Nov 15 2016 01:07
Y @GregatGit Youre the coolest thanks for the help!
CamperBot
@camperbot
Nov 15 2016 01:07
cmurphy580 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 785 | @gregatgit |http://www.freecodecamp.com/gregatgit
__mifflin__
@cdrainxv
Nov 15 2016 01:08
@hudoodesign: It’s in this line:
console.log(nextInLine(testArr, 6));
Notice the nextInLine function is called with the two arguments testArr and 6… testArr is passed onto arr and 6 is passed onto item as parameters… which you then used.
Greg Duncan
@GregatGit
Nov 15 2016 01:11
@Terryd12345 have you ever used the console?
__mifflin__
@cdrainxv
Nov 15 2016 01:11

@yourpalsneakers: Your variable doesn’t match:

var bSrt = str.slice(0, num); does not match:
return bStr + "…";

hudoodesign
@hudoodesign
Nov 15 2016 01:12
I think it's the sequence that confuses me. I expect the array used to be declared at the top, then the function that works from that to go below. Having the arguments buried in the console.log between two JSON thingamys... baby steps, guys! lol
plemanski
@plemanski
Nov 15 2016 01:13
I am having some issues with the profile lookup lesson. No matter my input it will return No such contact. Code is below
  if (!contacts.hasOwnProperty(firstName)){
      return ("No such contact");

    // Check to see if there is a prop matching the first name
  } else if (contacts.hasOwnProperty(firstName)){
   //check to see if prop exists and return the value of the prop
    if (contacts.hasOwnProperty(prop)) {
      return contacts.prop;
    }
  }
Terryd12345
@Terryd12345
Nov 15 2016 01:13
@GregatGit Is that the black box under the run tests button?
plemanski
@plemanski
Nov 15 2016 01:14
the stuff underneath is very incomplete but I think the issue lies in the first if statement
__mifflin__
@cdrainxv
Nov 15 2016 01:15
@plemanski: You should be using a for loop… how else are you going to traverse the contacts array… Also you want to return "No such contact" outside the loop.
n1a2n3d4i5n6i
@n1a2n3d4i5n6i
Nov 15 2016 01:15
Hi can some one explain me Escape sequences
Vladislav Galushko
@LordJocker
Nov 15 2016 01:15
Can anyone help? I need some kind of checkbox to the left of my To Do List items. How do i do it? http://codepen.io/lordjocker/pen/Vmjrpb
plemanski
@plemanski
Nov 15 2016 01:15
ty @cdrainxv
CamperBot
@camperbot
Nov 15 2016 01:15
plemanski sends brownie points to @cdrainxv :sparkles: :thumbsup: :sparkles:
:cookie: 941 | @cdrainxv |http://www.freecodecamp.com/cdrainxv
Greg Duncan
@GregatGit
Nov 15 2016 01:15
shift + control + i
@Terryd12345 toUpperCase() does not change the letter in question - but return the letter capitalized
capital.JPG
@Terryd12345
jrr5230
@jrr5230
Nov 15 2016 01:20
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));
// Only change code below this line
function updateRecords(id, prop, value) {

  if(collection.hasOwnProperty(prop) === false){
   var proper =  collection[prop]; 
   proper += collection[prop][value];
  }
  else if(collection.hasOwnProperty(prop) == 1 && value !== ""){
  var proper1 = collection[prop].push(value);
  }
  else if(collection.hasOwnProperty(value) === false ){
    delete collection.prop;
  }
  return collection;
}
// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Need a little help solving the Recored collection problem
Steve Brockley
@stevebrockley
Nov 15 2016 01:22
do I ever need help! first of all, how do I show my code in those black boxes that you all use?
Greg Duncan
@GregatGit
Nov 15 2016 01:23
@Terryd12345 sometime a function changes the variable and other times it just gives you brand new data while the orginal data stays the same
Terryd12345
@Terryd12345
Nov 15 2016 01:23
@GregatGit so why is it not possible to then say str[i][0] = str[i][0].toUpperCase() that also throws a typeError
plemanski
@plemanski
Nov 15 2016 01:25
@cdrainxv is my for loop just going to count up 1 until it finds the correct name? I am not too sure how to implement a for loop in this problem.
jrr5230
@jrr5230
Nov 15 2016 01:25
@stevebrockley if you go to the markdown help menu next to where you text, it will show you how to set it up
@stevebrockley it's pretty much (Then you press shift + enter)(afterwards paste your code)(then finish with again)
Greg Duncan
@GregatGit
Nov 15 2016 01:26
@Terryd12345 perhaps if you were to turn the individual words into arrays of letters - that might work
jrr5230
@jrr5230
Nov 15 2016 01:26
(```)
__mifflin__
@cdrainxv
Nov 15 2016 01:26
@stevebrockley: :point_up: November 14, 2016 5:40 PM
Steve Brockley
@stevebrockley
Nov 15 2016 01:27

function myLocalScope() {
'use strict';

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

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

// Now remove the console log line to pass the test

sorry that didn't work
jrr5230
@jrr5230
Nov 15 2016 01:29
(add ```before and after your code)
Steve Brockley
@stevebrockley
Nov 15 2016 01:30
ok so how do I do the back ticks on my macbook?
Greg Duncan
@GregatGit
Nov 15 2016 01:31
@stevebrockley I think it is first left to '1'
Steve Brockley
@stevebrockley
Nov 15 2016 01:31
got it! thanks @jrr5230 @cdrainxv
CamperBot
@camperbot
Nov 15 2016 01:31
stevebrockley sends brownie points to @jrr5230 and @cdrainxv :sparkles: :thumbsup: :sparkles:
:cookie: 236 | @jrr5230 |http://www.freecodecamp.com/jrr5230
:cookie: 943 | @cdrainxv |http://www.freecodecamp.com/cdrainxv
jrr5230
@jrr5230
Nov 15 2016 01:33
@stevebrockley btw I think all you have to do is comment out or delete the console.log statement outside your function (under the comment myVar is not defined outside.....)
__mifflin__
@cdrainxv
Nov 15 2016 01:34
@plemanski: here’s a skeletal structure of what you need to do:
for loop () {
    if (name exists) {
      // exists then look for persons's prop
      if (prop exists) {
        // exist so display prop
    // return the prop
      }
   // prop. doesn't exist?
    // return "prop not found"
      }
// outside the loop

// didn't find the person
// return "person not found"
Terryd12345
@Terryd12345
Nov 15 2016 01:34
@GregatGit awesome thanks man finally got it !
CamperBot
@camperbot
Nov 15 2016 01:34
terryd12345 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 786 | @gregatgit |http://www.freecodecamp.com/gregatgit
Greg Duncan
@GregatGit
Nov 15 2016 01:36
@Terryd12345 cool. Try stringing functions together
str = str.toLowerCase();
str = str.split(" ");
or
str = str.toLowerCase().split(" ");
Somia ♡
@somiajagadish
Nov 15 2016 01:36

Word Blanks

We will now use our knowledge of strings to build a "Mad Libs" style word game we're calling "Word Blanks". You will create an (optionally humorous) "Fill in the Blanks" style sentence.

You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence.

We have provided a framework for testing your results with different words. The tests will run your function with several different inputs to make sure all of the provided words appear in the output, as well as your extra strings.

Help?

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

// Your code above this line
return result;
}

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

what do they want me to do??
Steve Brockley
@stevebrockley
Nov 15 2016 01:37
```
Somia ♡
@somiajagadish
Nov 15 2016 01:37
?
Coy Sanders
@coymeetsworld
Nov 15 2016 01:37
return a string that includes those variables via string concatenation @somiajagadish
plemanski
@plemanski
Nov 15 2016 01:38
Ah, that is how I thought it needed to go. Just to confirm, the for loop is to iterate throughout the contacts array? Why exactly can I not use hasownProperty? @cdrainxv
Steve Brockley
@stevebrockley
Nov 15 2016 01:38

``` var code = function myLocalScope() {
'use strict';

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

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

// Now remove the console log line to pass the test
```

Coy Sanders
@coymeetsworld
Nov 15 2016 01:38
its like a madlib, some of the words are constant and you put in various words to make a sentence up
plemanski
@plemanski
Nov 15 2016 01:38
@cdrainxv To clarify, do you know why it would not work
Somia ♡
@somiajagadish
Nov 15 2016 01:38
@coymeetsworld so i have to return what?
Coy Sanders
@coymeetsworld
Nov 15 2016 01:38
a string
Rita Alfonso
@alfonsotech
Nov 15 2016 01:39

Hi, I'm trying to toggle a checkbox between checked and unchecked and I'm not sure why it's not working. Here is the code:

HTML

<form class='checkbox-form'>
   <input type='checkbox' class='checkbox' />
</form>

JS

coursesView.toggleCheckBox = function() {
  $('.checkbox').on('click', function() {
    if($('.checkbox').checked === false) {
      $('.checkbox').checked = true;
    } else {
      $('.checkbox').checked = false;
    }
  });
};
Steve Brockley
@stevebrockley
Nov 15 2016 01:39
damn it I can't make the black screen work! I just want to be able to post like the rest of you
Somia ♡
@somiajagadish
Nov 15 2016 01:39
so return wordBlanks @coymeetsworld
Coy Sanders
@coymeetsworld
Nov 15 2016 01:39
no thats the function name @somiajagadish
inside there they declared a variable named result, you need to assign that to a String
plemanski
@plemanski
Nov 15 2016 01:39
@DesertBugZ The code needs to be on a seperate line under the first 3 backticks
Somia ♡
@somiajagadish
Nov 15 2016 01:39
@stevebrockley just copy and past :))
Coy Sanders
@coymeetsworld
Nov 15 2016 01:39
mixed with the variables youre getting in (i.e. myNoun, ,myAdjective) etc
Somia ♡
@somiajagadish
Nov 15 2016 01:40
@coymeetsworld im confused
jrr5230
@jrr5230
Nov 15 2016 01:40
try doing the first three backticks first then pressing shift and enter @stevebrockley (copy and paste your code and then ending with three backticks)
Coy Sanders
@coymeetsworld
Nov 15 2016 01:40
did you do the challenges on String concatenation yet @somiajagadish ?
Steve Brockley
@stevebrockley
Nov 15 2016 01:40
Ok! trying again
Somia ♡
@somiajagadish
Nov 15 2016 01:40
let me check @coymeetsworld
no i havent @coymeetsworld
Coy Sanders
@coymeetsworld
Nov 15 2016 01:41
are you doing these in order @somiajagadish
Somia ♡
@somiajagadish
Nov 15 2016 01:41
the last one i did was Use Bracket Notation to Find the Nth-to-Last Character in a String
Jonathan Laflamme
@jonathanlaflamme
Nov 15 2016 01:41

It doesn’t work (supposed to sen back titled… first letters of each word capitalised))
‘’'
function titleCase(str) {
var splittedString = str.split(" ");
console.log(splittedString);
var strToUpper;
var blabla;

for(var i = 0; i < splittedString.lenght; i++){
blabla[i] = (splittedString[i].charAt(0).toUpperCase() + splittedString[i].slice(1));
}

strToUpper = blabla.join(" ");
return blabla;
}

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

Somia ♡
@somiajagadish
Nov 15 2016 01:41
@coymeetsworld
yes
Coy Sanders
@coymeetsworld
Nov 15 2016 01:42
then you shouldve done String concatenation i believe
__mifflin__
@cdrainxv
Nov 15 2016 01:42
@plemanski: It does… and you will to find if the property exists… You have to find it the property exists regardless of the index the person is in the contacts array… that’s why you need to loop through it.
Coy Sanders
@coymeetsworld
Nov 15 2016 01:42
let me check again
Somia ♡
@somiajagadish
Nov 15 2016 01:42
no i haven't
jrr5230
@jrr5230
Nov 15 2016 01:42
you're just pretty much using the strings as a "Fill in the Blanks to complete the sentence"
Coy Sanders
@coymeetsworld
Nov 15 2016 01:42
i would do that first then @somiajagadish, because youll need to do something similar in Word Blanks
jrr5230
@jrr5230
Nov 15 2016 01:42
@somiajagadish
Somia ♡
@somiajagadish
Nov 15 2016 01:42
I don't have that
Coy Sanders
@coymeetsworld
Nov 15 2016 01:43
Concatenating String with the Plus Operator @somiajagadish
its a few challenges below the one you completed
*above
Somia ♡
@somiajagadish
Nov 15 2016 01:43
oh well im doing them in order though
Coy Sanders
@coymeetsworld
Nov 15 2016 01:44
ok well do that challenge first, then come back to Word Blanks
comaeternal
@comaeternal
Nov 15 2016 01:44
Does anyone know why my true false statement isn't working. I get outputs that are true, but the false statement doesn't run.
```

function mutation(arr) {
  var one = arr[0];
  var two = arr[1];
    if (one.indexOf(two, 0)) {
      return true;


  } else {
    return false;
  }       

}


mutation(["hello", "hey"]);
Coy Sanders
@coymeetsworld
Nov 15 2016 01:44
i'm looking at the map and Concatenating comes first, and the concept is needed to do Word Blanks so makes sense it would be first, im not sure what you're seeing @somiajagadish
plemanski
@plemanski
Nov 15 2016 01:44
@cdrainxv That part i figured, I just want to know the theory behind needing a for loop to iterate through the array in the first place
Somia ♡
@somiajagadish
Nov 15 2016 01:45
@coymeetsworls i have this one first :/

Concatenating Strings with Plus Operator Complete

Concatenating Strings with the Plus Equals Operator

i have done these
@coymeetsworld
__mifflin__
@cdrainxv
Nov 15 2016 01:46
@plemanski: What’s your understanding of a for loop?
Coy Sanders
@coymeetsworld
Nov 15 2016 01:46
right thats the ones i was talking about @somiajagadish
so thats what you need to do with wordblanks
Somia ♡
@somiajagadish
Nov 15 2016 01:46
these are for the the plus operator though
Coy Sanders
@coymeetsworld
Nov 15 2016 01:46
yes thats what you'll need to use
because youll be putting multiple words together to form a string
Somia ♡
@somiajagadish
Nov 15 2016 01:47
@coymeetsworld but how? i dont have the sentece
Coy Sanders
@coymeetsworld
Nov 15 2016 01:47
you make one up @somiajagadish
plemanski
@plemanski
Nov 15 2016 01:47
A loop that runs until the final expression is met
Coy Sanders
@coymeetsworld
Nov 15 2016 01:47
and parts of it will stay constant
so i could have a string like "This animal is a " + someAnimal
Somia ♡
@somiajagadish
Nov 15 2016 01:47
@coymeetsworld okay thanks
CamperBot
@camperbot
Nov 15 2016 01:47
somiajagadish sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1529 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Nov 15 2016 01:47
This animal is a will always be returned, but someAnimal can vary
plemanski
@plemanski
Nov 15 2016 01:47
I suppose I should say condition is met @cdrainxv
Coy Sanders
@coymeetsworld
Nov 15 2016 01:48
just like a madlib
np @somiajagadish hope that makes sense
Somia ♡
@somiajagadish
Nov 15 2016 01:48
yep ty :)
Jonathan Laflamme
@jonathanlaflamme
Nov 15 2016 01:48
Trying to find why it doen’t send anything, look the for is doing nothing
function titleCase(str) {
  var splittedString = str.split(" ");
  console.log(splittedString);
  var strToUpper;
  var blabla;

  for(var i = 0; i < splittedString.lenght; i++){
    blabla[i] = (splittedString[i].charAt(0).toUpperCase() + splittedString[i].slice(1));
  }

  strToUpper = blabla.join(" ");
  return blabla;
}

titleCase("I'm a little tea pot »);
Somia ♡
@somiajagadish
Nov 15 2016 01:48
wait so i use it for var result correct?
Terryd12345
@Terryd12345
Nov 15 2016 01:49
@GregatGit oh okay ill do that in the future, thanks.
CamperBot
@camperbot
Nov 15 2016 01:49
:warning: terryd12345 already gave gregatgit points
terryd12345 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
Nov 15 2016 01:49
yes @somiajagadish
Somia ♡
@somiajagadish
Nov 15 2016 01:49
okay
Kher Je
@kherrjee
Nov 15 2016 01:50
hello guys can someone help with convertToF()
convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
jrr5230
@jrr5230
Nov 15 2016 01:52
@kherrjee you just set fahrenheit equal to the proper equation involving Celsius
instead of 9/5 I used 1.8
Coy Sanders
@coymeetsworld
Nov 15 2016 01:53
@kherrjee you're converting the number you're passing to convertToF which is a Celsius temperature to Fahrenheit
doesn't matter if you use 9/5 or 1.8 @jrr5230 as long as you get order of operations correct
jrr5230
@jrr5230
Nov 15 2016 01:53
right @coymeetsworld 1.8 is just more convenient
Coy Sanders
@coymeetsworld
Nov 15 2016 01:54
idk if its more convenient, its a matter of preference but either one is ok
__mifflin__
@cdrainxv
Nov 15 2016 01:54
@plemanski: Here’s another question… how would you find the name plemenski in someone else’s contact book, supposing it’s not in alphabetic order… You would have to go page by page, as you would’nt want to skip over it, right? It’s the same thing for the for loop… You don’t necessarily know where the name might show up. In the challenge you know the length, but suppose the contact list is 1000 people long?
jrr5230
@jrr5230
Nov 15 2016 01:54
yep...less characters are required so I went with that lol
Coy Sanders
@coymeetsworld
Nov 15 2016 01:55
its the same amount :)
plemanski
@plemanski
Nov 15 2016 01:55
@cdrainxv That cleared it right up for me ty!
CamperBot
@camperbot
Nov 15 2016 01:55
plemanski sends brownie points to @cdrainxv :sparkles: :thumbsup: :sparkles:
:warning: plemanski already gave cdrainxv points
jrr5230
@jrr5230
Nov 15 2016 01:56
not for people who use parantheses ;)
Parley Kennelly
@parleydk
Nov 15 2016 01:56
I'm working on the Bonfire challenges and I wanted to see other solutions for the Chunky Monkey. This is how I solved it.
whoops edit:


function chunkArrayInGroups(arr, size) {
  // Break it up.
  var a = Math.ceil(arr.length/size);

  var i = 0;
  var array = [];
  for(i=0;i<a;i++){
    array[i]= arr.slice(i*size, i*size+size);
  }

return array;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3);
__mifflin__
@cdrainxv
Nov 15 2016 01:57
@plemanski: :relieved: Nice…
hudsontaylor
@hudsontaylor
Nov 15 2016 02:08
I'm having trouble with this. Why is my code returning a string instead of an array?
function diffArray(arr1, arr2) {
  var newArr = [];
  // Same, same; but different.
  var arr1Length = arr1.length;
  var arr2Length = arr2.length;

  var wholeArr = arr1.concat(arr2);

  for (var i = 0; i <= wholeArr.length; i++) {
    if (wholeArr.indexOf(wholeArr[i]) > 0) {
      newArr += wholeArr[i];
    }
  }

  return newArr;
}

diffArray([1, 2, 3, 5], [7, 2, 3, 4, 5]);
Coy Sanders
@coymeetsworld
Nov 15 2016 02:09
newArr += wholeArr[i]
also i don't think your logic is going to return the difference of two arrays
hudsontaylor
@hudsontaylor
Nov 15 2016 02:09
Yes, that's what I have. What should I put instead?
Coy Sanders
@coymeetsworld
Nov 15 2016 02:10
+= isn't an array function
Array has special methods to add or remove things from it https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
hudsontaylor
@hudsontaylor
Nov 15 2016 02:10
Oh, I should use something like push then, right?
Alan Barr
@alanmbarr
Nov 15 2016 02:10
yep
Coy Sanders
@coymeetsworld
Nov 15 2016 02:10
yes
but also look at your logic, i don't think thats going to return you the differences
newArr is just going to be wholeArr
Eric Green
@Gorray
Nov 15 2016 02:11
Can anyone help me with the Understanding Uninitialized Variables
I'm really stuck
Coy Sanders
@coymeetsworld
Nov 15 2016 02:12
what do you need help with @Gorray ?
Eric Green
@Gorray
Nov 15 2016 02:12
I'm not sure what to put after the var a;
like I'm not sure how to implement the equation
plemanski
@plemanski
Nov 15 2016 02:12
@cdrainxv now I just need to refresh my memory on accessing object properties :P
hudsontaylor
@hudsontaylor
Nov 15 2016 02:12
Thanks @coymeetsworld ! I'm still working on the logic. Just wanted to sort that out :)
CamperBot
@camperbot
Nov 15 2016 02:12
hudsontaylor sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1530 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Nov 15 2016 02:13
np @hudsontaylor
@Gorray essentially you need to assign a to a number value
actually, it gives you the values in the challenge
you need to assign a to 5
Eric Green
@Gorray
Nov 15 2016 02:14
right, and I need to have a value of 6
Coy Sanders
@coymeetsworld
Nov 15 2016 02:14
it will be 6 after all the code runs, including a = a + 1
so when you set a to 5
and a = a + 1 runs, a will be 6
those 3 lines below are just demonstrating that even if you initialize a variable to one value at one point in the code, it can change after other lines run
hence the name, variable
Eric Green
@Gorray
Nov 15 2016 02:15
so, var a=a+1; is the formula
Coy Sanders
@coymeetsworld
Nov 15 2016 02:16
nope
you're not changing those last 3 lines
also that line is invalid
you can't assign a value to itself, because you don't know what a is
you need to assign it to something defined, like a literal number like 5
Eric Green
@Gorray
Nov 15 2016 02:17
so should i just change the a to 5 than
Coy Sanders
@coymeetsworld
Nov 15 2016 02:17
yes
as instructions say, don't overthink it :)
youre just assigning all 3 of those variables to numbers and strings
Eric Green
@Gorray
Nov 15 2016 02:18
so var a=5;
Coy Sanders
@coymeetsworld
Nov 15 2016 02:18
yup
so when a = a + 1 is run
it will look at defined value of a, which is 5
a = 5 + 1
a = 6
Eric Green
@Gorray
Nov 15 2016 02:19
wait so should i actually be typing var a=5+1
Coy Sanders
@coymeetsworld
Nov 15 2016 02:19
no
Eric Green
@Gorray
Nov 15 2016 02:19
ok
comaeternal
@comaeternal
Nov 15 2016 02:19
function mutation(arr) {
  var one = arr[0];
  var two = arr[1];
    if (one.indexOf(two, 0)) {
      return true;


  } else if (one.indexOf(two, 0) !== one) {
    return false;
  }       

}


mutation(["hello", "hey"]);
Coy Sanders
@coymeetsworld
Nov 15 2016 02:19
look at the code, theres a comment says dont change that code below
Eric Green
@Gorray
Nov 15 2016 02:20
I'm really new to code
just trying to get used to it
Alan Barr
@alanmbarr
Nov 15 2016 02:20
That's fine Eric every body starts somewhere
Coy Sanders
@coymeetsworld
Nov 15 2016 02:20
ya just go slow with it and follow instructions carefully @Gorray
comaeternal
@comaeternal
Nov 15 2016 02:20
I get true for the examples, but false never comes out. I think my true/ false statement doesn't work
Coy Sanders
@coymeetsworld
Nov 15 2016 02:20
@comaeternal you're not handling all the conditions, theres no else statement
Eric Green
@Gorray
Nov 15 2016 02:21
ALRIGHT, I got it!
thanks
Coy Sanders
@coymeetsworld
Nov 15 2016 02:21
nice work
Eric Green
@Gorray
Nov 15 2016 02:21
so do I pay you know
with the brownie things
*now
comaeternal
@comaeternal
Nov 15 2016 02:22
@coymeetsworld What do you mean? I want to say that if it doesn't find what in arr[0] then return false.
Coy Sanders
@coymeetsworld
Nov 15 2016 02:22
nah its ok @Gorray
Alan Barr
@alanmbarr
Nov 15 2016 02:22
Eric, if you want you just say thanks @ name of the user
and that sends brownie points
Eric Green
@Gorray
Nov 15 2016 02:23
@coymeetsworld
Coy Sanders
@coymeetsworld
Nov 15 2016 02:23
if (one.indexOf(two, 0)) {
      return true;


  } else if (one.indexOf(two, 0) !== one) {
    return false;
  }
if neither of those conditions are true, then nothing happens, you dont return anything
@comaeternal
octothorpus
@octothorpus
Nov 15 2016 02:25

I'm a little stuck with the "Using Objects for Lookups".

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

// Only change code below this line

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

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

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

``

Coy Sanders
@coymeetsworld
Nov 15 2016 02:25
@octothorpus you never change result
you need to use the lookup table you created to set a value to result
comaeternal
@comaeternal
Nov 15 2016 02:25
@coymeetsworld so how do I fix this problem?
Dingly Do
@dinglydo
Nov 15 2016 02:26
testing
Coy Sanders
@coymeetsworld
Nov 15 2016 02:26
i would clean up your logic first @comaeternal, but keep in mind no matter what situation you need to return true or false
thats what an else statement will help you do
Alan Barr
@alanmbarr
Nov 15 2016 02:27
@octothorpus don't use assignments (result = ) in the object
Coy Sanders
@coymeetsworld
Nov 15 2016 02:29
right that too @alanmbarr @octothorpus, you can also remove the undefined part
杲星明
@SymonGao
Nov 15 2016 02:30
@comaeternal
octothorpus
@octothorpus
Nov 15 2016 02:31
I tried it at first without the result = "values", but it didn't work either... and is there a method for returning undefined without using an if, or case statement?
杲星明
@SymonGao
Nov 15 2016 02:31
stringObject.indexOf(searchvalue,fromindex);
Coy Sanders
@coymeetsworld
Nov 15 2016 02:32
@octothorpus lookup is an object
comaeternal
@comaeternal
Nov 15 2016 02:32
@SymonGao Not sure what I'm doing wrong
Coy Sanders
@coymeetsworld
Nov 15 2016 02:33
you use a colon to separate key and value
not equals
look at example on left side
杲星明
@SymonGao
Nov 15 2016 02:34
stringObject.indexOf(searchvalue,fromindex)
if stringObject doesn't contain the searchvalue, it will return -1;
@comaeternal
Steve Brockley
@stevebrockley
Nov 15 2016 02:34
not sure what it is I'm being asked to do in the Local Scope and Functions challenge.
function myLocalScope() {
  'use strict';


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

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

// Now remove the console log line to pass the test
what is the 'use strict'; part? I'm not familiar
plemanski
@plemanski
Nov 15 2016 02:35
@cdrainxv I am still running into some issues but I think it is with finding the property within the object. Unless my for loop is messed up
杲星明
@SymonGao
Nov 15 2016 02:35
so your if statement will be true ;
@comaeternal
plemanski
@plemanski
Nov 15 2016 02:35
var answer;
for (var i = 0; i <= contacts.length; i++){
    if (firstName === contacts.firstName && contacts.hasOwnProperty(prop)) {
     answer = contacts[prop];
    }else if (!contacts.hasOwnProperty(prop)){
      return "No such property";
    }

}
if(!contacts.hasOwnProperty(firstName)) {
  return "No such contact";
}
return answer;
Coy Sanders
@coymeetsworld
Nov 15 2016 02:35
googled it for you @stevebrockley
Steve Brockley
@stevebrockley
Nov 15 2016 02:36
thanks @coymeetsworld
CamperBot
@camperbot
Nov 15 2016 02:36
stevebrockley sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1533 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Nov 15 2016 02:36
in a nutshell it just checks for some gotchas
__mifflin__
@cdrainxv
Nov 15 2016 02:37
@plemanski: contacts[i][prop]
Alan Barr
@alanmbarr
Nov 15 2016 02:38
Steve, in your example it is trying to explain that there is a difference between the variable myVar in the different contexts
__mifflin__
@cdrainxv
Nov 15 2016 02:39
Also you don’t need an if statement outside of the for loop… If the name is not found for the person… then just return "No such contact".
Steve Brockley
@stevebrockley
Nov 15 2016 02:40
"Declare a local variable myVar inside myLocalScope. Run the tests and then follow the instructions commented out in the editor." I understand the last part, but shouldn't myVar = something?
octothorpus
@octothorpus
Nov 15 2016 02:40
@coymeetsworld This was my original one... but I am missing something with the logic. That is why I messed around with the result thing, even though it looked way off.

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

  // Only change code below this line

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

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

// Change this value to test
phoneticLookup("alpha");
__mifflin__
@cdrainxv
Nov 15 2016 02:40
@plemanski: also remove the variable answer just return what you need.
Coy Sanders
@coymeetsworld
Nov 15 2016 02:41
can't use dot notation for variables @octothorpus
Steve Brockley
@stevebrockley
Nov 15 2016 02:41
in the example, the local variable = "foo"; but the instructions just say "Declare a local variable myVar inside myLocalScope"
Coy Sanders
@coymeetsworld
Nov 15 2016 02:41
can only use dot notation if you know the name of the property, like lookup.charlie, or lookup.delta
if its a variable you need bracket notation
octothorpus
@octothorpus
Nov 15 2016 02:42
okay, but this doesn't work either :
result = lookup["val"];
oh wait I got it!!! Not a string! Thanks for the prompts!!!
Alan Barr
@alanmbarr
Nov 15 2016 02:43
Steve, assign myVar in the function and see if you can console log it outside the function
octothorpus
@octothorpus
Nov 15 2016 02:44
thanks @coymeetsworld
CamperBot
@camperbot
Nov 15 2016 02:44
octothorpus sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1534 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Nov 15 2016 02:45
yup, np @octothorpus
yes val isn't a literal string, its an argument of the function, i.e. a variable
plemanski
@plemanski
Nov 15 2016 02:48
@cdrainxv does my if statement need to be if (firstName === contacts[i]firstName && contacts[i].hasOwnProperty(prop))? Now it will only output No such property
No matter the input
Barbara
@barb1643
Nov 15 2016 02:49
Can someone explain to me why this isn't working? Its saying I shouldn't change the code be low the line and I didn't but it's not letting me thru the question..
// Initialize these three variables
var a=6;
var b=15;
var c="I am a String!";
// Do not change code below this line
Coy Sanders
@coymeetsworld
Nov 15 2016 02:49
@barb1643 youre not initializing it to the right values
check instructions closer on the left
a will be 6 after a = a + 1 is run
so a needs to be initialized to 5
杲星明
@SymonGao
Nov 15 2016 02:50
```
function mutation(arr) {
      var one = arr[0];
      var two = arr[1];
      if (one.indexOf(two, 0) == -1)
      {
        return false;
      }
      else
      {
        return true;
      }
    }
    console.log(mutation(["hello", "hey"]));

```

@comaeternal

Steve Brockley
@stevebrockley
Nov 15 2016 02:51
ok got the challenge, thanks @coymeetsworld and @alanmbarr for hanging in there with me. I had it and then just had to delete the last line
CamperBot
@camperbot
Nov 15 2016 02:51
stevebrockley sends brownie points to @coymeetsworld and @alanmbarr :sparkles: :thumbsup: :sparkles:
:warning: stevebrockley already gave coymeetsworld points
:cookie: 312 | @alanmbarr |http://www.freecodecamp.com/alanmbarr
Coy Sanders
@coymeetsworld
Nov 15 2016 02:52
ya np @stevebrockley
Steve Brockley
@stevebrockley
Nov 15 2016 02:52
the JavaScript challenges are certainly more challenging than the html css and bootstrap for me. I find the instructions more obscure too but maybe that's just me
comaeternal
@comaeternal
Nov 15 2016 02:53
@SymonGao
function mutation(arr) {
      var one = arr[0];
      var two = arr[1];
      if (one.indexOf(two, 0) == -1)
      {
        return false;
      }
      else
      {
        return true;
      }
    }
   mutation(["hello", "hey"]);
```
Christian
@xChristianZx
Nov 15 2016 02:53
Just wondering if anyone did this problem a different way for "Return Early Pattern for Functions"
// Setup
function abTest(a, b) {
  // Only change code below this line
if (a < 0 || b < 0){
  return;
}

  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
comaeternal
@comaeternal
Nov 15 2016 02:53
it return just false statements and not any that happen to be true
johncouldbe
@johncouldbe
Nov 15 2016 02:54

So I finished the javascript basic lesson "Profile Lookup" and this is my solution.

function lookUpProfile(firstName, prop){
// Only change code below this line
var propTrue = false;  
var firstNameTrue = false;  

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

  if(contacts[i].firstName == firstName){

    if (contacts[i][prop]){
      propTrue = true;
      return contacts[i][prop];
    } 
    firstNameTrue = true;
  } 
}
  if(!firstNameTrue){
    return "No such contact";
  }

  if(!propTrue){
    return "No such property";
  }

It works and is fairly clean. I just feel like they had a different solution (perhaps more elegant) in mind playing in with the for loops. Did anyone solve this differently?

rissch
@rissch
Nov 15 2016 02:58
Hello ! I would like to ask you, if you have an idea, why the or operator in function isn't working

var code = "function palindrome(str) {
// Good luck!
var a = str.toLowerCase();
function isLetter(value) {
return value !== " " || "_";
}

a = a.split("");
console.log("a = ", a);
var b = a.filter(isLetter);
console.log("b = ", b);
var c = b.reverse();
console.log("c = ",c);
c = c.join("");
b = b.reverse();
b = b.join("");
console.log("c = ",c);
console.log("b = ", b);

if(b===c) {
return true;
}
else {return false;}
}

console.log(palindrome("_e y e"));
";

Barbara
@barb1643
Nov 15 2016 02:59
@coymeetsworld I think I got it...at least I got it right, don't totally understand yet though thanks!
CamperBot
@camperbot
Nov 15 2016 02:59
barb1643 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1535 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Nov 15 2016 03:00
@barb1643 you were assigning values correctly, just not the right ones
the tests on the end were saying that after all the code was run, including the 3 lines below that you didn't touch then the variables would be different
Kher Je
@kherrjee
Nov 15 2016 03:00
hi just having trouble with this, removing all the backslashes to to escape the quotes, idk where
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Coy Sanders
@coymeetsworld
Nov 15 2016 03:01
escaping looks ok, are you sure thats the right instructions? @kherrjee
if so, try refreshing the browser
Kher Je
@kherrjee
Nov 15 2016 03:01
yes @coymeetsworld , okay wait
@coymeetsworld idk what backslashes woudl be removed
the expected out must be two single quotes and four double quotes
Coy Sanders
@coymeetsworld
Nov 15 2016 03:03
oh you need to remove the backslashes and replace the double quotes that are backslashed with single quotes
rissch
@rissch
Nov 15 2016 03:03

function palindrome(str) {
// Good luck!
var a = str.toLowerCase();
function isLetter(value) {
return value !== " " || "_";
}

a = a.split("");
console.log("a = ", a);
var b = a.filter(isLetter);
console.log("b = ", b);
var c = b.reverse();
console.log("c = ",c);
c = c.join("");
b = b.reverse();
b = b.join("");
console.log("c = ",c);
console.log("b = ", b);

if(b===c) {
return true;
}
else {return false;}
}

console.log(palindrome("_e y e"));

Hi, have somebody idea why the or operator in the function isn't working?
Kher Je
@kherrjee
Nov 15 2016 03:03
@coymeetsworld okay i see
Coy Sanders
@coymeetsworld
Nov 15 2016 03:03
@kherrjee ok i had that a little mixed
you leave the double quotes there, but remove the \
but for the double quotes that don't have a \
you replace it with a single quote
this challenge just shows you a more elegant way of adding quotes to a String
rissch
@rissch
Nov 15 2016 03:08
Hi, could someone help me? Problem is, that the "or" operator in the isLetter funtion isn't working. Thanks for any kind of response.
function palindrome(str) {
  // Good luck!
  var a = str.toLowerCase();
  function isLetter(value) {
    return value !== " " || "_";
  }

  a = a.split("");
  console.log("a = ", a);
  var b = a.filter(isLetter);
  console.log("b = ", b);
  var c = b.reverse();
  console.log("c = ",c);
  c = c.join("");
  b = b.reverse();
  b = b.join("");
  console.log("c = ",c);
  console.log("b = ", b);

  if(b===c) {
  return true;
  }
  else {return false;}
}



console.log(palindrome("_e y e"));
Kher Je
@kherrjee
Nov 15 2016 03:10
@coymeetsworld thanks, i got it
CamperBot
@camperbot
Nov 15 2016 03:10
kherrjee sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1536 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Nov 15 2016 03:10
nice work @kherrjee
Jenky W. Nolasco
@jenkynolasco11
Nov 15 2016 03:13
@rissch it will always return _ unless is a space
Oh wait...
rissch
@rissch
Nov 15 2016 03:15
nope man :ok_woman: :)
everything other works well, when you remove _ from string and from the function, it's working fine
Eric Murta
@murtinha
Nov 15 2016 03:18
guys, I cant figure how to use the markdown library on the Markdown Previewer challenge. I'm trying to understand how I should do it... thats what I have so far
http://codepen.io/murtinha/pen/xEvbdX
comaeternal
@comaeternal
Nov 15 2016 03:18
function mutation(arr) {
      var one = arr[0];
      var two = arr[1];
      if (one.indexOf(two, 0) !== -1)
      {
        return true;
      }
      else if (one.indexOf(two, 0) == -1)
      {
        return false;
      }
    }
   mutation(["hello", "hey"]);
Can someone check out my code. I'm just got all the false statements correct, but none are coming up as true
Ian
@toianw
Nov 15 2016 03:22
@rissch try this: return value !== " " && value !== "_";
rissch
@rissch
Nov 15 2016 03:28
@toianw Thank's !!! You're awesome :)
CamperBot
@camperbot
Nov 15 2016 03:28
rissch sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
rissch
@rissch
Nov 15 2016 03:29
@toianw Do you have an idea, how to make better code then writing this for characters "#", "*", "," etc.?
Anthony
@jawaka72
Nov 15 2016 03:29
var Bike = function() {

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


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

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

var myCar = new Car();

var myBike = new Bike();
Hey, can anyone tell me what's wrong with this code?
Alan Barr
@alanmbarr
Nov 15 2016 03:30
@comaeternal pattern is if (blah) else if (blah) else{ any other blah case} count what you have
Ian
@toianw
Nov 15 2016 03:30
@rissch You could use regex
rissch
@rissch
Nov 15 2016 03:30
@toianw because it would look something like this :
return value !== " " && value !=="_" && value !=="*" && value !=="," && value !=="#" ;
Alan Barr
@alanmbarr
Nov 15 2016 03:30
@jawaka72 you need to assign a value to the gear var not return it
rissch
@rissch
Nov 15 2016 03:31
@toianw Ah, ok, thank's i will google it :)
Alan Barr
@alanmbarr
Nov 15 2016 03:31
you should pass something in to do that
CamperBot
@camperbot
Nov 15 2016 03:31
:cookie: 422 | @toianw |http://www.freecodecamp.com/toianw
rissch sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
rissch
@rissch
Nov 15 2016 03:31
@toianw Thanks for help man (y)
CamperBot
@camperbot
Nov 15 2016 03:31
rissch sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
:warning: rissch already gave toianw points
Kher Je
@kherrjee
Nov 15 2016 03:32
hello can anyone teach me how to assign this to a variable in java script and have this as an output
FirstLine
\SecondLine\
ThirdLine
Ian
@toianw
Nov 15 2016 03:32
@rissch you're welcome!
Kher Je
@kherrjee
Nov 15 2016 03:32
using escape sequences in strings
Anthony
@jawaka72
Nov 15 2016 03:32
@alanmbarr I assigned it a value of 1, and removed the returns, but it's still incorrect.
Alan Barr
@alanmbarr
Nov 15 2016 03:33
a setter usually looks like this
setSpeed(500mph)
Johnny
@JohnnyBizzel
Nov 15 2016 03:33
@kherrjee Did the instructions not help?
Kher Je
@kherrjee
Nov 15 2016 03:34
@JohnnyBizzel it did, but i find it blurry
Alan Barr
@alanmbarr
Nov 15 2016 03:35
so how would you modify your code to change the internals of your gear shifter to deal with an input like that to change a gear or speed
Johnny
@JohnnyBizzel
Nov 15 2016 03:35

@kherrjee

\'    single quote
\"    double quote
\\    backslash
\n    newline
\r    carriage return
\t    tab
\b    backspace
\f    form feed

Does this help?

Kher Je
@kherrjee
Nov 15 2016 03:35
@JohnnyBizzel , okay i'll try
JackVizl
@JackVizl
Nov 15 2016 03:36

function sumAll(arr) {
newArr=[];

  for(var i=Math.min(arr);i<Math.max();i++){

   newArr=arr.reduce(function(a,b){
     return a+b;
   });
  }

return newArr;
}

sumAll([1, 4]);
confused as to how i use Math.min() and max properly here?
Johnny
@JohnnyBizzel
Nov 15 2016 03:37
@JackVizl Very clever. What is it supposed to do?
JackVizl
@JackVizl
Nov 15 2016 03:38
Thanks @JohnnyBizzel , its the sum all numbers ina range challenge
CamperBot
@camperbot
Nov 15 2016 03:38
jackvizl sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 813 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
JackVizl
@JackVizl
Nov 15 2016 03:38
you chuck in a range eg. (1 to 4)
and it sums them, like an arithmetic series d=1
Paulo Alexandre
@PauloFurtunatoAlexandre
Nov 15 2016 03:39
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  return myObj.hasOwnProperty(checkProp) ? myObj.checkProp: "Not Found";
}
// Test your code by modifying these values
checkObj("house");`
Kher Je
@kherrjee
Nov 15 2016 03:39
@JohnnyBizzel i solved it thanks
CamperBot
@camperbot
Nov 15 2016 03:39
kherrjee sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
Johnny
@JohnnyBizzel
Nov 15 2016 03:39
@JackVizl Why don't you build an array of the numbers in the range first, then reduce that.
@kherrjee :smile: Good one!
JackVizl
@JackVizl
Nov 15 2016 03:40
good idea, thankyou @JohnnyBizzel
CamperBot
@camperbot
Nov 15 2016 03:40
jackvizl sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:warning: jackvizl already gave johnnybizzel points
Johnny
@JohnnyBizzel
Nov 15 2016 03:41
@JackVizl Good luck. I am off to bed :zzz:
JackVizl
@JackVizl
Nov 15 2016 03:41
except, my Math.min(0) and Math.max() are still always null
Anthony
@jawaka72
Nov 15 2016 03:42
@alanmbarr I'm sorry, but I don't understand. I have to make a private property called gear and two public methods called getGear and setGear and set that value. . I don't understand how I'm supposed to set the value.
Alan Barr
@alanmbarr
Nov 15 2016 03:43
@jawaka72 you need to use an argument in a function you can either leave the args empty setGear() or you can pass in the value setGear(2)
JackVizl
@JackVizl
Nov 15 2016 03:43
@jawaka72 setGear just has gear=whatever you pass to it
Paulo Alexandre
@PauloFurtunatoAlexandre
Nov 15 2016 03:43
Pls can anyone help me understand what am I doing wrong?
Alan Barr
@alanmbarr
Nov 15 2016 03:44
you want to pass in a value so you can do something with it
sabaimtiaz
@sabaimtiaz
Nov 15 2016 03:44
Hi - I'm stuck at the challenge where you have to pass par and strokes arguments for a golf game, and half my code won't work. If Strokes is par+2 and it has to return "Double Bogey", how can I write an else if argument?
Ian
@toianw
Nov 15 2016 03:45
@JackVizl You can use Math.max.apply(null, arr); or Math.max(arr[0], arr[1]);
Jaehoon
@puhaha-jung
Nov 15 2016 03:45
@PauloFurtunatoAlexandre myObj[checkProp]
JackVizl
@JackVizl
Nov 15 2016 03:46
thanks @toianw
CamperBot
@camperbot
Nov 15 2016 03:46
jackvizl sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
:cookie: 423 | @toianw |http://www.freecodecamp.com/toianw
Paulo Alexandre
@PauloFurtunatoAlexandre
Nov 15 2016 03:46
oh... okay... let me try that
Jaehoon
@puhaha-jung
Nov 15 2016 03:48
@PauloFurtunatoAlexandre I wish it is correct. Have a good day!!
Paulo Alexandre
@PauloFurtunatoAlexandre
Nov 15 2016 03:49
thx!
yozhikvtumane
@yozhikvtumane
Nov 15 2016 03:49
Hello guys! I am stuck at this Record Collection exercise where you should update albums, song etc. Here is my code http://pastebin.com/gGQvHSNL and I can't only pass this "updateRecords(2548, "tracks", "")" even console in Chrome says it's empty array
updateRecords(2548, "tracks", "")
emamadordev
@emamadordev
Nov 15 2016 03:54
Every time i paste in and run this code on chrome, Firefox, and my android phone the browser just freezes. But if i run it in the chrome console or on jsfiddle it works fine. tell me..do you see anything wrong with it?
it's supposed to give you Fibonacci numbers
function sumFibs(num) {
var arr=[1,1];
var newNum='';
for(var i=0;i<num;i++){
newNum=arr[i]+arr[i+1];
arr.push(newNum);
}
return arr;
}
sumFibs(10);
Aaron
@apalm1341
Nov 15 2016 03:55
if there is anyone out there that is good with tiled map editor and quintus, plz plz pz send me private message
would be greatly appreciated
yozhikvtumane
@yozhikvtumane
Nov 15 2016 03:57
@emamador Try this
function sumFibs(num) { var numV = num; var arr=[1,1]; var newNum=''; for(var i=0;i<numV;i++){ newNum=arr[i]+arr[i+1]; arr.push(newNum); } return arr; } sumFibs(10);
function sumFibs(num) {
var numV = num;
var arr=[1,1];
var newNum='';
for(var i=0;i<numV;i++){
newNum=arr[i]+arr[i+1];
arr.push(newNum);
}
return arr;
}
sumFibs(10);
Anower Jahan
@Shofol
Nov 15 2016 04:01

Why this is returning undefined value? TIA

function rot13(str) { // LBH QVQ VG!
var b,c;
a=str.split('');
for(i=0;i<a.length;i++){ b=a[i].charCodeAt(0); if(b>=65 && b<=90){
if(b<78){
b=b+13;}
else {
b=b-13;
}
c.push(String.fromCharCode(b));
}
}
//d=c.join('');
return ;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

c.push(String.fromCharCode(b)); -this line
Alan Barr
@alanmbarr
Nov 15 2016 04:02
@Shofol look at your return statement
emamadordev
@emamadordev
Nov 15 2016 04:03
@yozhikvtumane tried it. it does the same thing. have you tried this code on freecodecamp? it literally craches the browser for some reason.
Anower Jahan
@Shofol
Nov 15 2016 04:03
Alan if I return a var then it is showing the character. But Push or array accessing is not working.
@alanmbarr c.push(String.fromCharCode(b))
Alan Barr
@alanmbarr
Nov 15 2016 04:04
@emamador your android browser might have much less memory than the desktop browser
JackVizl
@JackVizl
Nov 15 2016 04:04

function sumAll(arr) {
newArr=[];



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

    newArr.push(i);

  }

return newArr.reduce(function(a,b){
  return a+b;

});
}

sumAll([1, 4]);
what i do wrong
emamadordev
@emamadordev
Nov 15 2016 04:04
@alanmbarr no i tried it on my desktop computer.
Alan Barr
@alanmbarr
Nov 15 2016 04:05
What browser are you using on desktop?
emamadordev
@emamadordev
Nov 15 2016 04:05
@alanmbarr Chrome.
@alanmbarr let me try firefox
@alanmbarr same on firefox. I also tried it on my phone and it does the same thing. lol
Anower Jahan
@Shofol
Nov 15 2016 04:08
@JackVizl You need to mention initial value in the reduce function
Alan Barr
@alanmbarr
Nov 15 2016 04:08
@Shofol i get an error that c does not have a push method
emamadordev
@emamadordev
Nov 15 2016 04:08
@alanmbarr i think i'm cursed.
Alan Barr
@alanmbarr
Nov 15 2016 04:09
lol
JackVizl
@JackVizl
Nov 15 2016 04:09
@Shofol confused what you mean
Anower Jahan
@Shofol
Nov 15 2016 04:10
return newArr.reduce(function(a, b) {
return a + b;
}, 0);
emamadordev
@emamadordev
Nov 15 2016 04:10
@alanmbarr all i want to know is what happens on your end when you run the code on FCC.
Alan Barr
@alanmbarr
Nov 15 2016 04:10
@emamador i googled your issue and it seems like its pretty common some people's solution is crashing
JackVizl
@JackVizl
Nov 15 2016 04:11

function sumAll(arr) {
newArr=[];



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

    newArr.push(i);

  }

return newArr.reduce(function(a, b) {
return a + b;
}, 0);

}

sumAll([1, 4]);
Still aint working
emamadordev
@emamadordev
Nov 15 2016 04:11
@alanmbarr oh. ahh DUH i should've googled.
Anower Jahan
@Shofol
Nov 15 2016 04:13
@alanmbarr what does that mean!
\
Alan Barr
@alanmbarr
Nov 15 2016 04:14
@Shofol .push is a method on an array, is c an array?
Anower Jahan
@Shofol
Nov 15 2016 04:15
@alanmbarr oh sorry. silly mistake. ;) thanks
CamperBot
@camperbot
Nov 15 2016 04:15
shofol sends brownie points to @alanmbarr :sparkles: :thumbsup: :sparkles:
:cookie: 313 | @alanmbarr |http://www.freecodecamp.com/alanmbarr
emamadordev
@emamadordev
Nov 15 2016 04:16
@apalm1341 thanks for mentioning quintus. never heard of it.
CamperBot
@camperbot
Nov 15 2016 04:16
emamador sends brownie points to @apalm1341 :sparkles: :thumbsup: :sparkles:
:cookie: 216 | @apalm1341 |http://www.freecodecamp.com/apalm1341
Aaron Bell
@awb715
Nov 15 2016 04:16
using jquery can get annoying
so many things to manipulate
duyduc1110
@duyduc1110
Nov 15 2016 04:17
hi
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

  this.getSpeed = function() {
    return speed;
  };
};
emamadordev
@emamadordev
Nov 15 2016 04:17
@alanmbarr thanks for helping :)
CamperBot
@camperbot
Nov 15 2016 04:17
:cookie: 314 | @alanmbarr |http://www.freecodecamp.com/alanmbarr
emamador sends brownie points to @alanmbarr :sparkles: :thumbsup: :sparkles:
duyduc1110
@duyduc1110
Nov 15 2016 04:17
i dont know how this.accelearte, develerate and getSpeed work
can anybody explain
Alan Barr
@alanmbarr
Nov 15 2016 04:20
@duyduc1110 generally you want an object you talk to through some functions and have it manage its internals. so you Car.accelerate(number) so you can change the speed or you can get the speed by calling Car.getSpeed()
beneficial if you are building a game with vehicles and you want to control how fast they move
Anower Jahan
@Shofol
Nov 15 2016 04:20
@JackVizl for(var i=Math.min(arr[0], arr1);i<=Math.max(arr[0], arr1);i++) it was wong
*wrong
check it
Aaron Bell
@awb715
Nov 15 2016 04:22
does anyone have experience making a responsive bootscrap grid while querying and for loopinb
i built a responsive grid
but i have to emulate it in jquery
duyduc1110
@duyduc1110
Nov 15 2016 04:23
@alanmbarr thank you so much
CamperBot
@camperbot
Nov 15 2016 04:23
duyduc1110 sends brownie points to @alanmbarr :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @alanmbarr |http://www.freecodecamp.com/alanmbarr
Alan Barr
@alanmbarr
Nov 15 2016 04:25
@awb715 how do you mean emulate?
Aaron Bell
@awb715
Nov 15 2016 04:25
i have to use jquery to recreate a bootstrap grid
@alanmbarr
Alan Barr
@alanmbarr
Nov 15 2016 04:26
you need jquery to make divs or a table for you dynamically?
Aaron Bell
@awb715
Nov 15 2016 04:26
yes
this is a grid i just made
Alan Barr
@alanmbarr
Nov 15 2016 04:27
@awb715 what data do you need to loop over to display?
Aaron Bell
@awb715
Nov 15 2016 04:27
i havent linked the api yet
its the twitch
Alan Barr
@alanmbarr
Nov 15 2016 04:28
where do you want to start with?
Aaron Bell
@awb715
Nov 15 2016 04:28
well i need to make the top part also
like a title and stuff
paintingfire
@paintingfire
Nov 15 2016 04:40

Hi, I am doing the Farenheit to Celcius challenge and I keep getting "celcius is not defined". I thought it was defined in the first line of code, though- function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = celcius * (9/5) + 32;

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

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

Merryl
@MerrylArok
Nov 15 2016 04:41
ya spelt it wrong
paintingfire
@paintingfire
Nov 15 2016 04:41
*headdesk
Andrew
@asmorris
Nov 15 2016 04:42
Hi everyone, I'm working on the steamroller algorithm right now and I'm getting all the right responses from my function, but it's not accepting my code. Can anyone figure out why? Code is: var newArr = [];
function steamrollArray(arr) {
// I'm a steamroller, baby
for (var i=0;i<arr.length;i++) {
if (Array.isArray(arr[i])) {
steamrollArray(arr[i]);
} else {
newArr.push(arr[i]);
}
}
return newArr;
}
paintingfire
@paintingfire
Nov 15 2016 04:43
@MerrylArok Thanks for the help. I think it's time to go to bed.
CamperBot
@camperbot
Nov 15 2016 04:43
:cookie: 250 | @merrylarok |http://www.freecodecamp.com/merrylarok
paintingfire sends brownie points to @merrylarok :sparkles: :thumbsup: :sparkles:
Merryl
@MerrylArok
Nov 15 2016 04:47
@paintingfire sleep tite
Tonye Dixon
@tonye-d
Nov 15 2016 04:50

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

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

```

Alan Barr
@alanmbarr
Nov 15 2016 04:51
Tonye where are you multiplying?
Tonye Dixon
@tonye-d
Nov 15 2016 04:52
@alanmbarr each number in the sub-array
```

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Merryl
@MerrylArok
Nov 15 2016 04:54
@tonye-d you should be multiplying product with the number
@tonye-d product*=arr[i][j][k]
duyduc1110
@duyduc1110
Nov 15 2016 04:55
js array.filter(function(currentValue,index,arr), thisValue)
js array.filter(function(currentValue,index,arr), thisValue)
what is index and arr actual mean?
when will we need it?
Alan Barr
@alanmbarr
Nov 15 2016 04:56
[1,2,3].filter(function(curr,index,array){return if true});
arr is the original array [1,2,3] in my example
index is the iteration number, 0,1,2
you don't always need those
duyduc1110
@duyduc1110
Nov 15 2016 04:58
I just want to understand it clearly
Alan Barr
@alanmbarr
Nov 15 2016 04:58
sure, in the filter function you return a new array that only has elements that match your logic
Micah Lewis
@EastML
Nov 15 2016 04:59
Doing the where for art thou challenge in intermediate js algorithms and stuck here. Any pointers on my code?
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line


  var sourceKeys = Object.keys(source);

  for (var i = 0; i < collection.length; i++) {
    for (var j = 0; j < sourceKeys.length; j++) {
      if (collection[i].hasOwnProperty(sourceKeys[j])) {
        if (source[sourceKeys[j]] != collection[i][sourceKeys[j]]) {

        }
        arr.push(collection[i]);
      }
    }
  }

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

whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
Alan Barr
@alanmbarr
Nov 15 2016 04:59
if you say you want only the elements that are not the first index you would say
[1,2,3].filter(function(curr,index,array){return index > 0});
and get back [2,3]
duyduc1110
@duyduc1110
Nov 15 2016 05:01
thank you (y)
Adolfo Saenz
@AdoSae1
Nov 15 2016 05:05
guys i've been staring at "record collection" for like an hour any tips?
heroiczero
@heroiczero
Nov 15 2016 05:06
@AdoSae1 There are four steps. list the steps and make a if else statement
@AdoSae1 use Object.hasOwnProperty(prop) to check if the object has a property like tracks
Adolfo Saenz
@AdoSae1
Nov 15 2016 05:07
ok thanks @heroiczero
CamperBot
@camperbot
Nov 15 2016 05:07
adosae1 sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:cookie: 389 | @heroiczero |http://www.freecodecamp.com/heroiczero
Merryl
@MerrylArok
Nov 15 2016 05:09
@AdoSae1 oh man i kinda struggled with it, but it helped me to understand how to access objects vs arrays. Be sure you are accessing them right, objects are not indexed like arrays!
Adolfo Saenz
@AdoSae1
Nov 15 2016 05:10
@MerrylArok thanks for the tip, much appreciated!
CamperBot
@camperbot
Nov 15 2016 05:10
adosae1 sends brownie points to @merrylarok :sparkles: :thumbsup: :sparkles:
:cookie: 252 | @merrylarok |http://www.freecodecamp.com/merrylarok
John Need
@johnneed
Nov 15 2016 05:12
@alanmbarr use slice : [1,2, 3].slice(1) // [2,3]
JackVizl
@JackVizl
Nov 15 2016 05:15
Thankyou @Shofol
CamperBot
@camperbot
Nov 15 2016 05:15
jackvizl sends brownie points to @shofol :sparkles: :thumbsup: :sparkles:
:cookie: 260 | @shofol |http://www.freecodecamp.com/shofol
John Need
@johnneed
Nov 15 2016 05:15
@joehesse You have extra spaces and you need a capital "i"
var myStr = "I am a \"double quoted\" string inside \"double quotes\".";
Adolfo Saenz
@AdoSae1
Nov 15 2016 05:22

ayaancoder
@ayaancoder
Nov 15 2016 05:22
var myStr = "\"\FirstLine\n\SecondLine\rThirdLine\"";
Adolfo Saenz
@AdoSae1
Nov 15 2016 05:22
function updateRecords(id, prop, value) {
  if (collection.hasOwnProperties(prop)) {
    return tracks[prop];
  }


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


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "tracks", 'Take a chance on Me');
so so wrong
ayaancoder
@ayaancoder
Nov 15 2016 05:24
Hi every one this geving me error
var myStr = "\"FirstLine\n\SecondLine\\rThirdLine\"";
Muneera Alhammadi
@Muneeraalhammadi
Nov 15 2016 05:24
Convert Celsius to Fahrenheit

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenhiet = convertToF(celsius)* 9/5 + 32 ;
// Only change code above this line
return fahrenheit;
}

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

it give me eroor
error**
I need some help
ayaancoder
@ayaancoder
Nov 15 2016 05:24
var myStr = "\"FirstLine\n\\SecondLine\\rThirdLine\"";
still getting error though i wrote every thing \n taking space
how should i get rid off the space
AKASH GUNJAL
@AKASH888
Nov 15 2016 05:29
copy your link let me see @Muneeraalhammadi
Sarahjsts
@Sarahjsts
Nov 15 2016 05:29
@Muneeraalhammadi instead of fahrenhiet = convertToF(celsius) 9/5 + 32 try fahrenhiet = celsius 9/5 + 32
*err just get rid of the convertToF part and just use celsius
__mifflin__
@cdrainxv
Nov 15 2016 05:30
@ayaancoder: Remove the fist and last \… and should only have one set of quotes… ""
In total you should have exactly 6 \
ayaancoder
@ayaancoder
Nov 15 2016 05:31
ok
its not working i removed first n last ..
.....
slash
Ghulam Shabir
@ghulamshabir
Nov 15 2016 05:34
@AdoSae1 make your last else part an else if and test for existence of prop
Adolfo Saenz
@AdoSae1
Nov 15 2016 05:36
function updateRecords(id, prop, value) {
  if (collection.hasOwnProperties(prop)) {
    return tracks[prop];
  }


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


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "tracks", 'Take a chance on Me');
?
like this
ayaancoder
@ayaancoder
Nov 15 2016 05:36
what i was actually doing is writing double quotes four times so i have to remove two double quotes and it works.
Ghulam Shabir
@ghulamshabir
Nov 15 2016 05:37
@AdoSae1 yes but if needs a condition if(condition) {
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:37

@AdoSae1

else if{
    collection[id][prop].push(value);
  }

what condition is this checking?

Ghulam Shabir
@ghulamshabir
Nov 15 2016 05:38
@AdoSae1 you need to test for existence of prop in the collection[id]
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:38
@ghulamshabir hey man!
Ghulam Shabir
@ghulamshabir
Nov 15 2016 05:39
@Lumexralph hey bro :smile:
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:39
it's morning over here....good morning @ghulamshabir
Ghulam Shabir
@ghulamshabir
Nov 15 2016 05:40
@Lumexralph good morning, yes in here too, its 10:40 AM
Adolfo Saenz
@AdoSae1
Nov 15 2016 05:41
@Lumexralph ok i reset my code, i want to start from the beginning
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:41
@ghulamshabir 6:40 am here.....
Ghulam Shabir
@ghulamshabir
Nov 15 2016 05:41
@AdoSae1 no you are almost done don't reset
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:41
@AdoSae1 okay
@AdoSae1 i don't think you did badly, just need to complete it but if you want to start again, good
sharkantropo
@sharkantropo
Nov 15 2016 05:42
Hey guys. I can't see why I'm unable to pass the binary agent challenge with this code:
function binaryAgent(str) 
{
  var codeASCII=[],bincode,sum,power, reduce,stringAscii=[],curCode;
  str=str.split(" ");
  for(var i=0; i<str.length; i++)
    {
        bincode=str[i];
        sum=0;
      for(var j=0; j <bincode.length ;j++)
        {
             reduce=7-j;
             if(bincode[reduce] === "1")
             {
               power=Math.pow(2,j);
               sum=sum+power;        
             }
        }
       codeASCII.push(sum);
    }



  for( i=0; i<codeASCII.length;i++)
     { 
        curCode=String.fromCharCode(codeASCII[i]);
        stringAscii.push(curCode);
     }

  stringAscii=stringAscii.join(" ");
  str=stringAscii;
 return str;
}
Ghulam Shabir
@ghulamshabir
Nov 15 2016 05:42
@Lumexralph you wake up so early ?
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:43
@ghulamshabir am used to it, have to prepare for work
Adolfo Saenz
@AdoSae1
Nov 15 2016 05:43
woah i reset and it erased all the code it provided me in the first place
??
Ghulam Shabir
@ghulamshabir
Nov 15 2016 05:43
@Lumexralph :+1:
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:44
@ghulamshabir and my work does not have anything to do with programming, so it can be challenging most times
doing the two
sharkantropo
@sharkantropo
Nov 15 2016 05:44
(2) It returns just the required translated string, but for some reason is not accepted as correct.
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:45
@AdoSae1 okay, let's start
Kher Je
@kherrjee
Nov 15 2016 05:45
what countries are online now?
Ghulam Shabir
@ghulamshabir
Nov 15 2016 05:45
@Lumexralph yes me too, I am a teacher, but today is a holiday here
Adolfo Saenz
@AdoSae1
Nov 15 2016 05:45
please

// 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) {


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
it just reset to that
Ryan Copeland
@ryan6627
Nov 15 2016 05:46
you know github has the solution to that?
nvm I'll show you the guy that explained it
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:46
@ghulamshabir lucky you
Ghulam Shabir
@ghulamshabir
Nov 15 2016 05:47
@Lumexralph :smile: yeah enjoying laziness lol
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:47
@ghulamshabir :smile:
Adolfo Saenz
@AdoSae1
Nov 15 2016 05:48
@ryan6627 thanks man im gonna check that out, hopefully he will explain it in a way that sticks
CamperBot
@camperbot
Nov 15 2016 05:48
adosae1 sends brownie points to @ryan6627 :sparkles: :thumbsup: :sparkles:
:cookie: 102 | @ryan6627 |http://www.freecodecamp.com/ryan6627
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:48
@AdoSae1 what are you to look for ? and you can also check what @ryan6627 posted the video, it can give you some understanding
Adolfo Saenz
@AdoSae1
Nov 15 2016 05:49
@Lumexralph yea im gonna do that... but tommorow its really late here i gotta sleep :smile:
thank you anyways
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:49
@AdoSae1 why don't you try for the last time? so you don't carry it over?
Ryan Copeland
@ryan6627
Nov 15 2016 05:52
can somebody put into words what this solution to Nesting For Loops is saying?
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr[i].length; j++) {
console.log(arr[i][j]);
product *= arr[i][j];
}
}
// Only change code above this line
return product;
}
I understand the first line, but I don't fully understand why the first line evaluates true ONCE and moves on, but the second line does its code MULTIPLE times per every first line that evaluates true
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:54
@ryan6627 where's product?
Ryan Copeland
@ryan6627
Nov 15 2016 05:54
@Lumexralph function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr[i].length; j++) {
console.log(arr[i][j]);
product *= arr[i][j];
}
}
// Only change code above this line
return product;
}
var arr = [
[1,2], [3,4], [5,6]
];
Terryd12345
@Terryd12345
Nov 15 2016 05:55
hey guys in seek & destroy how come indexing arr1 returns a value from in the list rather than the first index of the input?
Ryan Copeland
@ryan6627
Nov 15 2016 05:55
I can see what the code is doing, but I'm not at all understanding the why it's doing what it is
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:55
@ryan6627 it's because the inner loop will finish executing per element before moving to the next iteration of the outer loop
Markus Kiili
@Masd925
Nov 15 2016 05:56
@ryan6627 The code block of i loop is run once for each arr element (each index i). That block contains the inner loop that loops subarray elements.
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:57
@ryan6627 when i = 0, j loop will keep running till it's conditions are satisfied, it then exits and moves to the next iteration of the outer loop, it continues that till it's done
Ghulam Shabir
@ghulamshabir
Nov 15 2016 05:58
@Terryd12345 you want to access 2, 3 from destroyer([ ... ], 2, 3 ) ??
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:58
@ryan6627 that's why you have multiple actions in the inner loop compared to the outer loop
Terryd12345
@Terryd12345
Nov 15 2016 05:58
@ghulamshabir Yes, how am i able to access them?
Markus Kiili
@Masd925
Nov 15 2016 05:58
@Lumexralph @ghulamshabir Good morning.
Ogundele Olumide
@Lumexralph
Nov 15 2016 05:59
@Masd925 good morning :smile:
slept good @Masd925 ?
Ghulam Shabir
@ghulamshabir
Nov 15 2016 05:59
@Terryd12345 you can see 2, 3 are out of array brackets they are not in the arr
@Masd925 Morning bro :smile:
Terryd12345
@Terryd12345
Nov 15 2016 06:00
@ghulamshabir so when you call destroyer, if the inputs are not defined in the function how does the function refer to them? If you get what I mean.
Markus Kiili
@Masd925
Nov 15 2016 06:01
@Lumexralph When I started to code for work, I have had no problems sleeping ;) Teaching teenagers was another story.
Ryan Copeland
@ryan6627
Nov 15 2016 06:01
@Lumexralph @Masd925 OK, so the outer loop will run 2 times because the arr array has a length of two (counting from 0) correct? The for each time outer loop runs, it'll perform the inner loop completely, which says that it will log and multiply product as long as j is less than wherever the array arr iterated by i left off?
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:02
@Terryd12345 yes, you need to use arguments object, every function has its own instance of arguments object, its array like object and stores all the argumuents
Ogundele Olumide
@Lumexralph
Nov 15 2016 06:02
@Masd925 lol ... :smile:
Markus Kiili
@Masd925
Nov 15 2016 06:02
@ryan6627 Yes, the inner loop runs completely for each arr element (subarray).
Ogundele Olumide
@Lumexralph
Nov 15 2016 06:02
but you're passing it on and it's good, keep it up :+1: @Masd925
@ryan6627 exactly, that's what is going on
Ryan Copeland
@ryan6627
Nov 15 2016 06:04
@Masd925 I still don't really understand what that second line (for (var j = 0; j < arr[i].length; j++)) translates to. is it saying for as long j begins at zero and j is less than wherever the array iterated by i left off, it will run the code below? it's that condition/middle part that I'm not sure if I'm understanding correctly
Ogundele Olumide
@Lumexralph
Nov 15 2016 06:04
@Masd925 before I jump into conclusion, do you teach the teenagers coding or something else?
Markus Kiili
@Masd925
Nov 15 2016 06:05
@Lumexralph I did some teaching but switched into software development.
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:05
@ryan6627 arr[i] returns sub-array you are iterating over sub-array through its length arr[i].length
@ryan6627 as a bonus the inner loop can get you all the values from sub-arrays even they are different lengths
Terryd12345
@Terryd12345
Nov 15 2016 06:07
@ghulamshabir ah i see, thanks !
CamperBot
@camperbot
Nov 15 2016 06:07
terryd12345 sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1033 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
AKASH GUNJAL
@AKASH888
Nov 15 2016 06:07
the code translates to as long as the var j is less than array-length of i iterate the loop @ryan6627
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:07
@Terryd12345 :+1:
Ogundele Olumide
@Lumexralph
Nov 15 2016 06:07
@ryan6627 when i = 0 for outer loop, it moves to inner loop, inner loop on index 0 of outer loop, will keep running until j < arr[i] which is 0 i.e arr[0].length is satisfied, then it moves to index 1 of outer loop and does same for that iteration
@Masd925 cool, i hope i have the chance to switch soon to fasten my development
Markus Kiili
@Masd925
Nov 15 2016 06:09
@Lumexralph What are you doing at the moment?
Ogundele Olumide
@Lumexralph
Nov 15 2016 06:10
@Masd925 am an Inventory Manager
Markus Kiili
@Masd925
Nov 15 2016 06:11
@Lumexralph ok.
Ogundele Olumide
@Lumexralph
Nov 15 2016 06:11
but would sure love to quit if I get an opportunity in that direction
Ryan Copeland
@ryan6627
Nov 15 2016 06:11
@Masd925 @ghulamshabir @Lumexralph thanks guys!
CamperBot
@camperbot
Nov 15 2016 06:11
ryan6627 sends brownie points to @masd925 and @ghulamshabir and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1034 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
:cookie: 445 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 2911 | @masd925 |http://www.freecodecamp.com/masd925
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:11
@ryan6627 :+1:
Ogundele Olumide
@Lumexralph
Nov 15 2016 06:11
@ryan6627 glad we could help
MM Nauman
@mmnauman
Nov 15 2016 06:14
Hello Need Help in this Challenge https://www.freecodecamp.com/challenges/counting-cards
harrislu
@harrislu
Nov 15 2016 06:17
hi, I am harris. I just know this freecodecamp from a news
upendra
@ardnepu
Nov 15 2016 06:18
hello ....can someone tell me what shall i choose betwn react and angular?
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:19
@harrislu welcome, try to solve FCC challenges when you need help regarding javascript just post your problem here, we all are here for help
@ardnepu you can not choose one over the other as long as I think
Vidhi patel
@VidhiPatel5151
Nov 15 2016 06:20
any one knw about C# Dictionary in how to used varible value
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:20
@ardnepu they both have their own uses
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:21
@ardnepu but I will recommend learn React first
eyeseau
@eyea
Nov 15 2016 06:21
Is there someone help me here?
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:21
@ardnepu when you think you need to learn Angular then you can learn that too
@eyeA copy paste your code here
upendra
@ardnepu
Nov 15 2016 06:22
@ghulamshabir what about react native ...?
do i need to learn react first to learn react native?
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:23
@ardnepu sorry not into that yet
eyeseau
@eyea
Nov 15 2016 06:23
function palindrome(str) {
// Good luck!
var after = "";
var before = str;
after = str.toLowerCase().replace(/^\s\t/gi,"").join("").reverse();
if(before == after){
return true;
}
}
palindrome("eye");
@ghulamshabir
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:25
@eyeA join is method of arrays, you can not call it on strings
@eyeA you can call split on string first to covert it into array first
eyeseau
@eyea
Nov 15 2016 06:27
@ghulamshabir I can't write correct regular expression
after = str.toLowerCase().replace(/^\s\t/gi,"").split("").join("").reverse();
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:28
@eyeA you need this /[\W_]/g
eyeseau
@eyea
Nov 15 2016 06:29
I have a try
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:30
@eyeA you might want to call reverse before join ?
eyeseau
@eyea
Nov 15 2016 06:31
no , the question is like this:

You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes.

We'll pass strings with varying formats, such as "racecar", "RaceCar", and "race CAR" among others.

We'll also pass strings with special symbols, such as "2A33a2", "2A3 3a2", and "2_A33#A2".

Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:31
@eyeA because reverse works on arrays and you are converting array to string before reverse, that generate an error
eyeseau
@eyea
Nov 15 2016 06:32
oh my God...
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:32
just change the order of reverse and join
ruzmeh
@ruzmeh
Nov 15 2016 06:33
Can anyone help me with js celsius to fahrenheit challenge
eyeseau
@eyea
Nov 15 2016 06:33
I have changed the order of reverse and join @ghulamshabir
but still false
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:33
@ruzmeh you need celsius to fahrenheit conversion formula
ruzmeh
@ruzmeh
Nov 15 2016 06:34
https://www.freecodecamp.com/challenges/convert-celsius-to-fahrenheit#?solution= function convertToF(celsius) { var fahrenheit%3B %2F%2F Only change code below this line %2F%2F Only change code above this line return fahrenheit%3B } %2F%2F Change the inputs below to test your code convertToF(30) %3D 86%3B convertToF(-30)%3D -22%3B convertToF(0)%3D32%3B convertToF(20)%3D68%3B convertToF(-10)%3D -14%3B
eyeseau
@eyea
Nov 15 2016 06:34
function palindrome(str) {
// Good luck!
var after = "";
var before = str;
after = str.toLowerCase().replace("/[\W_]/g","").split("").reverse().join("");
if(before == after){
return true;
}
}
palindrome("eye");
ruzmeh
@ruzmeh
Nov 15 2016 06:34
Ghulam can you check the link plz
eyeseau
@eyea
Nov 15 2016 06:35
maybe regular expression is wrong
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:35
@eyeA copy paste your code here
eyeseau
@eyea
Nov 15 2016 06:35
@ghulamshabir
function palindrome(str) {
// Good luck!
var after = "";
var before = str;
after = str.toLowerCase().replace("/[\W_]/g","").split("").reverse().join("");
if(before == after){
return true;
}
}
palindrome("eye");
ruzmeh
@ruzmeh
Nov 15 2016 06:36

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

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

// Change the inputs below to test your code
convertToF(30) = 86;
convertToF(-30)= -22;
convertToF(0)=32;
convertToF(20)=68;
convertToF(-10)= -14;

Help
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:37
@eyeA you need to apply replace on before and reverse.join on after
@ruzmeh fahrenheit is celsius times 9/5 plus 32
ruzmeh
@ruzmeh
Nov 15 2016 06:39
Where do I write that
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:40
@ruzmeh between the two comments //only change code above/below this line
ruzmeh
@ruzmeh
Nov 15 2016 06:42
Ghulam couldn't get the result
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:42
@ruzmeh show me the code
ruzmeh
@ruzmeh
Nov 15 2016 06:43

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

celsius=9/5+32;
// Only change code above this line
return fahrenheit;
}

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

Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:43
@ruzmeh you need to multiply celsius with the formula
ruzmeh
@ruzmeh
Nov 15 2016 06:44
I fixed it. Thanx anyways ghulam
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:45
@ruzmeh mention @name for thankings
ruzmeh
@ruzmeh
Nov 15 2016 06:45
Instead of celsius I had to use fahrenheit
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:46
@ruzmeh yes , you needed to assign the result to fahrenheit but multiply the formula with celsius
@ruzmeh if you learn code formatting you will get great help here, see more info link below for that '''
CamperBot
@camperbot
Nov 15 2016 06:47
:bulb: to format code use backticks! ``` more info
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:48
@ruzmeh and also you should give brownie points to who help you by mentioning their @name and saying thanks
CamperBot
@camperbot
Nov 15 2016 06:48
ghulamshabir sends brownie points to @ruzmeh and @name :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for name
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:49
you can click on @name it will be copied to the chat text field
eyeseau
@eyea
Nov 15 2016 06:50
@ghulamshabir my code:

function palindrome(str) {
// Good luck!
var after = "";
var before = str;

after = before.toLowerCase().replace(/[\W_]/g,"").split("").reverse().join("");
if(before == after){
return true;
}else{
return false;
}
}
palindrome("eye");

can't work correctly...
Mateusz Kadlubowski
@xeho91
Nov 15 2016 06:52
@eyeA Can you please put code in more readable formatting? https://github.com/freecodecamp/freecodecamp/wiki/code-formatting
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:53
@eyeA you have all the weapons of solving the challenge but you mixing things up
Mateusz Kadlubowski
@xeho91
Nov 15 2016 06:54
From what I found in your code, I found one mistake in replace(/[\W_]/g,"").
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:54
@eyeA what you have to do you keep one copy of string which has non alpha numeric characters and another copy which is reversed version of previous copy
Mateusz Kadlubowski
@xeho91
Nov 15 2016 06:55
@ghulamshabir Nevermind, I copied code wrongly
Philipp Scholz
@philipp32
Nov 15 2016 06:55
function titleCase(str) {
  str = str.toLowerCase();
  var array = str.split(" ");
 var newString = [];  
  for (i=0; i<array.length; i++)
    newString = array[i][0].toUpperCase;
newString= array.join(" ");
  return newString;
}   

titleCase("I'm a little tea pot");
This doesn't work. It only gives out the string in all lower case letters. What needs to be changed so that array[i][0].toUpperCase() can work?
eyeseau
@eyea
Nov 15 2016 06:57
sorry
kirbyedy
@kirbyedy
Nov 15 2016 06:58
@philipp32 I dont see where you join that array later on
Mateusz Kadlubowski
@xeho91
Nov 15 2016 06:58
@philipp32 toUpperCase() you're missing brackets at the end
Ghulam Shabir
@ghulamshabir
Nov 15 2016 06:58
@philipp32 you need to reset every word in the array not the array itself in the loop and you also need to take care of remaining letters of words besides first letter capitalized
@philipp32 toUpperCase is method it needs () to be called
Mateusz Kadlubowski
@xeho91
Nov 15 2016 07:00
@philipp32 Hint: I used charAt() and 'slice()` to complete this lesson. This wasn't included in instructions indeed, but researching documentation of JavaScript at MozillaDev did the job
@philipp32 slice() *
Philipp Scholz
@philipp32
Nov 15 2016 07:00
@xeho91 thank you all @ghulamshabir @kirbyedy
CamperBot
@camperbot
Nov 15 2016 07:00
philipp32 sends brownie points to @xeho91 and @ghulamshabir and @kirbyedy :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @xeho91 |http://www.freecodecamp.com/xeho91
:star2: 1530 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
:star2: 1035 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Philipp Scholz
@philipp32
Nov 15 2016 07:00
I will let yout know how i goes.
Eric K
@EricK425
Nov 15 2016 07:10
does someone mind helping me with Title Case in a Sentence challenge?? im so close.. I just cant seem to put my sentence back together at the end after I have changed all the cases

function titleCase(str) {
  var strArr = str.split(' '); 
  var strArr1;
  console.log(strArr);
  for (i = 0; i < strArr.length; i++) {
    strArr1 = strArr[i].split('');
    //console.log(strArr1);
    for (j = 0; j < strArr1.length; j++) {

        if (strArr1[j] == strArr1[j].toUpperCase() && strArr1[j]                   != strArr1[0].toUpperCase()) {
          strArr1[j] = strArr1[j].toLowerCase();
          str = strArr1.join('');
          //str = [str];


        } 
        else if (strArr1[j] != strArr1[j].toUpperCase() && strArr1[j]               ==         strArr1[0]) {
          strArr1[j] = strArr1[j].toUpperCase();

          str = strArr1.join('');
          //str = [str];

        }   

    }
    console.log(str);



  }
  return str;


}

titleCase("I'm a little tea pot");
Tonye Dixon
@tonye-d
Nov 15 2016 07:12
can someone tell me what i'm doing wrong?

//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 i = 0;
var j = 0;
  while (i < contacts.length){
    while (j < contacts[i].length){
      if (contacts.i.j[0] === firstName && contacts[i].hasOwnProperty === prop) {
        return contacts.i[j];
      }
    }
    i++;
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Mateusz Kadlubowski
@xeho91
Nov 15 2016 07:13
@EricK425 Woah that's very long code, but can you show what's the current output of this code? Because at first look I can see that lack of space inside join function between single quotations strArr1.join(''); causes your problem
Eric K
@EricK425
Nov 15 2016 07:13
@xeho91 the code out put is
I'm
A
Little
Teapot
Ogundele Olumide
@Lumexralph
Nov 15 2016 07:13
@tonye-d you need just one loop
Philipp Scholz
@philipp32
Nov 15 2016 07:14
@tonye-d your i and j remain 0
Eric K
@EricK425
Nov 15 2016 07:14
@xeho91 well it actually just outputs the last word so just Pot
Philipp Scholz
@philipp32
Nov 15 2016 07:14
only use one loop and count i higher before @tonye-d
Eric K
@EricK425
Nov 15 2016 07:14
@xeho91 the console log view shows the word broken into the correct separate strings but I just need to put them together
Philipp Scholz
@philipp32
Nov 15 2016 07:15
function titleCase(str) {
  str = str.toLowerCase();
  var array = str.split(" ");
  var container, firstLetters = [];  
  for (i=0; i<array.length; i++)
     container = array.charAt(0);
     //firstLetters = array.charAt(0);
  return array;
}
It shows me that arraycharAt(0) is not a function. What??!!!
Mateusz Kadlubowski
@xeho91
Nov 15 2016 07:16
@EricK425 Did you forget to declare variables i and j in your loops?
Ogundele Olumide
@Lumexralph
Nov 15 2016 07:16
@tonye-d you can't access an array using this method contacts.i.....only used as property access, contatcts is an array rememeber...use contacts[i]
Eric K
@EricK425
Nov 15 2016 07:17
@xeho91 I initialized them.. I don't think thats the issue basically there isn't an issue running the code it's just I can't figure out how to put all the separate strings back together into the final answer.. the code functions perfectly and gives the desired separte strings I just need to make them one string
Ghulam Shabir
@ghulamshabir
Nov 15 2016 07:17
@philipp32 its just the same as your previous, you have just used different variables and charAt instead of str[i][0]
Mateusz Kadlubowski
@xeho91
Nov 15 2016 07:17
@philipp32 you need to you made variable array an array now is no longer a string, is an array. So you need to access certain index in your array
eyeseau
@eyea
Nov 15 2016 07:17

@ghulamshabir

function palindrome(str) {
  // Good luck!
  var after = "";
  var before = str;

  after = before.toLowerCase().replace(/[\W_]/g,"").split("").reverse().join("");
  if(before == after){
    return true;
  }else{
    return false;
  }
}
palindrome("race car");

false

it should be true
Ogundele Olumide
@Lumexralph
Nov 15 2016 07:18
@tonye-d use a loop to iterate through contacts element which will be an object at every iteration contacts[i], check if that property has the firstName and use Object.hasOwnProperty(prop) to check if the property exists and return the value
Ghulam Shabir
@ghulamshabir
Nov 15 2016 07:19
@eyeA you need to store the result of replace in one variable and result of reverse.join into another variable then compare them
Ian
@toianw
Nov 15 2016 07:19
@eyeA before has a space in it and after doesn't
Ogundele Olumide
@Lumexralph
Nov 15 2016 07:21
@philipp32 you didn't pick any element in the iteration, array is just an array, it threw a TypeError because you're carrying out array.charAt(0), which is a function done on string object, use array[i].charAt(0)
__mifflin__
@cdrainxv
Nov 15 2016 07:22
@eyeA: You need to apply the same replace you did to after to before as well… The only difference b/t them is that you reverse after, but not before… Then compare them using ===.
eyeseau
@eyea
Nov 15 2016 07:29
@cdrainxv yes
:+1:
the after is ----qracecar
the before is ----race carq
__mifflin__
@cdrainxv
Nov 15 2016 07:33
@eyeA: It’s not the same though is it… why does before have a space… it has to be exactly the same as after except after is reversed.
Tonye Dixon
@tonye-d
Nov 15 2016 07:35
@Lumexralph baba, you much!
Ogundele Olumide
@Lumexralph
Nov 15 2016 07:36
@tonye-d :smile:
@tonye-d glad I could help
Jax
@jax11000
Nov 15 2016 07:55
can someone tell me why the name of the city is not being shown? http://codepen.io/Jax11000/pen/ObXZZL
Ghulam Shabir
@ghulamshabir
Nov 15 2016 07:57
@jax11000 you saved your work ? I don't see weather is defined or you call any getJSON
Jax
@jax11000
Nov 15 2016 07:58
@ghulamshabir i totally missed a giant step huh?
Ghulam Shabir
@ghulamshabir
Nov 15 2016 07:59
@jax11000 i think so
Jax
@jax11000
Nov 15 2016 08:01
@ghulamshabir to be honest. this whole JSON thing makes no sense to me, been struggling with it for a while now.
Ghulam Shabir
@ghulamshabir
Nov 15 2016 08:02
@jax11000 JSON is just conventional name of a js object { ... }
Java Script Object Notation
Jax
@jax11000
Nov 15 2016 08:04
@ghulamshabir i understand what it is. im having trouble with how to implement the code in a practical way
Ogundele Olumide
@Lumexralph
Nov 15 2016 08:04
@jax11000 json is just a data from a server in object format, you try to study the information with the api
Ghulam Shabir
@ghulamshabir
Nov 15 2016 08:04
@jax11000 you need to learn how to call an api and get the json object
Ogundele Olumide
@Lumexralph
Nov 15 2016 08:05
then it'll be easier to implement it in your project @jax11000
Ghulam Shabir
@ghulamshabir
Nov 15 2016 08:05
@jax11000 mostly people use jquery $.getJSON
Jax
@jax11000
Nov 15 2016 08:06
i understand the $.getJSON part. its the part thats in () after thats confusing me
Ogundele Olumide
@Lumexralph
Nov 15 2016 08:08
@jax11000 a callback function that takes the data from the ajax request, that's where the implementation of the data starts
Ghulam Shabir
@ghulamshabir
Nov 15 2016 08:09
$.getJSON("url", function(data) {
 console.log(data);
}
json object will copied to data
Ogundele Olumide
@Lumexralph
Nov 15 2016 08:13
@jax11000 as @ghulamshabir said, data is what you work with if the ajax request is successful and you also have to pay attention or read about the api
Jax
@jax11000
Nov 15 2016 08:13
okay got that part. so the rest of my stuff i write after the end curly bracket of the $.getJSON right?
duyduc1110
@duyduc1110
Nov 15 2016 08:16
Im stuck at palindromes
Ogundele Olumide
@Lumexralph
Nov 15 2016 08:16
@jax11000 yes
duyduc1110
@duyduc1110
Nov 15 2016 08:16
how to use str.replace(" ","")
e.g: "a b c" => "ab c"
i need "a b c" -> "abc"
Ogundele Olumide
@Lumexralph
Nov 15 2016 08:17
@duyduc1110 str.(x, y).. .. It will replace the match of x in the str with y
Mateusz Kadlubowski
@xeho91
Nov 15 2016 08:18

@duyduc1110 Example:

var string "Hello world!";
string = string.replace("Hello", "Hi");

Output: Hi world!

Ogundele Olumide
@Lumexralph
Nov 15 2016 08:18
@duyduc1110 use RegExp
duyduc1110
@duyduc1110
Nov 15 2016 08:18
I mean
replace(x,y) only replace 1 time
Ogundele Olumide
@Lumexralph
Nov 15 2016 08:18
@duyduc1110 you want to replace white space so...
duyduc1110
@duyduc1110
Nov 15 2016 08:19
i need it to find and replace all
Ogundele Olumide
@Lumexralph
Nov 15 2016 08:19
@duyduc1110 str.replace(/s/g, "" )
Mateusz Kadlubowski
@xeho91
Nov 15 2016 08:20
@duyduc1110 Then you need to use JavaScript regex as @Lumexralph said, there's a link to cheat sheet: https://www.debuggex.com/cheatsheet/regex/javascript
Ogundele Olumide
@Lumexralph
Nov 15 2016 08:20
@duyduc1110 sorry for any typo, am using the app and am limited with symbols on my keypad
Mateusz Kadlubowski
@xeho91
Nov 15 2016 08:21
@duyduc1110 more about JavaScript regex is here: http://www.w3schools.com/jsref/jsref_obj_regexp.asp
Ogundele Olumide
@Lumexralph
Nov 15 2016 08:21
@duyduc1110 can't access my pc now
duyduc1110
@duyduc1110
Nov 15 2016 08:22
there is a challenge of "/s+/g" in Basic JS but I cant find out
:(
Tonye Dixon
@tonye-d
Nov 15 2016 08:22

i wanna sleep but this is keeping me awake


//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }     
];


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


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");

help please!

Mateusz Kadlubowski
@xeho91
Nov 15 2016 08:23
@tonye-d What's the problem in this code?
Ogundele Olumide
@Lumexralph
Nov 15 2016 08:23
@duyduc1110 use a back slash before s in your regEx pattern
Mateusz Kadlubowski
@xeho91
Nov 15 2016 08:24
@tonye-d You need to learn to use else if and else, the way you made conditions are a bit confusing
Ogundele Olumide
@Lumexralph
Nov 15 2016 08:24
@duyduc1110 you're only matching the alphabet s with that there should be a backslash with s... Which is special character for white space in regEx, check the link @xeho91 pasted to have more understanding on it