These are chat archives for FreeCodeCamp/HelpJavaScript

29th
Jun 2016
Milo Hartsoe
@MiloATH
Jun 29 2016 00:00
You have to use the equal sign to set myArray = myArray.reverse();
Cyffer
@cyffer
Jun 29 2016 00:00
@Chrono79
Jabbawoki
@Jabbawoki
Jun 29 2016 00:00
mk
Moisés Man
@moigithub
Jun 29 2016 00:01
@SecondarySpawn var value = card + 1; wrong
to increase count.. should be
count++
count = count +1
or
count += 1
Jabbawoki
@Jabbawoki
Jun 29 2016 00:01
@MiloATH I think the issue is that it doesn't delete punctuation etc...
Norvin Burrus
@ndburrus
Jun 29 2016 00:01
@SecondarySpawn alright... how is the counter being handled? also, these may be helpful in understanding the return statement:
Milo Hartsoe
@MiloATH
Jun 29 2016 00:02
Work?
@Jabbawoki
Jabbawoki
@Jabbawoki
Jun 29 2016 00:02
It flips it correctly and everything but doesn't delete all the other stuff like in the word *(%^eye^$@
Gabriel De Paula
@SecondarySpawn
Jun 29 2016 00:02

@moigithub so i should

return count += 1?

Milo Hartsoe
@MiloATH
Jun 29 2016 00:02
Use \s
Jabbawoki
@Jabbawoki
Jun 29 2016 00:02
i just want eye to remain.
Milo Hartsoe
@MiloATH
Jun 29 2016 00:02
I think \s is all whitespace
Jabbawoki
@Jabbawoki
Jun 29 2016 00:03
where do i put it?
Mark Ayoub
@mk485eg
Jun 29 2016 00:03
any help will be greate to solve this clue
Milo Hartsoe
@MiloATH
Jun 29 2016 00:03
In the regex
Moisés Man
@moigithub
Jun 29 2016 00:03
@SecondarySpawn also it should be done in 2 parts... first.. evaluate card and increase or decrease count variable
and second... evaluate count value.. n return Bet or Count
@SecondarySpawn no return. just increase(or decrease) count..
Jabbawoki
@Jabbawoki
Jun 29 2016 00:04
Like this?
new RegExp("[^a-z0-9\s]");
Mark Ayoub
@mk485eg
Jun 29 2016 00:04
blob
Gabriel De Paula
@SecondarySpawn
Jun 29 2016 00:04
would I use console.log(count +=1)
return "Bet"
Mark Ayoub
@mk485eg
Jun 29 2016 00:05
any help ?
Gabriel De Paula
@SecondarySpawn
Jun 29 2016 00:05
@moigithub So the if part of the equation is right ??
Moisés Man
@moigithub
Jun 29 2016 00:05
@SecondarySpawn to increase is just ANY of this
count++
count = count +1
or
count += 1
(pick 1 )
Gabriel De Paula
@SecondarySpawn
Jun 29 2016 00:05
Okay
let me try it out and see what happens, but how would I set it up to return both the count and the work bet or hold
Norvin Burrus
@ndburrus
Jun 29 2016 00:06
@eduwin7 carefully consider the placement of this code: str.split('').reverse().join(''); :palm_tree:
Gabriel De Paula
@SecondarySpawn
Jun 29 2016 00:08
@moigithub could you possibly start it out for me ?? I am lost but I also want to learn
Moisés Man
@moigithub
Jun 29 2016 00:09
if (card >= 2 && card <= 6) {
   count++;
} else if ( ......   )
Gabriel De Paula
@SecondarySpawn
Jun 29 2016 00:13
@moigithub Thank you! i think i figured it out :)
CamperBot
@camperbot
Jun 29 2016 00:13
secondaryspawn sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1564 | @moigithub |http://www.freecodecamp.com/moigithub
John Alcher
@alchermd
Jun 29 2016 00:14
Hey mates. I'm just wondering why I'm getting an infinite loop in my code.
https://gist.github.com/alchermd/55a15538d7797bf835bc84c9fbd28fab
Gabriel De Paula
@SecondarySpawn
Jun 29 2016 00:14
@moigithub Oh yep, that is what I did. Thanks for the tip :) !! I was thinking about this for a while, I make another if statement for the BET or HOLD and set it to name then I returned count + name and I think it should work
CamperBot
@camperbot
Jun 29 2016 00:14
secondaryspawn sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: secondaryspawn already gave moigithub points
John Alcher
@alchermd
Jun 29 2016 00:15
why does arr!= [] not work here? shouldn't arr be empty by the time the loop finishes?
Moisés Man
@moigithub
Jun 29 2016 00:15
@SecondarySpawn :+1:
@alchermd
[]==[] >>> false
[]!=[] >>> true
@alchermd try with length
while (arr.length>0){.... }
plz
Gabriel De Paula
@SecondarySpawn
Jun 29 2016 00:16

@moigithub ```
var count = 0;

function cc(card) {

// Only change code below this line
if (count >= 1) {
name = " Bet";
} else if (count <= 0) {
name = " Hold";
}

if (card >= 2 && card <= 6) {
count += 1;
return count + name;
} else if (card >= 7 && card <= 9) {
count -= 1;
return count + name;
}

// Only change code above this line
}

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

@moigithub
var count = 0;

function cc(card) {

  // Only change code below this line
 if (count >= 1) {
   name = " Bet";
 } else if (count <= 0) {
   name = " Hold";
 }

  if (card >= 2 && card <= 6) {
   count += 1;
   return count + name;
 }  else if (card >= 7 && card <= 9) {
   count -= 1;
   return count + name;
 }


  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Does that look right so far ?
@moigithub I dont think that they way I set it up that it will check the name variable, will it?
John Alcher
@alchermd
Jun 29 2016 00:19
@moigithub lmao thats painfully obvious why didn't I think of that. I shouldn't feel bad since It's still the same concept right (check if arr is empty)? :D
Moisés Man
@moigithub
Jun 29 2016 00:19
@SecondarySpawn should decrease count if
card is any of this 10, 'J', 'Q', 'K', 'A'
John Alcher
@alchermd
Jun 29 2016 00:19
@alchermd big thanks!
CamperBot
@camperbot
Jun 29 2016 00:19
sorry alchermd, you can't send brownie points to yourself! :sparkles: :sparkles:
Gabriel De Paula
@SecondarySpawn
Jun 29 2016 00:20
Oh yes, silly mistake @moigithub
@moigithub So it is right the way it is so far, correct?
Moisés Man
@moigithub
Jun 29 2016 00:22

@SecondarySpawn move this to the end

 if (count >= 1) {
   name = " Bet";
 } else if (count <= 0) {
   name = " Hold";
 }

and move return count + name; after that block

Gabriel De Paula
@SecondarySpawn
Jun 29 2016 00:24
ar count = 0;

function cc(card) {

  // Only change code below this line


  if (card >= 2 && card <= 6) {
   count += 1;
 }  else if (card >= 7 && card <= 9) {
   count = 0;
 } else if (card = 10, "J", "Q", "K", "A") {
   count -= 1;

 }

  if (count >= 1) {
   name = " Bet";
 } else if (count <= 0) {
   name = " Hold";
 }

     return count + name;

  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
All of the challenges check out except one
llamatarianism
@llamatarianism
Jun 29 2016 00:25
card = 10, "J", "Q", "K", "A" this is your problem
first of all, you're trying to use = as the equality operator
= is the assignment operator
use === for equality
second of all, that's not valid syntax
that's just not a valid way to check if something is 1 of several values
you need to use || (logical or)
card === 10 || card === "J" || ...
JohnnyMcMonny
@JohnnyMcMonny
Jun 29 2016 00:27
Another silly question from me:
What's wrong with my escape sequences on this challenge? https://www.freecodecamp.com/challenges/escape-sequences-in-strings
My code: var myStr = "Here is a backslash: \ . \n \t \t This is a new line with two tabs.";
llamatarianism
@llamatarianism
Jun 29 2016 00:27
oh also
count = 0;
JohnnyMcMonny
@JohnnyMcMonny
Jun 29 2016 00:27
(there are two backslashes after "backslash:". They just didn't show up here.)
llamatarianism
@llamatarianism
Jun 29 2016 00:27
you're supposed to add 0 in this case
not reset it to 0
Norvin Burrus
@ndburrus
Jun 29 2016 00:28
@JohnnyMcMonny where is the text?
Gabriel De Paula
@SecondarySpawn
Jun 29 2016 00:28
@llamatarianism Oh alright, so instead of and I should use or?
Moisés Man
@moigithub
Jun 29 2016 00:28
My code: var myStr = "Here is a backslash: \\ . \n \t \t This is a new line with two tabs.";
@JohnnyMcMonny
remove extra spaces
after dot, \n, and \t
Heather
@heathermhargreaves
Jun 29 2016 00:29
I've got a question on the palindrome exercise specifically on how to recognize special characters for string splits. here is the code I have so far:

function palindrome(str) {
var normStr = str.toLowerCase().replace(/[&\/\#,+()$~%.'":*?-\<>{}]/g,'_');;
var revStr = normStr.split('').reverse().join('');
if (str === revStr) {
return true;
}
else {
return revStr;
}
}

palindrome("0_0 (: /-\ :) 0-0");

ALMY91
@ALMY91
Jun 29 2016 00:30

You have a module of code you want to use in a number of different Javascript programs (or for client-side Javascript, on a number of different web pages)

This code defines variable to store intermediate results of its computation

Problem: Since this code will be used in many different programs, you do not know if the variable it creates will conflict with variables used by the programs that imports it.

Solution: Put the code in a function and then invoke. This way, variables that would have been global become local to the function

Stephen James
@sjames1958gm
Jun 29 2016 00:30
@heathermhargreaves make sure you are using your modified string to compare with your reversed string
Heather
@heathermhargreaves
Jun 29 2016 00:31
function palindrome(str) {
  var normStr = str.toLowerCase().replace(/[&\/\\#,+()$~%.'":*?\-\<>{}]/g,'_');;
  var revStr = normStr.split('').reverse().join('');
  if (str === revStr) {
    return true;
  }
  else {
    return revStr;
  }
}



palindrome("0_0 (: /-\ :) 0-0");
Moisés Man
@moigithub
Jun 29 2016 00:31
@heathermhargreaves u should NOT have underscores... u replacing all those characters by _
Coy Sanders
@coymeetsworld
Jun 29 2016 00:31
@heathermhargreaves you could simplify using regex code
Heather
@heathermhargreaves
Jun 29 2016 00:31
@coymeetsworld I think that's what I need to do too
JohnnyMcMonny
@JohnnyMcMonny
Jun 29 2016 00:31
@moigithub
Like this?
var myStr = "Here is a backslash: \ .\n\t\t This is a new line with two tabs.";
ALMY91
@ALMY91
Jun 29 2016 00:31
i don really understand what this means tho
Norvin Burrus
@ndburrus
Jun 29 2016 00:31
@eduwin7 how are we doing?
Leonid S. Knyshov
@wiseleo
Jun 29 2016 00:32
johnny use backticks to enclose your code in this chat system
Norvin Burrus
@ndburrus
Jun 29 2016 00:32
help format @JohnnyMcMonny
CamperBot
@camperbot
Jun 29 2016 00:32

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

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

Moisés Man
@moigithub
Jun 29 2016 00:32
u still have a space before dot and after last \t
var myStr = "Here is a backslash: \\ .\n\t\t This is a new line with two tabs.";
@JohnnyMcMonny
Heather
@heathermhargreaves
Jun 29 2016 00:32
@coymeetsworld not sure how to get there though. when I print that screen to the console.log I get
```
=> '0_0 __ __ __ 0_0'
Stephen James
@sjames1958gm
Jun 29 2016 00:33
@heathermhargreaves It easier to use a negative pattern such as [^0-9a-z]
Heather
@heathermhargreaves
Jun 29 2016 00:33
so it should work, but still returns false
Stephen James
@sjames1958gm
Jun 29 2016 00:33
@heathermhargreaves Look at your compare - str is unmodified use normStr
Coy Sanders
@coymeetsworld
Jun 29 2016 00:34
@heathermhargreaves i don't think you want to replace those characters with an underscore, i think you want to remove them completely
Mike
@Nachtleben
Jun 29 2016 00:34
find celsius
CamperBot
@camperbot
Jun 29 2016 00:34
Heather
@heathermhargreaves
Jun 29 2016 00:34
@sjames1958gm thanks! so put that in instead of [^0-9a-z]?
CamperBot
@camperbot
Jun 29 2016 00:34
heathermhargreaves sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1669 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
ALMY91
@ALMY91
Jun 29 2016 00:34
hi can anybody help me out here?
Coy Sanders
@coymeetsworld
Jun 29 2016 00:34
also include capital letters @heathermhargreaves
Stephen James
@sjames1958gm
Jun 29 2016 00:34
@heathermhargreaves that pattern and a replace string of '' will remove all but those characters
Since you use toLowerCase prior to replace capitals are not needed.
Coy Sanders
@coymeetsworld
Jun 29 2016 00:36
oh thats true
Norvin Burrus
@ndburrus
Jun 29 2016 00:36
@Nachtleben use the formula in the instructions... :sailboat: translate it into code :hamster:
JohnnyMcMonny
@JohnnyMcMonny
Jun 29 2016 00:36
@moigithub
Is there any chance you could write out the correct code? I don't see why mine isn't working:
'var myStr = "Here is a backslash: \.\n\t\tThis is a new line with two tabs.";'
Ignore those backticks on the end
Norvin Burrus
@ndburrus
Jun 29 2016 00:37
@JohnnyMcMonny ...ensure this translation is accurate: \\ backslash note: the period is being escaped - is that what you want?
Moisés Man
@moigithub
Jun 29 2016 00:38
var myStr = "Here is a backslash: \\.\n\t\tThis is a new line with two tabs.";
Here insteadof This
@JohnnyMcMonny
Stephen James
@sjames1958gm
Jun 29 2016 00:38
JohnnyMcMonny
@JohnnyMcMonny
Jun 29 2016 00:39
@moigithub Of course I would do that, lol. Thank you for the help. ^^'
CamperBot
@camperbot
Jun 29 2016 00:39
johnnymcmonny sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1565 | @moigithub |http://www.freecodecamp.com/moigithub
ALMY91
@ALMY91
Jun 29 2016 00:44
@sjames1958gm
paxblueribbon
@paxblueribbon
Jun 29 2016 00:44
i'm having an issue with my weather page challenge. The checkbox to change from fahrenheit to celsius should be working, but isn't... i think the info isn't refreshing when someone flips the switch. How can I make it refresh onClick? http://codepen.io/PaxBlueRibbon/pen/wWJWXj
ALMY91
@ALMY91
Jun 29 2016 00:45
function mymodule(x){
square=x*x; //Module code goes here any variables used by the module are local to this function
return square; //instead of cluttering up the gloval namespace
}

console.log(mymodule(12));

//So what they are saying is if we do not know whether the variable square will conflict with 
//variables used by the programs that import it. By putting the code into a function and then invoking it
//variables that would have been global become local
DANIELHART19
@DANIELHART19
Jun 29 2016 00:50
struggling with the Escape sequences in strings
var myStr = "Here is a backslash:\.\n\t\tHere is a new line with two tabs.";
never mind fixed it ha
Om Carrasquillo
@oc2215
Jun 29 2016 00:58
@DANIELHART19 How did you fix it? var myStr = "Here is a backslash:\.\n\t\t Here is a new line with two tabs.";
I'm having trouble with mine, it says the spacing is not correct
Diego Mayer
@Chrono79
Jun 29 2016 01:04
@DANIELHART19 leave a space after the :
John Alcher
@alchermd
Jun 29 2016 01:04
Hey mates. Can anyone analyze my code and explain why it's still including null on the returned array even though I filtered it out?
https://gist.github.com/alchermd/40ec4a994276e28874dad3c12d0e9c9d
Moisés Man
@moigithub
Jun 29 2016 01:05
@oc2215 remove space after last \t
Diego Mayer
@Chrono79
Jun 29 2016 01:05
@oc2215 you too leave a space after the : and also remove the space between \t and Here
Alex Harshaw
@aharshaw
Jun 29 2016 01:08
Hello, I'm going the wrong direction with Profile Lookup
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
/// 4 other objects later....

function lookUpProfile(firstName, prop){
// Only change code below this line
  if(contacts.hasOwnProperty(firstName)){
    if(contacts.firstName.hasOwnProperty(prop)){
      return firstName,prop;
    }
      else{
        return "No such contact";
      }
    }

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Om Carrasquillo
@oc2215
Jun 29 2016 01:10
@Chrono79 @moigithub Thank you very much! Appreciate the help.
CamperBot
@camperbot
Jun 29 2016 01:10
oc2215 sends brownie points to @chrono79 and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1348 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 1566 | @moigithub |http://www.freecodecamp.com/moigithub
Alex Harshaw
@aharshaw
Jun 29 2016 01:11
I checked the forum and I could immediately tell I was handling this the wrong way. Is my logic even on track here?
Diego Mayer
@Chrono79
Jun 29 2016 01:11
@alchermd it's not null that's returning, it's NaN
@aharshaw contacts is an array, a loop is the right approach there
John Alcher
@alchermd
Jun 29 2016 01:13
@Chrono79 I got it working now with if(x) {return x} , but I'm still curious why my method doesn't work
Alex Harshaw
@aharshaw
Jun 29 2016 01:13
Can you go into detail why? @Chrono79
I feel like the further I get into these lessons, the more often I’m picking the wrong tools to solve problems
Diego Mayer
@Chrono79
Jun 29 2016 01:14
@alchermd NaN is a special case, it's the only value that makes this false x === x
John Alcher
@alchermd
Jun 29 2016 01:15
@Chrono79 I see. One last thing, why is if(x) not the same as if(x === true)?
Diego Mayer
@Chrono79
Jun 29 2016 01:16
@alchermd the === also checks the type (boolean), so only true would pass that
when you use x as an if condition, it converts that value to a boolean
@aharshaw think of it as an address book, where each contact is a page
each page can be accessed with the loop indice
kuldeep
@gurukd
Jun 29 2016 01:22

function palindrome(str) {
// Good luck!
var collectString = str.replace(/([_(-:,.)\/|\s])/gi,'').toLowerCase().split('').join('');
var compareString = str.replace(/([_(-:,.)\/|\s])/gi,'').toLowerCase().split('').reverse().join('');
console.log(collectString);
console.log(compareString);
if(collectString === compareString){
return true;
}else {
return false;
}
}

palindrome("1 eye for of 1 eye.");
Can anyone help with this code. Only this palindrome("1 eye for of 1 eye."); call returning true but in chrome console its showing false;

Diego Mayer
@Chrono79
Jun 29 2016 01:25
@gurukd Use a better regex, that doesn't work
Look at what that regex does here: https://regex101.com
Moisés Man
@moigithub
Jun 29 2016 01:27
@gurukd parenthesis and dot are "special" characters on regex.. if u wanna it to be treated as regular character it must be escaped
Rafael Uzcategui
@rafaelg21
Jun 29 2016 01:29
Hi, How to add data to a settlement within a JSON collection
kuldeep
@gurukd
Jun 29 2016 01:29
@Chrono79 @moigithub Thanks Its easy
CamperBot
@camperbot
Jun 29 2016 01:29
gurukd sends brownie points to @chrono79 and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1567 | @moigithub |http://www.freecodecamp.com/moigithub
:star2: 1349 | @chrono79 |http://www.freecodecamp.com/chrono79
Rafael Uzcategui
@rafaelg21
Jun 29 2016 01:30

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

´´´´

FM
@mafelix
Jun 29 2016 01:30
settlement?
you mean add data to a property within a json collection?
Diego Mayer
@Chrono79
Jun 29 2016 01:31
@gurukd code optimization:
var collectString = str.replace(/([_(-:,.)\/|\s])/gi,'').toLowerCase().split('').join(''); // split next to join does nothing here
var compareString = str.replace(/([_(-:,.)\/|\s])/gi,'').toLowerCase().split('').reverse().join(''); // and here you could replace a lot of this just reversing collecString
FM
@mafelix
Jun 29 2016 01:31
var jsonCollection[propertyName] = whatever_value_you_want
Moisés Man
@moigithub
Jun 29 2016 01:32
@rafaelg21 push is an array method
pushing on a non array will fail
Rafael Uzcategui
@rafaelg21
Jun 29 2016 01:34
value
collection[id][prop]=[].push(value);
bitgrower
@bitgrower
Jun 29 2016 01:39
now there's a syntax I haven't seen before!
Moisés Man
@moigithub
Jun 29 2016 01:39
@rafaelg21 tal vez deberias postear todo tu codigo...
Rafael Uzcategui
@rafaelg21
Jun 29 2016 01:41

´´´js
// Setup
var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"2468": {
"album": "1999",
"artist": "Prince",
"tracks": [
"1999",
"Little Red Corvette"
]
},
"1245": {
"artist": "Robert Palmer",
"tracks": [ ]
},
"5439": {
"album": "ABBA Gold"
}
};

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

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

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

if (collection[id].hasOwnProperty("tracks") === false ) {
  collection[id].tracks = [];
}

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

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

return collection;
}

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

Moisés Man
@moigithub
Jun 29 2016 01:42
@rafaelg21 tienes el "backtick" alrevez :) ` <---
Rafael Uzcategui
@rafaelg21
Jun 29 2016 01:43

// Setup
var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"2468": {
"album": "1999",
"artist": "Prince",
"tracks": [
"1999",
"Little Red Corvette"
]
},
"1245": {
"artist": "Robert Palmer",
"tracks": [ ]
},
"5439": {
"album": "ABBA Gold"
}
};

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

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

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

if (collection[id].hasOwnProperty("tracks") === false ) {
  collection[id].tracks = [];
}

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

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

return collection;
}

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

Moisés Man
@moigithub
Jun 29 2016 01:44
SI.. prop no es "tracks"
if (prop !== "tracks")
bitgrower
@bitgrower
Jun 29 2016 01:45
backtick -- and you don't even have to re-post your code to get it in there -- just edit your post @rafaelg21
OZ Gnaly
@OZGnaly
Jun 29 2016 01:47
hi !
Moisés Man
@moigithub
Jun 29 2016 01:47

este bloque

if (collection[id].hasOwnProperty("tracks") === false ) {
  collection[id].tracks = [];
}

deberia estar dentro del siguiente IF
else if ( collection[id][prop] === "tracks" && value !== "" ) { <-- deberias revisar SI prop es tracks...no collection[][]etc
@rafaelg21

Dani
@danijmoss
Jun 29 2016 01:48
can i get an assist with profile lookup? i think im on the correct track but im probably missing something somewhere
for (var i = 0; i < contacts.length; i++) {
  if (firstName == contacts.firstName) {
    return contacts.firstName;   
  } else if (prop == contacts.prop) {
    return contacts.prop;
  } else if (firstName !== contacts.firstName) {
    return "No such contact";
  } else if (prop !== contacts.prop) {
    return "No such property";
  }
}
Moisés Man
@moigithub
Jun 29 2016 01:48
@danijmoss contacts is an array of objects.. u need a index to access its elements
ie.. contacts[0] will return the first object
and contacts[0].firstName will return the name of the first object
Dani
@danijmoss
Jun 29 2016 01:49
so should i do var i = [0]; in the for statement?
or will that not work?
Moisés Man
@moigithub
Jun 29 2016 01:50
i already have correct values for (var i = 0; i < contacts.length; i++) {
but u not accessing the array properly
should be
contacts[0] for first object
contacts[1] for second object
contacts[2] for next and so on
those numbers are on the i variable
soo u can just say contacts[i]
Dani
@danijmoss
Jun 29 2016 01:52
oh! i see! yes!
i was just about to ask if contacts[i] would be the correct path
let me try that now
Wan Jong Kim
@wanjongkim
Jun 29 2016 01:56
$.getJSON(search, function(data) {
            $.each(data.items, function(index, value) {
                var obj = {};
                obj.title = value.title;
                obj.link = value.link;
                obj.image = value.image.thumbnailLink;
                response.push(response);
            });
            console.log(response[0].title);
            res.setHeader('Content-Type', 'application/json');
            res.send(JSON.stringify(response));
        });
could someone tell me why I get null for response[0].title
Dani
@danijmoss
Jun 29 2016 01:58
ugh! ok so i still dont get it apparently. here's what i have now. i did have trouble with accessing nested arrays in the previous challenges. here's what i have now. can you point me in the correct direction?
for (var i = 0; i < contacts.length; i++) {
  if (firstName == contacts[i][firstName]) {
    return contacts.firstName;   
  } else if (prop == contacts[i][prop]) {
    return contacts.prop;
  } else if (firstName !== contacts[i][firstName]) {
    return "No such contact";
  } else if (prop !== contacts[i][prop]) {
    return "No such property";
  }
}
Moisés Man
@moigithub
Jun 29 2016 02:04

@danijmoss
if (firstName == contacts[i][firstName]) { <---
fistName is a variable.. but on the contacts objects.. this refer to the property name

var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",

soo instead of contacts[i][firstName]
should be contacts[i]["firstName"] or using dot notation contacts[i].firstName
which will return ie. "Akira"
also this are not correct...
return contacts.firstName;
return contacts.prop

Dani
@danijmoss
Jun 29 2016 02:05
i thought you couldnt access strings with the quotes in the brackets?
Moisés Man
@moigithub
Jun 29 2016 02:05
contacts is an array.. soo missing the index [i]
prop is variable.. (not a real property name ) soo cant use dot notation
Dani
@danijmoss
Jun 29 2016 02:06
ah i see. ok. ill give this a try and let you know how it goes
Moisés Man
@moigithub
Jun 29 2016 02:07
if quotes.. like ["firstName"]
means firstName is literally a property name
Dani
@danijmoss
Jun 29 2016 02:08
ah! ok! i get it now. :)
Moisés Man
@moigithub
Jun 29 2016 02:08
without quotes mean is a variable...
soo if the variable contains "Akira" string (ie. firstName = "Akira")
contacts[i][firstName] would be interpreted as contacts[i]["Akira"] <-- but no Akira property/key name exist
Johan De Jesus
@jdpowers
Jun 29 2016 02:10

Hello guys, I am having a small issue. I'm currently working on the Record Collection exercise and I am stuck!

// Setup
var collection =
{
"2548":
{
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": ["Let It Rock", "You Give Love a Bad Name"]
},

"2468":
{
"album": "1999",
"artist": "Prince",
"tracks": ["1999", "Little Red Corvette"]
},

"1245":
{
"artist": "Robert Palmer",
"tracks": [ ]
},

"5439": {
"album": "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

return collection;
}

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

Dani
@danijmoss
Jun 29 2016 02:10
i tried to use brackets but now its saying the syntax is incorrect
for (var i = 0; i < contacts.length; i++) {
  if (firstName == contacts[i]["firstName"]) {
    return contacts.firstName;   
  } else if (prop == contacts[i].prop) {
    return contacts.prop;
  } else if (firstName !== contacts[i]["firstName"]) {
    return "No such contact";
  } else if (prop !== contacts[i].prop) {
    return "No such property";
  }
}
Moisés Man
@moigithub
Jun 29 2016 02:11
@danijmoss prop is variable.. u cant use dot notation...
Dani
@danijmoss
Jun 29 2016 02:12
so it would be contacts[i][prop]?
Meera Sundar
@mirageq
Jun 29 2016 02:13

Hi, I've been stuck with this for a while. How do I filter an array from an array?
`
function destroyer(arr) {
/You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments /

var args = Array.prototype.slice.call(arguments, 1);
var filteredArr = arr.filter(function(x){
for(var i = 0; i < args.length; i++){
return (x != args[i]);
}
});
return filteredArr;
}

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

Johan De Jesus
@jdpowers
Jun 29 2016 02:14

Hello guys, I am having a small issue. I'm currently working on the Record Collection exercise and I am stuck!

// Setup
var collection =
{
"2548":
{
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": ["Let It Rock", "You Give Love a Bad Name"]
},

"2468":
{
"album": "1999",
"artist": "Prince",
"tracks": ["1999", "Little Red Corvette"]
},

"1245":
{
"artist": "Robert Palmer",
"tracks": [ ]
},

"5439": {
"album": "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

return collection;
}

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

That's my code.

But I can't seem to get it to accept my code. I am missing this: After updateRecords(2468, "tracks", "Free"), tracks should have "1999" as the first element.

This is what the console spits out: After updateRecords(2468, "tracks", "Free"), tracks should have "1999" as the first element.

Any ideas??

Meera Sundar
@mirageq
Jun 29 2016 02:14
Obviously, the for loop exits right after filtering out args[0]
David Liendo
@DavLiendoProgramming
Jun 29 2016 02:16
ehm i did it liek this :

function updateRecords(id, prop, value) {
if( value!=="" && prop==="tracks" ){
if (collection[id].hasOwnProperty("tracks")===false )
{
collection[id][prop]=[];

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

}

return collection;

}

ti worked for me
Dani
@danijmoss
Jun 29 2016 02:16
know what, i think im going to give this another go tomorrow. im too exhausted to think anymore.
by thanks @moigithub
CamperBot
@camperbot
Jun 29 2016 02:16
danijmoss sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1568 | @moigithub |http://www.freecodecamp.com/moigithub
Dani
@danijmoss
Jun 29 2016 02:16
i do appreciate the help! :)
bitgrower
@bitgrower
Jun 29 2016 02:19
@danijmoss -- -good choice ... too many folks butt their heads up against something, get tired, stressed out & burned out ... coding can be a ton of fun ... but gotta manage the experience ... #happycoding
David Liendo
@DavLiendoProgramming
Jun 29 2016 02:19
@jdpowers did it help you?
Santiago Gómez
@Sperkajugglite
Jun 29 2016 02:20
hi, theres a page that lets you see the order in which things happen in your script, do you know how its called?
Meera Sundar
@mirageq
Jun 29 2016 02:21
@jdpowers I did it like this and it worked:
function updateRecords(id, prop, value) {

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

    switch(prop){

      case "album":
      if(!(collection[id].hasOwnProperty('album'))){
      collection[id].album = value;
      }
      break;

    case "artist":
      collection[id].artist = value;
      break;

    case "tracks":
      if(!(collection[id].hasOwnProperty('tracks'))){
        var tracksArr = [];
        collection[id].tracks = tracksArr;
      }

      collection[id].tracks.push(value);
     break;
  }  }

  return collection;
}
Johan De Jesus
@jdpowers
Jun 29 2016 02:21

@DavLiendoProgramming, nope. Now it says I'm missing :

After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.

After updateRecords(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element.
After updateRecords(2468, "tracks", "Free"), tracks should have "1999" as the first element.

bitgrower
@bitgrower
Jun 29 2016 02:21
pythontutor.com/javascript.html ? Is that what you are looking for @Sperkajugglite ?
Santiago Gómez
@Sperkajugglite
Jun 29 2016 02:21
yes
thanks @bitgrower
CamperBot
@camperbot
Jun 29 2016 02:21
sperkajugglite sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1119 | @bitgrower |http://www.freecodecamp.com/bitgrower
Johan De Jesus
@jdpowers
Jun 29 2016 02:23
@DavLiendoProgramming I didn't paste it correctly the first time.... Its working now, thanks! :smile:
CamperBot
@camperbot
Jun 29 2016 02:23
jdpowers sends brownie points to @davliendoprogramming :sparkles: :thumbsup: :sparkles:
:cookie: 218 | @davliendoprogramming |http://www.freecodecamp.com/davliendoprogramming
Shawn Williams
@Shawn-Williams
Jun 29 2016 02:34
anyone on that might have time to review my javascript? http://codepen.io/Shawn-Williams/full/gMgWRr/
Dani
@danijmoss
Jun 29 2016 02:34
@bitgrower thanks dude! and that's very true
CamperBot
@camperbot
Jun 29 2016 02:34
danijmoss sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1120 | @bitgrower |http://www.freecodecamp.com/bitgrower
Bennn123
@Bennn123
Jun 29 2016 02:36
who can give me all answer?
'Add your JavaScript Slot Machine Slots' I can't slove this project.
Pavan Kulkarni
@pavankrcr
Jun 29 2016 02:40
//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].prop!=="") {
    console.log(contacts[i]["firstName"]);
   return contacts[i]["prop"];
    }

  else 
 {
    console.log(contacts["firstName"]);    
       return "No such Contact";
}
// Only change code above this line
}

// Change these values to test your function
console.log(lookUpProfile("Akira", "likes"));
i am not able return array please help
pahosler
@pahosler
Jun 29 2016 02:49
@Bennn123 get rid of the quotes ["prop"] should be [prop] etc....
sorry wrong person should have been @pavankrcr
pahosler
@pahosler
Jun 29 2016 02:55
anyone else trying M$ Visual Studio Code, yes it works with Linux also :D, that with nodejs has really helped me get through the first round of algorithum challenges. I'm actually impressed with this little IDE
Bnobo
@acloud12345678
Jun 29 2016 02:59
Hello World
CamperBot
@camperbot
Jun 29 2016 02:59

welcome to FreeCodeCamp @acloud12345678!

Nazim Abdimomunov
@dm-nz
Jun 29 2016 02:59
This message was deleted
This message was deleted
This message was deleted
Afolabi Kolawole
@Afolabi28
Jun 29 2016 03:02

function mutation(arr) {
  var arrS1 = arr.pop().toLowerCase().split("");
  var s2 = arr.pop().toLowerCase();

 for(var i = 0 ; i < arrS1.length; i++){ 
   if(s2.indexOf(arrS1[i]) == -1){
    return false;
 }
    else return true;
 }

}

mutation(["hello", "hey"]);
David Liendo
@DavLiendoProgramming
Jun 29 2016 03:02
guys...
pelae help
x.x
Nazim Abdimomunov
@dm-nz
Jun 29 2016 03:02
This message was deleted
David Liendo
@DavLiendoProgramming
Jun 29 2016 03:03

function lookUpProfile(firstName, prop){
// Only change code below this line
var aux1="";

for (var i = 0; i < contacts.length; i++) {
if (firstName == contacts[i][firstName]) {
if (prop == contacts[i][prop]) {
return contacts[i][prop];

}

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

step 217
if somebody could help
Nazim Abdimomunov
@dm-nz
Jun 29 2016 03:04

Can you help me with this?
It returns:
undefined is not an object (evaluating "collection[id].tracks.push")

function updateRecords(id, prop, value) {
if (prop === 'tracks' & collection[id].tracks === '') {
collection[id].tracks = [];
} else if (prop === 'tracks' & collection[id].tracks !== '') {
collection[id].tracks.push(value);
} else {
collection[id][prop] = value;
}
return collection;
}

Sebastian Dobri
@Seby56
Jun 29 2016 03:04
can anyone help me with challenge 215?

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

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

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

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

this is my code
Bnobo
@acloud12345678
Jun 29 2016 03:05
This message was deleted
This message was deleted
This message was deleted
can somebody help me with challenge 11?
Ted Shaw
@TedTShaw
Jun 29 2016 03:17
Hey guys, was wondering if someone could help me out with "accessing Nested objects"
Here's what I have so far

// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line
myStorage.car.inside["glove box"];
var gloveBoxContents = "maps"; // Change this line

not sure where I went wrong
friesenet21
@friesenet21
Jun 29 2016 03:18
@DavLiendoProgramming return contact[i][prop]; does not return anything since it is within the scope of aux1 which is returned instead.
96street
@96street
Jun 29 2016 03:20

what's the difference between

$.ajax({
  type: 'GET',
  }

and

$.ajax({
  type: 'json',
  }
?
Connor Hastey-Palindat
@cpalindat
Jun 29 2016 03:22
Is anyone free to help me figure out some regex stuff? Im seriously struggling haha
Matt
@TheeMattOliver
Jun 29 2016 03:22
hey @TedTShaw sure thing
try to paste your code in between two sets of three backticks (```)
like this:
help format
CamperBot
@camperbot
Jun 29 2016 03:22

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

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

Connor Hastey-Palindat
@cpalindat
Jun 29 2016 03:23
help spinal tap
CamperBot
@camperbot
Jun 29 2016 03:23

:point_right: algorithm spinal tap case [wiki]

Algorithm Spinal Tap Case

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

:checkered_flag: Problem Explanation:

Convert the given string to a lowercase sentence with words joined by dashes.

Relevant Links

:pencil: read more about algorithm spinal tap case on the FCC Wiki

Matt
@TheeMattOliver
Jun 29 2016 03:24
so just remember you're trying to access what's inside the object called myStorage
so here, you're declaring a variable
called gloveBoxContents
you're going to put the stuff inside gloveBoxContents
so it will be
var gloveBoxContents = myStorage.car.inside["glove box"];
Ted Shaw
@TedTShaw
Jun 29 2016 03:25
just got it right now
Thanks a bunch Matt
Matt
@TheeMattOliver
Jun 29 2016 03:25
oh ok cool
you got it
Ted Shaw
@TedTShaw
Jun 29 2016 03:25
I was trying to put it above the variable the whole time
Justin R
@Mathiar
Jun 29 2016 03:30
Hey folks :)
This message was deleted
This message was deleted
This message was deleted
This message was deleted
CamperBot
@camperbot
Jun 29 2016 03:32
:bulb: to format code use backticks! ``` more info
Justin R
@Mathiar
Jun 29 2016 03:32
split1.forEach(function(char) { var count = split2.filter(function(otherchar) { return otherchar == char; }).length; console.log(count) console.log(char) })
I want to sort char by count.
tezbo
@tezbo
Jun 29 2016 03:34
oh man
challenge 218
i thought i came up with the perfect way to do this
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0;i<contacts.length;i++){
if(contacts[i].firstName == firstName){
if(contacts[i][prop]){
return contacts[i][prop];
} else {
return "No such property";
}
} else {
return "No such contact";
}
}
// Only change code above this line
}
but it just doesn't like it ;(
Calat
@latimercaleb
Jun 29 2016 03:35
Hi guys I'm having issues with the golf course problem

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

// Change these values to test
golfScore(5, 4);
returns birdie instead of go home for the next to last test
ALMY91
@ALMY91
Jun 29 2016 03:37
hello is anyone there?
Calat
@latimercaleb
Jun 29 2016 03:38
Maybe I can help? While I'm waiting for help @ALMY91
ALMY91
@ALMY91
Jun 29 2016 03:38

You have a module of code you want to use in a number of different Javascript programs (or for client-side Javascript, on a number of different web pages)

This code defines variable to store intermediate results of its computation

Problem: Since this code will be used in many different programs, you do not know if the variable it creates will conflict with variables used by the programs that imports it.

Solution: Put the code in a function and then invoke. This way, variables that would have been global become local to the function

my question is
function mymodule(x){
square=x*x; //Module code goes here any variables used by the module are local to this function
return square; //instead of cluttering up the gloval namespace
}

console.log(mymodule(12));
what is the variable they are referring to?
Based on this code
is it square
or mymodule?
or x?
Calat
@latimercaleb
Jun 29 2016 03:41
@ALMY91 the only variable visible is square. X is an argument and mymodule is a function.
boruchwoolstone
@boruchwoolstone
Jun 29 2016 03:41
i beleive its square
although you need to declare it as var square, otherwise it will be a global var
x981
@x981
Jun 29 2016 03:46
I get this error on challenge "Show the local wearther", anyone help me.
jquery-2.2.4.min.js:4 Mixed Content: The page at 'https://s.codepen.io/boomerang/d7b335ce465d84f76a9fdfaaab766b361467171886701/index.html' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://api.openweathermap.org/data/2.5/weather?id=2172797&appid=77b646ea6f08891aca84686309edeb47'. This request has been blocked; the content must be served over HTTPS.
Yi
@ycoding007
Jun 29 2016 03:46
i got problems for the Mutation challenge, everything is true..what's wrong with the code?
//Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.
function mutation(arr) {
  var str1 = arr[0].toString() + " ";
  var str2 = arr[1].toString();
  var str = str1.concat(str2);

  return str.indexOf(str2)!==-1;

}

mutation(["hello", "neo"]);
x981
@x981
Jun 29 2016 03:46
OpenweatherMap is "http" not "https"
Greg Duncan
@GregatGit
Jun 29 2016 03:50
@x981 In chrome to get lat and long you can use http://ip-api.com/json if your page has to be http (which it does if you are using the free openweather which has to use http)
96street
@96street
Jun 29 2016 03:50
Can someone explain what 'action', 'search', 'format' and 'callback' are in this URL? Is there are name for what they are? http://en.wikipedia.org/w/api.php/action=opensearch&search=userSearch&format=json&callback=wikiCallback
x981
@x981
Jun 29 2016 03:52
@GregatGit But i want to get weather infomation?
@x981 yes but you need the lat and long of the local user
This message was deleted
friesenet21
@friesenet21
Jun 29 2016 03:53
function mutation(arr) {
    arr = arr[0].toLowerCase().split('').sort().join('').indexOf(arr[1].toLowerCase().split('').sort().join('')) !== -1;


  return arr;
}

mutation(["hello", "hey"]);
x981
@x981
Jun 29 2016 03:54
@GregatGit i've got long and lat, Now, i get weather info
Bnobo
@acloud12345678
Jun 29 2016 03:54
I need help on the challenge "Storing Values with the Assignment Operator"
can somebody help me?
please
x981
@x981
Jun 29 2016 03:55
But it required "https" not "http"
Santiago Gómez
@Sperkajugglite
Jun 29 2016 03:55
@acloud12345678 i can
Greg Duncan
@GregatGit
Jun 29 2016 03:55
@x981 can i see your pen
@x981 I had the same problem
Santiago Gómez
@Sperkajugglite
Jun 29 2016 03:55
@acloud12345678 whats your problem?
96street
@96street
Jun 29 2016 03:55
except for action i'm not sure what exactly that does and what other values it can take (query etc)
x981
@x981
Jun 29 2016 03:56
@GregatGit Here you are: https://codepen.io/x981/pen/JKWWjb
Santiago Gómez
@Sperkajugglite
Jun 29 2016 03:56
@acloud12345678 ??
Greg Duncan
@GregatGit
Jun 29 2016 03:56
@96street you can use this for wiki - just change the search
x981
@x981
Jun 29 2016 03:57
@GregatGit if change that link by "https" link then nothing problem
friesenet21
@friesenet21
Jun 29 2016 03:57
am I missing a method?
96street
@96street
Jun 29 2016 03:58
@GregatGit yes I know I'm doing the wiki challenge so i'll use this, i'm just not sure what 'action' is
Greg Duncan
@GregatGit
Jun 29 2016 03:58
@96street don't worry for now
96street
@96street
Jun 29 2016 03:59
Ok I won't
Bnobo
@acloud12345678
Jun 29 2016 03:59
Can somebody help me with "Understanding Uninitialized Variables" please?
Greg Duncan
@GregatGit
Jun 29 2016 03:59
@96street I got stuck for ages trying to figure out the wiki until someone gave me a api string
x981
@x981
Jun 29 2016 04:00
@GregatGit Where is problem?
kevlozano
@kevlozano
Jun 29 2016 04:01
Hey guys im having trouble with the this challenge: "Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed."
Greg Duncan
@GregatGit
Jun 29 2016 04:01
@x981 it gives me the weather in a different city
kevlozano
@kevlozano
Jun 29 2016 04:02

this is my code:" function nextInLine(arr, item) {
// Your code here
testArr.push(item);
testArr.shift(0);

return testArr.shift(0); // Change this line
}"

Idk how to return the element that was removed

Greg Duncan
@GregatGit
Jun 29 2016 04:02
@acloud12345678 can you put up what you have done so far
pahosler
@pahosler
Jun 29 2016 04:03
@friesenet21 that's a cool chain! My own code for that challenge was much more verbose :D
x981
@x981
Jun 29 2016 04:03
Thanks @GregatGit
CamperBot
@camperbot
Jun 29 2016 04:03
x981 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 629 | @gregatgit |http://www.freecodecamp.com/gregatgit
ALMY91
@ALMY91
Jun 29 2016 04:04
```js
(function(x){
var square=x*x; 
return square; 
}());
hi guys how do i get this to work?
Bnobo
@acloud12345678
Jun 29 2016 04:04
Can somebody help me with "Understanding Case Sensitivity in Variables"
Please?
Santiago Gómez
@Sperkajugglite
Jun 29 2016 04:04
yes
wait
Justin Dado
@rene-justin-dado
Jun 29 2016 04:05

So close. :/

function titleCase(str) {
  spaced = str.replace(/\s/g, '  ');
  sub = spaced.toLowerCase().split(/\s/);
  var upperSub = [];

  for (i = 0; i < sub.length; i++) {
    upperSub += sub[i].replace(/^\w/, function(match) {
        return match.toUpperCase();
    });
  }
  return upperSub;  
}

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

It's returning I'mALittleTeaPot

Greg Duncan
@GregatGit
Jun 29 2016 04:05
@acloud12345678 var help; is not var Help;
Santiago Gómez
@Sperkajugglite
Jun 29 2016 04:05
@acloud12345678 just change each variable to look like this:
ThisVariable
Bnobo
@acloud12345678
Jun 29 2016 04:05
ok thank you very much!
Santiago Gómez
@Sperkajugglite
Jun 29 2016 04:06
sorry, "thisVariable"
Bnobo
@acloud12345678
Jun 29 2016 04:06
ok
Santiago Gómez
@Sperkajugglite
Jun 29 2016 04:06
no problem
x981
@x981
Jun 29 2016 04:09
@GregatGit , In weather info, "temp":285.68 => I don't know how many degree?
ALMY91
@ALMY91
Jun 29 2016 04:11
sigh nvm
i figured it out alr
pahosler
@pahosler
Jun 29 2016 04:12
@rene-justin-dado return match.toUpperCase().join(' ');
Greg Duncan
@GregatGit
Jun 29 2016 04:14
@x981 that would have to be 28.5
Justin Dado
@rene-justin-dado
Jun 29 2016 04:15
@pahosler I'll try that out. Thanks!
CamperBot
@camperbot
Jun 29 2016 04:15
rene-justin-dado sends brownie points to @pahosler :sparkles: :thumbsup: :sparkles:
:cookie: 261 | @pahosler |http://www.freecodecamp.com/pahosler
Nick Irvine
@irvin3
Jun 29 2016 04:15
could someone please take a look at my code and tell me if they have anyclue why the if statement that controls switching between Fahrenheit and Celsius will only run once? i may be missing some obvious detail about if statements
      var tempSwitch = false;
    $("#fTemp").click(function(){
      if(tempSwitch === false){
        $("#fTemp").html(cTemp + " &#8451");
        tempSwitch = true;
      }
      else{
        ("#fTemp").html(fTemp+ " &#8457");
        tempSwitch = false;
      }

    });
I can post my codepen too if that would help
kevlozano
@kevlozano
Jun 29 2016 04:17
can someone help me with the Stand in Line challenge?
Nick Irvine
@irvin3
Jun 29 2016 04:19
nvm, weird how you debug yourself once you post a question haha
Greg Duncan
@GregatGit
Jun 29 2016 04:21
@irvin3 can I see your pen?

@irvin3 also

if (tempSwitch)
or
if(!tempSwitch)

you don't need the === false or true

@irvin3 does .html(cTemp + " &#8451"); change what you can now click on?
Bnobo
@acloud12345678
Jun 29 2016 04:30
Can you help me in "Converting Celcius to Fareignheit"
Can you help me in "Converting Celcius to Fareignheit"
Joseph
@revisualize
Jun 29 2016 04:32
I got 30min to help. Sup.
@kevlozano I can.
@acloud12345678 I can.
@kevlozano
// Write a function nextInLine which takes 
// an array (arr) and a number (item) as arguments.
function nextInLine(arr, item) {
    // Add the number to the end of the array,

   // then remove the first element of array.
    // The nextInLine function should 
    // then return the element that was removed.
    return item; // Change this line
}
Justin Woodward
@jwoo92
Jun 29 2016 04:32
@GregatGit hey how have you been?
Joseph
@revisualize
Jun 29 2016 04:33
@acloud12345678 What is the mathematical formula for turning Celsius to Fahrenheit?
Joseph
@revisualize
Jun 29 2016 04:35
@GregatGit Okay. I was asking @acloud12345678 because of :point_up: June 28, 2016 9:30 PM
Greg Duncan
@GregatGit
Jun 29 2016 04:35
@jwoo92 I'm good - have you been to central or south America
@revisualize Ha! Sorry about that - you looked really lazy for moment!
Justin Woodward
@jwoo92
Jun 29 2016 04:37
i am having some trouble solving the 'Spinal tap case' algorithm challenge. i have everything sorted out except being able to get a - inbetween a string such as in my code. i understand my if statement is registering undefined due to the fact if str[i].toLowerCase() or str[i+1].toUpperCase() will result undefined if the letter is already the proper casing. here is what i have:

function spinalCase(str) {

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

    if( str[i] == str[i].toLowerCase() && str[i+1] == str[i+1].toUpperCase()) {
      str.split('').splice(i, 0, ' ').join('');    
    } 
  }
    console.log(str);
  str = str.replace(/\s/g, '-').replace(/_/g, '-').toLowerCase();

  return str;
}

spinalCase('ThisIsSpinalTap');
Wan Jong Kim
@wanjongkim
Jun 29 2016 04:37
J
Justin Woodward
@jwoo92
Jun 29 2016 04:38
@GregatGit thats great. i have, i actually just returned from a trip to mexico. why do you ask?
Greg Duncan
@GregatGit
Jun 29 2016 04:38
@jwoo92 You have a priamid in the background
Justin Woodward
@jwoo92
Jun 29 2016 04:39
@GregatGit i almost forgot i changed that. i visited it while i was in mexico. it was a great experience.
Greg Duncan
@GregatGit
Jun 29 2016 04:39
@jwoo92 keep it - looks awesome
Justin Woodward
@jwoo92
Jun 29 2016 04:39
@GregatGit thanks i love it as well!
CamperBot
@camperbot
Jun 29 2016 04:39
jwoo92 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 630 | @gregatgit |http://www.freecodecamp.com/gregatgit
Syah Hakam Ibrahim
@h4km
Jun 29 2016 04:40
test comment
Greg Duncan
@GregatGit
Jun 29 2016 04:40
@jwoo92 what output are you getting
purnendutiwari
@purnendutiwari
Jun 29 2016 04:41
need help with ceaser cipher challenge:

function rot13(str) { // LBH QVQ VG!
  var nstr="";
  for(var i=0;i<str.length;i++){
    var charCodeAtI=str.charCodeAt(i);
    if(charCodeAtI<65|charCodeAtI>90){
      nstr+=str[i];
      console.log("else:"+str[i]);
    }
    else{

      console.log(charCodeAtI+":"+str[i]+":"+String.fromCharCode(((charCodeAtI-64+13)%26)+64));

    }

  }
  return nstr;
}

// Change the inputs below to test
rot13("SERR CVMMN!");
Justin Woodward
@jwoo92
Jun 29 2016 04:41
@GregatGit cannot read property 'touppercase' of undefined
purnendutiwari
@purnendutiwari
Jun 29 2016 04:41
@jwoo92 it is toUpperCase
Justin Woodward
@jwoo92
Jun 29 2016 04:42
@purnendutiwari i know, i was responding in a sense for showing what the console log was saying. thanks though for trying to help out :)
CamperBot
@camperbot
Jun 29 2016 04:42
jwoo92 sends brownie points to @purnendutiwari :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @purnendutiwari |http://www.freecodecamp.com/purnendutiwari
purnendutiwari
@purnendutiwari
Jun 29 2016 04:43
:|
@jwoo92
Greg Duncan
@GregatGit
Jun 29 2016 04:44
@jwoo92 try split(' ') them at the start
Justin Woodward
@jwoo92
Jun 29 2016 04:44
@GregatGit i also took this approach and resulted with 'ThisIsSpinalTap'. i am trying to get it to result 'this-is-spinal-tap'.

function spinalCase(str) {

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

    if( str[i].toLowerCase() === undefined && str[i+1].toUpperCase() === undefined) {
      str.split('').splice(i, 0, ' ').join('');    
    } 
  }
    console.log(str);
  str = str.replace(/\s/g, '-').replace(/_/g, '-').toLowerCase();

  return str;
}

spinalCase('ThisIsSpinalTap');
Greg Duncan
@GregatGit
Jun 29 2016 04:45
@jwoo92 before you split replace " " (a space) with "-"
@jwoo92 i did similar to what you did but at the start repaced all " " and "_" with "-" then I split it
Justin Woodward
@jwoo92
Jun 29 2016 04:47
@GregatGit no luck. with the inital if statement i have setup. it would put in spaces in which my regex would replace with the -. i have it setup like that because a few other sentences require that approach and it just made it easier for me to take the approach im going after.
@GregatGit everything else is checking out good on my challenge. i am just failing on the sentences which require a dash between a lowercase and uppercase letter

spinalCase("thisIsSpinalTap") should return "this-is-spinal-tap".
spinalCase("AllThe-small Things") should return "all-the-small-things".

these are the only ones failing for reference.

purnendutiwari
@purnendutiwari
Jun 29 2016 04:48

need help with ceaser cipher challenge:


function rot13(str) { // LBH QVQ VG!
  var nstr="";
  for(var i=0;i<str.length;i++){
    var charCodeAtI=str.charCodeAt(i);
    if(charCodeAtI<65|charCodeAtI>90){
      nstr+=str[i];
    }
    else{

      console.log(charCodeAtI+":"+str[i]+":"+String.fromCharCode(((charCodeAtI-64+13)%26)+64));

    }

  }
  return nstr;
}

// Change the inputs below to test
rot13("SERR CVMMN!");

my code skip al

Justin Woodward
@jwoo92
Jun 29 2016 04:49
the second one i am only concerned on the all and the part. the rest checks out fine
@purnendutiwari that was a trickier one of the basic algs if that makes you feel any better.
@GregatGit i am not fully understanding what you are talking about here 'before you split replace " " (a space) with "-"'
purnendutiwari
@purnendutiwari
Jun 29 2016 04:50
@jwoo92 tjanks, i am getting it almost correct
thanks*
i just want to code it efficiently
Bnobo
@acloud12345678
Jun 29 2016 04:52
Guys, I want to know how to make coding even more fun than I already think it is.
Fernand
@Ferdyboy81
Jun 29 2016 04:52
hi guys!
how can i turn this into strings?
var allPets = function(kitties, puppies)
Greg Duncan
@GregatGit
Jun 29 2016 04:53
@jwoo92 at the very start I made swapped all spaces " " and underscores "_" with dashes "-" using replace
Sergey
@altvec
Jun 29 2016 04:53
Hi everyone!
Joaquin Toral
@joaquintoral
Jun 29 2016 04:55
switch(seatRow) {
                            case 1: 
                                switch(seatColumn) {
                                    case 1:
                                        $(".quadrant-"+quadrant+" .row-1 .col-1 p:first").text(seatId);
                                        $(".quadrant-"+quadrant+" .row-1 .col-1 p:nth-child(2)").text(usersList[key].lastName+", "+usersList[key].firstName);
                                        break;
                                    case 2:
                                        $(".quadrant-"+quadrant+" .row-1 .col-2 p:first").text(seatId);
                                        $(".quadrant-"+quadrant+" .row-1 .col-2 p:nth-child(2)").text(usersList[key].lastName+", "+usersList[key].firstName);
                                        break;
                                    case 3:
                                        $(".quadrant-"+quadrant+" .row-1 .col-3 p:first").text(seatId);
                                        $(".quadrant-"+quadrant+" .row-1 .col-3 p:nth-child(2)").text(usersList[key].lastName+", "+usersList[key].firstName);
                                        break;
                                    default:
                                        break;
                                }

                            case 2: 
                                switch(seatColumn) {
                                    case 1:
                                        console.log(seatRow);
                                        $(".quadrant-"+quadrant+" .row-2 .col-1 p:first").text(seatId);
                                        $(".quadrant-"+quadrant+" .row-2 .col-1 p:nth-child(2)").text(usersList[key].lastName+", "+usersList[key].firstName);
                                        break;
                                    case 2:
                                        $(".quadrant-"+quadrant+" .row-2 .col-2 p:first").text(seatId);
                                        $(".quadrant-"+quadrant+" .row-2 .col-2 p:nth-child(2)").text(usersList[key].lastName+", "+usersList[key].firstName);
                                        break;
                                    case 3:
                                        $(".quadrant-"+quadrant+" .row-2 .col-3 p:first").text(seatId);
                                        $(".quadrant-"+quadrant+" .row-2 .col-3 p:nth-child(2)").text(usersList[key].lastName+", "+usersList[key].firstName);
                                        break;
                                    default:
                                        break;
                                }
                            default:
                                break;
                        }
Greg Duncan
@GregatGit
Jun 29 2016 04:56
@jwoo92 try this link https://codeshare.io/wFsSu
Justin Woodward
@jwoo92
Jun 29 2016 04:56
@GregatGit oh okay. yeah i have that working. the only thing i am having trouble with is splitting this ThisIsSpinalTap at the last lowercase letter in each work and before the next word with the uppercase letter and splicing in a whitespace so afterwords my regex will take of the space for a dash.
Joaquin Toral
@joaquintoral
Jun 29 2016 04:56
What's wrong with my switch statement? It's changing the value of case one of case 2 as well of the first switch statement. when my seatrow is 1 and column is 1 as well?
AnshulDawar
@anshuldawar
Jun 29 2016 04:58
function myLocalScope() {
var myVar='use strict';
console.log(myVar);
}
myLocalScope();
Justin Woodward
@jwoo92
Jun 29 2016 04:58
@GregatGit i even tried this and it only failed at (str[i+1] === str[i+1].toUpperCase()) === true saying 'TypeError {message: "Cannot read property 'toUpperCase' of undefined"}'.

function spinalCase(str) {

  console.log(str[4] === str[4].toUpperCase());

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

    if( (str[i] === str[i].toLowerCase()) === true && (str[i+1] === str[i+1].toUpperCase()) === true) {
      str.split('').splice(i, 0, ' ').join('');    
    } 
  }
    console.log(str);
  str = str.replace(/\s/g, '-').replace(/_/g, '-').toLowerCase();

  return str;
}

spinalCase('ThisIsSpinalTap');
Greg Duncan
@GregatGit
Jun 29 2016 04:59
@jwoo92 its a bit hard to read
Justin Woodward
@jwoo92
Jun 29 2016 04:59
@GregatGit i prematurely clicked the enter button, sorry about that.
@GregatGit the failing part would be the same as (str[4] === str[4].toUpperCase()) === true to help clarify which character.
1ety
@1ety
Jun 29 2016 05:01
5! = 1 2 3 4 5 = 120
why for(var i=1; i<count; i++){
and not for(var i=1; i< =count; i++)
Sergey
@altvec
Jun 29 2016 05:01

Can someone please help me with twitch API challenge? So far I’ve done this:

var users = ['ESL_SC2',
             'OgamingSC2',
             'cretetion',
             'freecodecamp',
             'storbeck',
             'habathcx',
             'RobotCaleb',
             'noobs2ninjas',
             'brunofin',
             'comster404'],
    baseURL = 'https://api.twitch.tv/kraken';

var result = getUsersInfo(users, baseURL);
result.forEach(function(o) {
  console.log(o.name);
});

function getUsersInfo(_users, _URL) {
  var arr = []; // array of objects
  _users.forEach(function(u) {
    var info = {}; // temporary object
    $.getJSON(_URL + '/users/' + u + '?callback=?').success(function(data) {
      info.name = data.display_name;
      data.logo === null ? info.logo = 'PLACEHOLDER' : info.logo = data.logo;
      info.url = 'https://twitch.tv/' + data.name;

      $.getJSON(_URL + '/streams/' + u + '?callback=?').success(function(data) {
        info.active = true;
        if (data.stream === null) {
          info.status = 'Offline';
        } else if (data.status === 422) {
          info.status = 'Offline';
          info.active = false;
        } else {
          info.status = "Online";
          info.game = data.stream.game;
          info.channel_status = data.stream.channel.status;
        };
      });
    });
    arr.push(info);
  });
  return arr;
}

I can’t figure out why I can’t access object property here:

result.forEach(function(o) {
  console.log(o.name); // returns undefined
});
Z.G.Hao
@akidox
Jun 29 2016 05:02
challenge #invert regular expression matches with JavaScript,why the \S doesn’t need a + sign to be /\S+/g?
Justin Woodward
@jwoo92
Jun 29 2016 05:04
@purnendutiwari have you gotten it yet? if not, i will take a look over it for you.
Gyeognphil Choi
@creativeworkers10
Jun 29 2016 05:07
``js
js

``js

// Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;

// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;
``

Markus Kiili
@Masd925
Jun 29 2016 05:08
This message was deleted
Gyeognphil Choi
@creativeworkers10
Jun 29 2016 05:08
I don't quiet understand about CamelCase, I put many things but I can't solve this problem,
purnendutiwari
@purnendutiwari
Jun 29 2016 05:08
@jwoo92 got it, thanks
CamperBot
@camperbot
Jun 29 2016 05:08
purnendutiwari sends brownie points to @jwoo92 :sparkles: :thumbsup: :sparkles:
:cookie: 360 | @jwoo92 |http://www.freecodecamp.com/jwoo92
Justin Woodward
@jwoo92
Jun 29 2016 05:10
@GregatGit i think this [i+1] might be why it is saying this: TypeError {message: "Cannot read property 'toUpperCase' of undefined"}. once i take the '+1' out, it will perform, but i need it to be one character more than i for that to select the correct letter. i even trying creating a var saying ex: var example = i+1; then trying (str[example] === str[example].toUpperCase()) === true. itll still output:TypeError {message: "Cannot read property 'toUpperCase' of undefined"}.
@purnendutiwari awesome man, congrats! how long did it take you?
purnendutiwari
@purnendutiwari
Jun 29 2016 05:11
@jwoo92 may be 2hrs,
actually i was trying to do minimum code possible
Markus Kiili
@Masd925
Jun 29 2016 05:11
@altvec getUsersInfo returns arr and you loop its contents before getJSON callbacks put stuff into it.
purnendutiwari
@purnendutiwari
Jun 29 2016 05:12
but couldn't @jwoo92 at the end :P
Justin Woodward
@jwoo92
Jun 29 2016 05:12
@GregatGit this did not work either by declaring two variables in my for loop:

function spinalCase(str) {

  console.log((str[3] === str[3].toUpperCase()) === true);

  for (var i = 0, u = 1; i < str.length, u <= str.length; i++, u++) {

    if( (str[i] === str[i].toLowerCase()) === true && (str[u] === str[u].toUpperCase()) === true) {
      str.split('').splice(i, 0, ' ').join('');    
    } 
  }

  str = str.replace(/\s/g, '-').replace(/_/g, '-').toLowerCase();

  return str;
}

spinalCase('ThisIsSpinalTap');
@purnendutiwari well lets see the end result after all that hard work :)
njwda
@njwda
Jun 29 2016 05:13
Hi there guys, can I get a little help with this one "Replacing If Else Chains with Switch".... here comes the code:

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

switch (val){
case val ==="bob":
answer="Marley";
break;

   case val === 42:
  answer="The Answer";
  break;

      case val === 1:
  answer="There is no #1";
  break;

      case val === 99:
  answer="Missed me by this much!";
  break;
      case val === 7:
  answer="Ate Nine";

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

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

96street
@96street
Jun 29 2016 05:14
Can someone tell me why my Wiki Viewer isn't working (appending search results)? http://codepen.io/kingdezz/pen/yJgoNN?editors=1010
Justin Ober
@0b3r
Jun 29 2016 05:14
@njwda dont put === for the cases
purnendutiwari
@purnendutiwari
Jun 29 2016 05:15
@jwoo92
please if you can suggest any improvement

function rot13(str) { // LBH QVQ VG!
  var nstr="";
  for(var i=0;i<str.length;i++){
    var charCodeAtI=str.charCodeAt(i);
    if(charCodeAtI<65|charCodeAtI>90){
      nstr+=str[i];
    }
    else{
      var shiftedChar=charCodeAtI+13;
      if(shiftedChar>90){
        nstr+=(String.fromCharCode(shiftedChar-26));
      }
      else{
        nstr+=(String.fromCharCode(shiftedChar));
      }
    }
  }
  return nstr;
}

// Change the inputs below to test
rot13("SERR CVMMN!");
Justin Ober
@0b3r
Jun 29 2016 05:16
switch(val){
     case 1:
          //expression
     break;
}
Justin Woodward
@jwoo92
Jun 29 2016 05:17
@purnendutiwari here is how i completed it:

function rot13(str) { // LBH QVQ VG!

  function deCode(char) {
    if (char.charCodeAt(0) - 13 < 65) {
       return String.fromCharCode(91 -(65 - (char.charCodeAt(0) - 13)));
    } else {
       return String.fromCharCode(char.charCodeAt(0) - 13);
    }
  }

  return str.replace(/[A-Z]/g, deCode);
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
njwda
@njwda
Jun 29 2016 05:17
@0b3r thanks for the tip bro, but Stilll I can't get pass that one :'c
CamperBot
@camperbot
Jun 29 2016 05:17
njwda sends brownie points to @0b3r :sparkles: :thumbsup: :sparkles:
:cookie: 318 | @0b3r |http://www.freecodecamp.com/0b3r
Justin Ober
@0b3r
Jun 29 2016 05:18
which problem is it?
Eligijus Karčiauskas
@bICEQ
Jun 29 2016 05:18
can anyone give me a good link to javascript exercizes for begginers? :) thanks
Justin Woodward
@jwoo92
Jun 29 2016 05:18
@purnendutiwari similar in logic, i shortened mine just a bit if it helps you to compare :)
Markus Kiili
@Masd925
Jun 29 2016 05:18
@purnendutiwari Another way is to use .map() and remainder:
function rot13(str) {
  return str.split("").map(function(char){
      var cc = char.charCodeAt(0);
      return (cc>64 && cc<91) ? String.fromCharCode(cc%26+65) : char;
  }).join("");
}
The same could be done with .replace() too.
Justin Ober
@0b3r
Jun 29 2016 05:20
@Masd925 map works fine however it requires a split and then a join. @jwoo92 i agree with using string replace with regex. It has the looping over string chars built in
JakAttak2017
@JakAttak2017
Jun 29 2016 05:20
Hey guys I've been stuck on "Profile Lookup" for like 3 days. I just don't get it at all. Anyone feel like giving me some help?
purnendutiwari
@purnendutiwari
Jun 29 2016 05:21
@Masd925 thank looks compact
CamperBot
@camperbot
Jun 29 2016 05:21
purnendutiwari sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1997 | @masd925 |http://www.freecodecamp.com/masd925
Justin Ober
@0b3r
Jun 29 2016 05:21
@purnendutiwari your solution gets the job done but this is a short version if you are interested
function rot13(str) { // LBH QVQ VG!

  return str.replace(/[a-z]/gi,
    function(char){
      var newChar = char.charCodeAt(0) + 13;
      return String.fromCharCode((90 >= newChar) ? newChar : newChar - 26);
    });
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
@JakAttak2017 can you post your code plz?
purnendutiwari
@purnendutiwari
Jun 29 2016 05:24
@0b3r thanks, I will need to study replace for this
CamperBot
@camperbot
Jun 29 2016 05:24
purnendutiwari sends brownie points to @0b3r :sparkles: :thumbsup: :sparkles:
:cookie: 319 | @0b3r |http://www.freecodecamp.com/0b3r
Justin Ober
@0b3r
Jun 29 2016 05:25
@purnendutiwari replace is super useful for string mutation. Essentially you give it some regex (in this case find all chars between a-z) and then a function to replace it with. Thats pretty much the gist
96street
@96street
Jun 29 2016 05:28
It's cause I already had one I was using @GregatGit
What's wrong with the one I have now compared to that one?
Justin Ober
@0b3r
Jun 29 2016 05:28
@purnendutiwari also the last part in the return is just a ternary operator (you may or may not be familiar with it). If you are not it is basically an if else ```
'if this' ? 'then this' : 'else this'
purnendutiwari
@purnendutiwari
Jun 29 2016 05:29
i got the "ternary operator"
does replace takes one character at a time?
Justin Ober
@0b3r
Jun 29 2016 05:29
yes
well.... its one match at a time
boruchwoolstone
@boruchwoolstone
Jun 29 2016 05:30
how can i post a pic with my code like evryone is doing?
Justin Ober
@0b3r
Jun 29 2016 05:30
considering the regex could match word or whatever else
Markus Kiili
@Masd925
Jun 29 2016 05:30
explain format
CamperBot
@camperbot
Jun 29 2016 05:30

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

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

purnendutiwari
@purnendutiwari
Jun 29 2016 05:31
@0b3r yup got it, thanks again
CamperBot
@camperbot
Jun 29 2016 05:31
purnendutiwari sends brownie points to @0b3r :sparkles: :thumbsup: :sparkles:
:warning: purnendutiwari already gave 0b3r points
Justin Ober
@0b3r
Jun 29 2016 05:31
@purnendutiwari no problem! happy coding
Sandeep Kumar
@wdsandeep
Jun 29 2016 05:31
hi
can anyone help
purnendutiwari
@purnendutiwari
Jun 29 2016 05:32
@0b3r :smile:
Greg Duncan
@GregatGit
Jun 29 2016 05:32
@96street not sure - but I meant to give you this one
Sandeep Kumar
@wdsandeep
Jun 29 2016 05:32
what i did is var myStr = "\"Here is a backslash:\.\n\t\tHere is a new line with two tabs.\""; // Change this lin
Kimberly Pennington
@kimberlythegeek
Jun 29 2016 05:32
for anyone who has completed "Steamroller"... did you use recursion?
boruchwoolstone
@boruchwoolstone
Jun 29 2016 05:33
var myStr = "here is a backslash\\n\t\t Here is a new line wiht two tabs";
shoudl look like that Sandeep
96street
@96street
Jun 29 2016 05:34
Do I need to know what any of the parameters mean apart from 'search'? @GregatGit
boruchwoolstone
@boruchwoolstone
Jun 29 2016 05:34
there shoudl be 3 \ before the n
not twoo
Sandeep Kumar
@wdsandeep
Jun 29 2016 05:34
ok i do try
Justin Ober
@0b3r
Jun 29 2016 05:34
@boruchwoolstone yes i used recursion
boruchwoolstone
@boruchwoolstone
Jun 29 2016 05:34
This message was deleted
This message was deleted
This message was deleted
Greg Duncan
@GregatGit
Jun 29 2016 05:35
@96street no - I used it in
$.getJSON(url, function(data){
    console.log(data);
}
boruchwoolstone
@boruchwoolstone
Jun 29 2016 05:36
can any one help me wiht this https://www.freecodecamp.com/challenges/record-collection#?solution=%0A%2F%2F%20Setup%0Avar%20collection%20%3D%20%7B%0A%20%20%20%20%222548%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%222468%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%221999%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%221245%22%3A%20%7B%0A%20%20%20%20%20%20%22artist%22%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%225439%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22ABBA%20Gold%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%5B%5D%0A%20%20%20%20%7D%0A%7D%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse(JSON.stringify(collection))%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20updateRecords(id%2C%20prop%2C%20value)%20%7B%0Avar%20property%20%3D%20prop%3B%0Avar%20ident%20%3D%20id%3B%0Avar%20val%20%3D%20value%3B%0Aif%20(property%20!%3D%20%22tracks%22%20%26%26%20value%20!%3D%3D%22%22)%20%7B%0A%20%20%20%20collection%5Bident%5D.artist%20%3D%20val%3B%0A%7D%0A%20%20%0Aelse%20if%20(collection%5Bident%5D.hasOwnProperty(%22tracks%22))%20%7B%0A%20%20collection%5Bident%5D.tracks.push(val)%3B%0A%20%20%0A%7D%0A%20%20%0Aelse%20if%20(val%20!%3D%3D%20%22%22)%20%7B%0A%20%20%20collection%5Bident%5D.tracks%20%3D%20%5Bval%5D%3B%0A%7D%0A%20%20%0Aelse%20if(prop%20%3D%3D%20%22artist%22%20%26%26%20val%20%3D%3D%3D%20%22%22)%7B%0A%20delete%20collection%5Bid%5D.artist%3B%0A%7D%0A%20%20%0A%0A%20%20return%20collection%3B%0A%7D%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0AupdateRecords(5439%2C%20%22artist%22%2C%20%22%22)%3B%0A%0A
Markus Kiili
@Masd925
Jun 29 2016 05:36
@kimberlythegeek There are also non-recursive solutions, but recursion is the usual way.
Kimberly Pennington
@kimberlythegeek
Jun 29 2016 05:37
@Masd925 yeah, I figured. thanks :)
CamperBot
@camperbot
Jun 29 2016 05:37
kimberlythegeek sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1998 | @masd925 |http://www.freecodecamp.com/masd925
96street
@96street
Jun 29 2016 05:37
@GregatGit sweet
endlessetudes
@endlessetudes
Jun 29 2016 05:38
Hey everyone. Is there anyone here who could help with "Wherefore art thou"?
Sergey
@altvec
Jun 29 2016 05:38
@Masd925 I thought that due to functions hoisting array will be filled with objects when I loop over it...
96street
@96street
Jun 29 2016 05:38
Do you know why my search appending isn't working?
@GregatGit
Greg Duncan
@GregatGit
Jun 29 2016 05:40
@96street i would put var userInput = $('#searchText').val(); on line 17
96street
@96street
Jun 29 2016 05:41
done
Markus Kiili
@Masd925
Jun 29 2016 05:41
@altvec You bind callback functions to ajax responses, which come after your function call and loop execute. You could do the work on callback function, where you know the response has come.
Sandeep Kumar
@wdsandeep
Jun 29 2016 05:42
endlessetudes
@endlessetudes
Jun 29 2016 05:44
i will just post in case someone can push me in the right direction. i've solved for if the source only contains one object
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];

  // Only change code below this line
  var prop = Object.keys(source);
  //console.log("prop: " + prop);
  var val = source[prop];
  //console.log("val: " + val);
  for(var i = 0; i < collection.length; i++){
    if(collection[i].hasOwnProperty(prop) && collection[i][prop] === val){
      arr.push(collection[i]);
    }
  }
Sergey
@altvec
Jun 29 2016 05:49
@Masd925 ahh, ok. Thanks a lot!
CamperBot
@camperbot
Jun 29 2016 05:49
altvec sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1999 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 29 2016 05:49
@endlessetudes You need to loop or iterate source key array inside the collection loop.
That way you can test that the property values match for all the source keys.
endlessetudes
@endlessetudes
Jun 29 2016 05:52
@Masd925 got it. i'll give it a go.
Markus Kiili
@Masd925
Jun 29 2016 05:53
@endlessetudes If you used proper methods like .filter and .every instead of loops, the code would be very compact.
Sandeep Kumar
@wdsandeep
Jun 29 2016 05:54
Please help me anyone https://www.freecodecamp.com/challenges/escape-sequences-in-strings - give me the solution
Kimberly Pennington
@kimberlythegeek
Jun 29 2016 05:54
so..... is there a way to reset my code on a problem if I can't load the page without the browser crashing?
Markus Kiili
@Masd925
Jun 29 2016 05:55
help autorun
CamperBot
@camperbot
Jun 29 2016 05:55

:point_right: freecodecamp disable code autorun [wiki]

Disable Code Auto Run on Free Code Camp

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

:pencil: read more about freecodecamp disable code autorun on the FCC Wiki

Kimberly Pennington
@kimberlythegeek
Jun 29 2016 05:55
I was attempting a recursive algorithm... and I broke it :cry:
@masd925 ahh thank you
Smitesh Mangelkar
@msmitesh
Jun 29 2016 05:56
After updateRecords(2548, "artist", ""), artist should not be set
how to do this one
challenge 211
Sandeep Kumar
@wdsandeep
Jun 29 2016 05:59
Please help me anyone https://www.freecodecamp.com/challenges/escape-sequences-in-strings - give me the solution
Anirudha Kasralikar
@akasralikar
Jun 29 2016 06:00
@wdsandeep try something like below
var myStr = "Here is a backslash: \.\n\t\tHere is a new line with two tabs.";
so \ will represent backslash
\\
Sandeep Kumar
@wdsandeep
Jun 29 2016 06:01
@akasralikar i am doing this
var myStr = "\"Here is a backslash:\.\n\t\tHere is a new line with two tabs.\"";
but its not working. Your solution also not working
Anirudha Kasralikar
@akasralikar
Jun 29 2016 06:01
no need to escape quotes
Sandeep Kumar
@wdsandeep
Jun 29 2016 06:01
ok
Anirudha Kasralikar
@akasralikar
Jun 29 2016 06:01
var myStr = "Here is a backslash: \\.\n\t\tHere is a new line with two tabs.";
Sandeep Kumar
@wdsandeep
Jun 29 2016 06:02
Thankx @akasralikar now its working.
CamperBot
@camperbot
Jun 29 2016 06:02
wdsandeep sends brownie points to @akasralikar :sparkles: :thumbsup: :sparkles:
:cookie: 181 | @akasralikar |http://www.freecodecamp.com/akasralikar
Markus Kiili
@Masd925
Jun 29 2016 06:02
@msmitesh You should delete the property if value is ===""
DevSplinter
@DevSplinter
Jun 29 2016 06:04
Hello!
I've a problem with profile lookup checkpoint.
for(var i=0; i<contacts.length; i++){
    if(contacts[i].firstName == firstName){
      if(contacts[i].hasOwnProperty(prop)){
        return contacts[i][prop];
      }else{
      return "no such property";
     }
    }else{
      return "No such contact";
    }
  }
Markus Kiili
@Masd925
Jun 29 2016 06:06
@DevSplinter Your code can return no such contact after checking one contact.
You should always use strict equality === and !==.
DevSplinter
@DevSplinter
Jun 29 2016 06:14
hmmm... it work better, but still I've errors:
 var answer;
 for(var i=0; i<contacts.length; i++){
    if(contacts[i].firstName === firstName){
      if(contacts[i].hasOwnProperty(prop)){
        answer =  contacts[i][prop];
      }else{
      answer = "no such property";
     }
    }else{
      answer = "No such contact";
    }
  }

  return answer;
Markus Kiili
@Masd925
Jun 29 2016 06:15
@DevSplinter Don't use answer. Just put the last return on correct spot.
Nathaniel Nasarow
@Torgian
Jun 29 2016 06:20
hey guys
any idea how I can use openweatherdata over a secure origin so I can use HTML location data? The other options out there (ip-api for instance) are very inaccurate
My location stuff works on Safari but not Chrome
rozesn
@rozesn
Jun 29 2016 06:26
hello everyone - can someone guide me for word blanks?
Evgueni
@Redoras
Jun 29 2016 06:26
Not sure why the data.name is not showing in the list: http://codepen.io/RedCone/pen/vKgYjW?editors=1011
mwandama
@mwandama
Jun 29 2016 06:26
I don't know what they want me to do. I was told create a variable called myData and take the values from myArray. this what i did var myData =[1,2,3]; so this correct. I don't understand what they mean when they say The data in viariable should be accessed using bracktes how i can i do that
Evgueni
@Redoras
Jun 29 2016 06:26
@rozesn word blanks?
rozesn
@rozesn
Jun 29 2016 06:27

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");

@Redoras
mwandama
@mwandama
Jun 29 2016 06:27
read my question please
DevSplinter
@DevSplinter
Jun 29 2016 06:27

@Masd925

 for(var i=0; i<contacts.length; i++){
    if(contacts[i].firstName === firstName){
      if(contacts[i].hasOwnProperty(prop)){
        return contacts[i][prop];
      }else{
        return "no such property";
      }
    }
  }
  return "No such contact";

I still get an error though
lookUpProfile("Akira", "adress");
returned no such property

Evgueni
@Redoras
Jun 29 2016 06:28
@mwandama you use brackets with the index number to access the values like so: myData[0] will equal 1
kirbyedy
@kirbyedy
Jun 29 2016 06:28
@Redoras you are missing a + after ">" and before "<h1>"
Evgueni
@Redoras
Jun 29 2016 06:28
@kirbyedy thanks
CamperBot
@camperbot
Jun 29 2016 06:28
redoras sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 1173 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
mwandama
@mwandama
Jun 29 2016 06:28
thats what i did
Alex T.
@lx-t
Jun 29 2016 06:28
@Redoras You forget to concatenate each line of your innerHTML
Evgueni
@Redoras
Jun 29 2016 06:28
@rozesn I'm looking into your issue, just a moment:)
mwandama
@mwandama
Jun 29 2016 06:29
var myData =[1,2,3];
myArray[0];
myArray[1];
rozesn
@rozesn
Jun 29 2016 06:29
thank you @Redoras
CamperBot
@camperbot
Jun 29 2016 06:29
rozesn sends brownie points to @redoras :sparkles: :thumbsup: :sparkles:
:cookie: 279 | @redoras |http://www.freecodecamp.com/redoras
Evgueni
@Redoras
Jun 29 2016 06:29
@rozesn okey, I understand the code but what is the challenge, what do you need to do?
Markus Kiili
@Masd925
Jun 29 2016 06:30
@DevSplinter Check the spelling on second return.
rozesn
@rozesn
Jun 29 2016 06:30
You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb. @Redoras
Evgueni
@Redoras
Jun 29 2016 06:31
@rozesn yeah, but what's the end result, what should the function return? Just a concatenated string?
give an example
rozesn
@rozesn
Jun 29 2016 06:32
this is the exact instruction :

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.

Evgueni
@Redoras
Jun 29 2016 06:33
@rozesn okey, so you should just take the arguments which are sent into your function and put them together like so: var newString = arg1 + arg2 + arg3 + arg3
DevSplinter
@DevSplinter
Jun 29 2016 06:33
@Masd925 thanks you very much ;)
CamperBot
@camperbot
Jun 29 2016 06:33
devsplinter sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2000 | @masd925 |http://www.freecodecamp.com/masd925
mwandama
@mwandama
Jun 29 2016 06:33
can someone answer my question
Evgueni
@Redoras
Jun 29 2016 06:33
@rozesn do you understand? You should also add a space inbetween like this: arg1 + " " + arg2 + " " and so on...
was that clear?
rozesn
@rozesn
Jun 29 2016 06:34
@Redoras thank you, I am trying that now. I will let you know
CamperBot
@camperbot
Jun 29 2016 06:34
rozesn sends brownie points to @redoras :sparkles: :thumbsup: :sparkles:
:warning: rozesn already gave redoras points
Evgueni
@Redoras
Jun 29 2016 06:34
@rozesn and obviously you should return that string
Vladimir Oscolcov
@dmduelist
Jun 29 2016 06:34
Hey guys, did anyone else have problems with "no repeat please" challenge?
Markus Kiili
@Masd925
Jun 29 2016 06:35
@dmduelist No. Just somewhat tough problem.
Evgueni
@Redoras
Jun 29 2016 06:35
@mwandama could you send a link to your challenge?
Vladimir Oscolcov
@dmduelist
Jun 29 2016 06:35
@Masd925 no, I mean problems with the website performance
@Masd925 sometimes the script stops running, or I get an error "too many recursions"
Evgueni
@Redoras
Jun 29 2016 06:36
@dmduelist Have you tried reloading your browser?
Justin Woodward
@jwoo92
Jun 29 2016 06:36
@GregatGit thanks for assisting me with a challenge!
CamperBot
@camperbot
Jun 29 2016 06:36
jwoo92 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 632 | @gregatgit |http://www.freecodecamp.com/gregatgit
Greg Duncan
@GregatGit
Jun 29 2016 06:37
@jwoo92 thank you - it was fun!
CamperBot
@camperbot
Jun 29 2016 06:37
gregatgit sends brownie points to @jwoo92 :sparkles: :thumbsup: :sparkles:
:cookie: 362 | @jwoo92 |http://www.freecodecamp.com/jwoo92
Markus Kiili
@Masd925
Jun 29 2016 06:37
@dmduelist Infinite loop or slow enough algorithm can do that.
Vladimir Oscolcov
@dmduelist
Jun 29 2016 06:37
@Redoras yep, I guess I'll have to simply improve the logic of the code
Justin Woodward
@jwoo92
Jun 29 2016 06:37
@GregatGit so simple, yet always the smallest culprit lol.
Markus Kiili
@Masd925
Jun 29 2016 06:37
@dmduelist You could also test it elsewhere like https://repl.it/
Randy Goldsmith
@Dueldrawer8
Jun 29 2016 06:38
@GregatGit hey man whats up?!
Evgueni
@Redoras
Jun 29 2016 06:38
@kirbyedy @lx-t thanks guys, now the data.name is showing but it's kind of a mess. Everything is pushed into itself :/
CamperBot
@camperbot
Jun 29 2016 06:38
redoras sends brownie points to @kirbyedy and @lx-t :sparkles: :thumbsup: :sparkles:
:warning: redoras already gave kirbyedy points
:cookie: 382 | @lx-t |http://www.freecodecamp.com/lx-t
kirbyedy
@kirbyedy
Jun 29 2016 06:39
@Redoras well you can style it with css
Vladimir Oscolcov
@dmduelist
Jun 29 2016 06:39
@Masd925 thanks for the link, it's great ;)
CamperBot
@camperbot
Jun 29 2016 06:39
dmduelist sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2001 | @masd925 |http://www.freecodecamp.com/masd925
Vladimir Oscolcov
@dmduelist
Jun 29 2016 06:40
@Masd925 it works there, but freezes in FCC workspace
Markus Kiili
@Masd925
Jun 29 2016 06:40
@dmduelist I quess it is just too slow then.
Vladimir Oscolcov
@dmduelist
Jun 29 2016 06:42
@Masd925 hm, I'm using a for loop inside a recursive function. Can you advise a different approach ?
@Masd925 I found this concept as a solution of finding permutations, took me almost 7 hours yesterday to understand it (though I don't fully grasp it yet)
Alex T.
@lx-t
Jun 29 2016 06:44
@Redoras Your .nav li elements in ul#list block have style display: inline-block. If you want them on a separate line each, use display: block;
Shivam Mehta
@shivam13
Jun 29 2016 06:44

function truncateString(str, num) {
if(num!=str.length)
{
str=str.slice(0,num);
if(str.length>=num){
str=str+"...";
}
}
return str;
}

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

I can't get this answer can anyone help me:
truncateString("A-tisket a-tasket A green and yellow basket", 11) should return "A-tisket...".

Markus Kiili
@Masd925
Jun 29 2016 06:44
@dmduelist I used similar structure.
devpaaji
@devpaaji
Jun 29 2016 06:45
var doSomething = function () {
    var a = 10;
};

doSomething();

console.log(a); // a is undefined
@Masd925 why is this a undefined
Markus Kiili
@Masd925
Jun 29 2016 06:46
This message was deleted
Evgueni
@Redoras
Jun 29 2016 06:47
@lx-t I rearranged so the nav bar is styled by id
@lx-t and added a css style for the rest of li elements: http://codepen.io/RedCone/pen/vKgYjW
Markus Kiili
@Masd925
Jun 29 2016 06:48
@devpaaji JS has function scope. a is not declared on global scope.
Alex T.
@lx-t
Jun 29 2016 06:49
@Redoras Do you want them go inline or do you want each channel on a separate line?
Vladimir Oscolcov
@dmduelist
Jun 29 2016 06:49
@Masd925 can you help me understand how does the for looping in the recursion work ?
devpaaji
@devpaaji
Jun 29 2016 06:49
@Masd925 a is inside a function do something
so it is local correct
when we invoke do something()
does it give 10
Markus Kiili
@Masd925
Jun 29 2016 06:50
@devpaaji a is local. It exists only inside function execution context. When doSomething finishes executing the variable vanishes.
Evgueni
@Redoras
Jun 29 2016 06:51
@lx-t each channel on a separate line
Markus Kiili
@Masd925
Jun 29 2016 06:52
@devpaaji If you did a=10; or window.a=10; the variable would be global.
Luis Carlos Garcia Barajas
@Luiko
Jun 29 2016 06:52
@shivam13 try cutting three more.
Eric
@ericlyv
Jun 29 2016 06:55

function nextInLine(arr, item) {
// Your code here
testArr.push(item);
return testArr.shift(); // 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(testAr " + JSON.stringify(testArr));

Alex T.
@lx-t
Jun 29 2016 06:55
@Redoras Try using #list > li rule and apply display: block style to it
Eric
@ericlyv
Jun 29 2016 06:55
can someone tell me what I am doing wrong?
devpaaji
@devpaaji
Jun 29 2016 06:55
@Masd925
alert(doSomething());
gives me undefined
var doSomething = function () {
    var a = 10;
    return a;
};

alert(doSomething());
now it gives me 10
Magnus Holm
@mghlm
Jun 29 2016 06:56
I can’t figure out what calcius equals in the celciusToFahrenheit convert assignment - please help
Markus Kiili
@Masd925
Jun 29 2016 06:56
@devpaaji Default return value in JS is undefined.
Magnus Holm
@mghlm
Jun 29 2016 06:56
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line

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


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

// Change the inputs below to test your code
convertToF(20);
devpaaji
@devpaaji
Jun 29 2016 06:56
so if a func does not have a return value
Magnus Holm
@mghlm
Jun 29 2016 06:57
celcius = what??
Markus Kiili
@Masd925
Jun 29 2016 06:57
@devpaaji Yes.
devpaaji
@devpaaji
Jun 29 2016 06:57
it points to undefined
Evgueni
@Redoras
Jun 29 2016 06:57
@lx-t thanks I'll try it :)
CamperBot
@camperbot
Jun 29 2016 06:57
redoras sends brownie points to @lx-t :sparkles: :thumbsup: :sparkles:
:warning: redoras already gave lx-t points
Alex T.
@lx-t
Jun 29 2016 06:57
@Redoras Did you know that your #list is nested into your #topbar?
Evgueni
@Redoras
Jun 29 2016 06:58
@lx-t Woah damn! You're right, I actually thought i made them separate. This explains quite a lot :)
@lx-t great!
Eric
@ericlyv
Jun 29 2016 06:59
hello guys! I'm quite new here and I'm stuck with a problem.

function nextInLine(arr, item) {
// Your code here
testArr.push(item);
return testArr.shift(); // 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));

I can't this correct. It says: nextInLine([5,6,7,8,9], 1) should return 5
Coy Sanders
@coymeetsworld
Jun 29 2016 07:00
instead of testArr, use arr @ericlyv
Luis Carlos Garcia Barajas
@Luiko
Jun 29 2016 07:01
@m4gnusholm var celcius = ;
xu hongbin
@mnixu
Jun 29 2016 07:02
how to pass Spinal Tap Case
Eric
@ericlyv
Jun 29 2016 07:02
it worked. Thanks Coy!
Magnus Holm
@mghlm
Jun 29 2016 07:02
@Luiko what?
Rose
@missstubborn
Jun 29 2016 07:02
hey guys, i think im not quite understanding what this task is asking. can you help? https://www.freecodecamp.com/challenges/selecting-from-many-options-with-switch-statements
Luis Carlos Garcia Barajas
@Luiko
Jun 29 2016 07:03
you have celSius and you use celCius @m4gnusholm
Coy Sanders
@coymeetsworld
Jun 29 2016 07:04
np @ericlyv
Shivam Mehta
@shivam13
Jun 29 2016 07:04
its switch case @missstubborn
Magnus Holm
@mghlm
Jun 29 2016 07:04
@Luiko ohhh, god damnit, thank you!
CamperBot
@camperbot
Jun 29 2016 07:04
m4gnusholm sends brownie points to @luiko :sparkles: :thumbsup: :sparkles:
:cookie: 337 | @luiko |http://www.freecodecamp.com/luiko
xu hongbin
@mnixu
Jun 29 2016 07:07
spinalCase("Teletubbies say Eh-oh") should return "teletubbies-say-eh-oh" How to write this regular?
Coy Sanders
@coymeetsworld
Jun 29 2016 07:08
@missstubborn its asking you to create a case/switch statement
in the example the cases are the numbers and the values are the Strings you would set the answer to
Justin Woodward
@jwoo92
Jun 29 2016 07:09
@mnixu replace the white spaces with '-'.
Rose
@missstubborn
Jun 29 2016 07:10
@coymeetsworld oh i see, thank you, ill give it a go
CamperBot
@camperbot
Jun 29 2016 07:10
missstubborn sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1213 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
xu hongbin
@mnixu
Jun 29 2016 07:10
but spinalCase("thisIsSpinalTap") should return "this-is-spinal-tap"
so i don't know how to write
Coy Sanders
@coymeetsworld
Jun 29 2016 07:12
good luck @missstubborn
Keone Martin
@Athaman
Jun 29 2016 07:12
@mnixu you need to use regular expressions to replace all _ or spaces with - ... then return the string as lowercase
i konw
Keone Martin
@Athaman
Jun 29 2016 07:13
@mnixu also you need to search for capital letters and insert - in front of them
xu hongbin
@mnixu
Jun 29 2016 07:19

function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
str=str.replace(/\s|_/g,"-")
str=str.replace(/[A-Z]/g,function(e){
return e.toLowerCase();
})
return str
}

spinalCase("Teletubbies say Eh-oh")

this is my code
but don't pass spinalCase("thisIsSpinalTap")
Valeske
@LantareCode
Jun 29 2016 07:20
Hi there, I wanted to ask if anyone can recommend a course,book or youtube channel to get into Javascript animations?
xu hongbin
@mnixu
Jun 29 2016 07:20
I replace all _ or spaces with -
michael-wise
@michael-wise
Jun 29 2016 07:22
@lantare iirc, the Khan Academy teaches JS via animations
Valeske
@LantareCode
Jun 29 2016 07:23
@michael-wise I'll go have a look, thank you so much!
CamperBot
@camperbot
Jun 29 2016 07:23
lantare sends brownie points to @michael-wise :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for michael-wise
Keone Martin
@Athaman
Jun 29 2016 07:24
@Lantare yeah khan started off on animation i didn't go very far with it because i'm not artsy
@mnixu where are all your semicolons?
xu hongbin
@mnixu
Jun 29 2016 07:27
@Athaman ...
Keone Martin
@Athaman
Jun 29 2016 07:28
So at the moment you're not inserting a hyphen before capital letters
instead of str = str.replace(/[A-Z]g, function(e){ return e.toLowerCase();}); you need to return "-" + e.toLowerCase()
xu hongbin
@mnixu
Jun 29 2016 07:29
/(?=[A-Z])/?
Keone Martin
@Athaman
Jun 29 2016 07:30
or you could just use better regex and only insert the hyphen when the capital isn't immediately following one already
xu hongbin
@mnixu
Jun 29 2016 07:38
oh thank you @Athaman
CamperBot
@camperbot
Jun 29 2016 07:38
mnixu sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:cookie: 486 | @athaman |http://www.freecodecamp.com/athaman
xu hongbin
@mnixu
Jun 29 2016 07:38

function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
str=str.replace(/\s|_/g,"-");
str=str.replace(/\w(?=[A-Z])/g,function(e){
var a=/[a-z]/;
if(a.test(e)){
return e+"-";
}else {
return e;
}
});
str=str.replace(/[A-Z]/g,function(e){
return e.toLowerCase();
});
return str;
}

spinalCase("thisIsSpinalTap");

this is my code
Keone Martin
@Athaman
Jun 29 2016 07:38
help format
CamperBot
@camperbot
Jun 29 2016 07:38

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

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

Keone Martin
@Athaman
Jun 29 2016 07:38
try using that, it helps make reading code much less painful
also neat, congratulations on passing it
Akshay Sheelvant
@AkshaySheelvant
Jun 29 2016 07:40
can any1 please check the issue with this code, as it's returning "Not Found", but not the object properties.....

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

function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty("checkProp")){
return myObj.checkProp;
}
else
return "Not Found";
}
// Test your code by modifying these values

checkObj("gift");

xu hongbin
@mnixu
Jun 29 2016 07:40
yes
HuWei501
@HuWei501
Jun 29 2016 07:42
function update(id, prop, value) {
if(prop != "tracks" && value != null){
collection[id][prop]=value;
}else if(prop == "tracks" && value != null){
collection[id].tracks.push(value);
}
else if(value == ""){
delete collection[id][prop];
}
return collection;
}
update(2548, "tracks", "");
Andrew
@andrewlee56
Jun 29 2016 07:42
anyone find the challenge - Make Object Properties Private - difficult?
Aleksandr Kozlov
@Cu3bIu
Jun 29 2016 07:42

Hey Everyone I have resovled "Steamroller" task using the recursive function. I get the exact answers as need but it doesnot recognise as a positive results. Anyone knows why is that ? Here is the code: var finalArr = [];

function steamrollArray(arr) {
// I'm a steamroller, baby

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

}

return finalArr;
}

function checkIfArr (arr){
var keepChecking = true;
if(Array.isArray(arr)){
for(var k = 0; k<arr.length;k++){
checkIfArr(arr[k]);
}
}else{
finalArr.push(arr);
}
}

HuWei501
@HuWei501
Jun 29 2016 07:42
why value=="" is wrong?
Andrew
@andrewlee56
Jun 29 2016 07:42
the directions were very unclear
Anirudha Kasralikar
@akasralikar
Jun 29 2016 07:42
@AkshaySheelvant I think you hardcoded parameter inside string
try remove double quotes around checkProp
Coy Sanders
@coymeetsworld
Jun 29 2016 07:43
its alot to take in @andrewlee56
Anirudha Kasralikar
@akasralikar
Jun 29 2016 07:43
instead of if(myObj.hasOwnProperty("checkProp")){
use if(myObj.hasOwnProperty(checkProp)){
Akshay Sheelvant
@AkshaySheelvant
Jun 29 2016 07:44
@akasralikar tried with that too, not helping
Andrew
@andrewlee56
Jun 29 2016 07:44
not sure how to tackle the challenge - Make Object Properties Private. Need help
Coy Sanders
@coymeetsworld
Jun 29 2016 07:44
@AkshaySheelvant its this line too return myObj.checkProp;
checkProp is a variable, you can only use dot notation to get a property if you have the name of the property
in that example it would check for the property with name checkProp, not what's stored in checkProp
use bracket notation instead to solve the problem
Magnus Holm
@mghlm
Jun 29 2016 07:45
what’s wrong with this??
```js

var myStr = "Here is a backlash: \\.\n\t\tHere is a new line with two tabs.";
Akshay Sheelvant
@AkshaySheelvant
Jun 29 2016 07:46
@coymeetsworld thanks man, it got resolved
CamperBot
@camperbot
Jun 29 2016 07:46
akshaysheelvant sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1215 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 29 2016 07:46
you have a typo @m4gnusholm
should say backslash, not backlash
your escape sequences look fine
good @AkshaySheelvant
James Riall
@JamesRiall
Jun 29 2016 07:47

Can anyone help with the getting my API call right for the wikipedia viewer challenge? I don't see to have got the scope right - API is in scope outside of the call, but out of scope when inside the JSON get request:

```$(document).ready(function() {

//setting search term
var search = "test";

// wiki api url
var api = "https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrsearch=" + search + "&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max";

//load API
$.getJSON(api, function(data) {
$("#test").html(api);

});
});```

Magnus Holm
@mghlm
Jun 29 2016 07:47
@coymeetsworld omg., now i feel stupid. thanks!!
CamperBot
@camperbot
Jun 29 2016 07:47
m4gnusholm sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1216 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 29 2016 07:47
someone linked this medium article on differences between dot and bracket notation if you're interested @AkshaySheelvant, thought it was well written https://medium.com/@prufrock123/js-dot-notation-vs-bracket-notation-797c4e34f01d#.xa320t5ml
np @m4gnusholm
Andrew
@andrewlee56
Jun 29 2016 07:48
anyone there?
James Riall
@JamesRiall
Jun 29 2016 07:48
So the api string is displayed when i put it outside the getJSON request, but is not displaying when inside the getJSON request
Keone Martin
@Athaman
Jun 29 2016 07:48
@m4gnusholm you have backlash instead of backslash if no one has pointed that out yet
Coy Sanders
@coymeetsworld
Jun 29 2016 07:49
what are you having trouble with @andrewlee56 ?
James Riall
@JamesRiall
Jun 29 2016 07:49
The URL works fine and is providing the JSON data I need
Anirudha Kasralikar
@akasralikar
Jun 29 2016 07:49
@coymeetsworld thanks for sharing article on dot vs bracket
CamperBot
@camperbot
Jun 29 2016 07:49
akasralikar sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1217 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Keone Martin
@Athaman
Jun 29 2016 07:49
@andrewlee56 chill bro, people need time to think about how they're going to offer advice and we're often busy with other questions as well.
Magnus Holm
@mghlm
Jun 29 2016 07:49
@Athaman yeah, Coy pointed it out - thank you !!
CamperBot
@camperbot
Jun 29 2016 07:49
m4gnusholm sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:cookie: 487 | @athaman |http://www.freecodecamp.com/athaman
Coy Sanders
@coymeetsworld
Jun 29 2016 07:49
np @akasralikar
Keone Martin
@Athaman
Jun 29 2016 07:49
@m4gnusholm no problem, i alt tabbed for a minute cos the channel was quiet and suddenly it went off :D
Magnus Holm
@mghlm
Jun 29 2016 07:50
@Athaman what’s alt tab?
Keone Martin
@Athaman
Jun 29 2016 07:51
alt + tab on a windows pc changes program focus to another thing (i was doing some coding in atom)
@andrewlee56 you need to write out a similar set of lines to what is offered in the example code but changing the variable names
shweta rajput
@ShwetaRajput
Jun 29 2016 07:52
even mine not working
Keone Martin
@Athaman
Jun 29 2016 07:53
@ShwetaRajput what's not working?
shweta rajput
@ShwetaRajput
Jun 29 2016 07:53
can some one help with escape sequence in strings
Gianni Zamora
@wizyoua
Jun 29 2016 07:53
Hello I am wondering if anybody has done the javascript problem where a=7, b=7 then a=b
shweta rajput
@ShwetaRajput
Jun 29 2016 07:53
@Athaman var myStr="\"Here is a backslash:\. \n\t\t Here is a new line with two tabs.\"";// Change this line
Gianni Zamora
@wizyoua
Jun 29 2016 07:53
I understand it completely but the answer is not correct
Wan Jong Kim
@wanjongkim
Jun 29 2016 07:54
a==b you mean? @wizyoua
Gianni Zamora
@wizyoua
Jun 29 2016 07:55
@wanjongkim no it says a should be assigned to b with =
and i did a = b;
Wan Jong Kim
@wanjongkim
Jun 29 2016 07:55
oh it's b = a
Gianni Zamora
@wizyoua
Jun 29 2016 07:55
oh lol thx
Keone Martin
@Athaman
Jun 29 2016 07:56
@ShwetaRajput you need to remove the space between \. and \n as well as between \t and Here
@wizyoua remember that order is important in the assignment operator... whatever is on the right will be stored in what is on the left so it makes a difference what goes where.
it's easy to forget because equals normally means something different in maths and you can swap sides without worrying, not in programming though :)
Gianni Zamora
@wizyoua
Jun 29 2016 07:57
@Athaman Thank you for the explanation:)
CamperBot
@camperbot
Jun 29 2016 07:57
wizyoua sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:cookie: 488 | @athaman |http://www.freecodecamp.com/athaman
shweta rajput
@ShwetaRajput
Jun 29 2016 07:57
@Athaman but in output we should not have any spaces between escape sequence
@Athaman this is my code: var myStr="\"Here is a backslash:\.\n\t\t Here is a new line with two tabs.\"";
Keone Martin
@Athaman
Jun 29 2016 07:59
yes... spaces are important in strings and will mess with a string comparison "this string" === "thisstring" will fail... so when you put extra spaces in it breaks the test. here you are putting an extra space after the full stop at the end of the line and one after the tabs on the new line
you still need to get rid of the space between \t and Here
that will start the new line with two tabs, then a space, then Here... it should be two tabs then straight to Here
Andrew
@andrewlee56
Jun 29 2016 08:00
thanks @Athaman
CamperBot
@camperbot
Jun 29 2016 08:00
andrewlee56 sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:cookie: 489 | @athaman |http://www.freecodecamp.com/athaman
Andrew
@andrewlee56
Jun 29 2016 08:01
@Athaman just figured it out :)
Keone Martin
@Athaman
Jun 29 2016 08:02
:) good to hear @andrewlee56
shweta rajput
@ShwetaRajput
Jun 29 2016 08:04
@Athaman var myStr="\"Here is a backslash:\.\n\t\tHere is a new line with two tabs.\"";
whats wrong with this one.
Anirudha Kasralikar
@akasralikar
Jun 29 2016 08:04
you dont need to escape quotes @ShwetaRajput
Keone Martin
@Athaman
Jun 29 2016 08:04
wait, why are you putting the extra quotes in?
shweta rajput
@ShwetaRajput
Jun 29 2016 08:05
because "here is.... should be in quotes
Keone Martin
@Athaman
Jun 29 2016 08:05
it only needs to be in quotes to make it a string
not escaped quotes inside
shweta rajput
@ShwetaRajput
Jun 29 2016 08:06
and even if i does not insert these quotes it still doesn'twork
Anirudha Kasralikar
@akasralikar
Jun 29 2016 08:06
Try this var myStr = "Here is a backslash: \\.\n\t\tHere is a new line with two tabs."; @ShwetaRajput
Keone Martin
@Athaman
Jun 29 2016 08:06
send us the new string
Gianni Zamora
@wizyoua
Jun 29 2016 08:06
This community is awesome. I just joined to re study my javascript and all of you have been great help :)
Keone Martin
@Athaman
Jun 29 2016 08:06
we try :)
oh right, this one will be because you need the space between : and \\
Anirudha Kasralikar
@akasralikar
Jun 29 2016 08:08
right
shweta rajput
@ShwetaRajput
Jun 29 2016 08:10
@Athaman yes it worked. thanku as usual
CamperBot
@camperbot
Jun 29 2016 08:10
shwetarajput sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:cookie: 490 | @athaman |http://www.freecodecamp.com/athaman
Ian Hale
@coloradomountain
Jun 29 2016 08:14
Challenge "stand in line" requires you to remove the first element of an array, I did this using a standard function in JS but got errors.
I guess there are multiple ways to answer the solution, and only one right way? However best practice says to use the first (incorrect per FCC) function rather than the one FCC wants.
idk just something to think about. This is a beginning course after all, maybe I should take it with a cup of salt.
Keone Martin
@Athaman
Jun 29 2016 08:17
what function did you use @coloradomountain ?
or maybe even copy paste your code here to look at?
generally they're pretty relaxed about how you get your solution, they just have some assert statements which check that whatever your function returns is what they were looking for.
Shivam Mehta
@shivam13
Jun 29 2016 08:18
This message was deleted

function mutation(arr) {
arr[0]=arr[0].toLowerCase();
arr1=arr1.toLowerCase();
var a= arr1.split('');
for(i=0;i<arr.length;i++){ if((arr[0].indexOf(a[i]))>=0){
return true;
}
return false;
}
}

mutation(["hello", "hey"]);

Keone Martin
@Athaman
Jun 29 2016 08:19
@shivam13 you're using array1 instead of array1 it seems
wait... that's just formatting >.>
This message was deleted
Shivam Mehta
@shivam13
Jun 29 2016 08:20
i m using [] but its not displayed here @Athaman
Keone Martin
@Athaman
Jun 29 2016 08:20
function mutation(arr) {
  arr[0]=arr[0].toLowerCase();
  arr[1]=arr[1].toLowerCase();
  var a= arr[1].split('');
  for(i=0;i<arr.length;i++){
    if((arr[0].indexOf(a[i]))>=0){
      return true;
    }
    return false;
  }
}

mutation(["hello", "hey"]);
help format
CamperBot
@camperbot
Jun 29 2016 08:20

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

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

Keone Martin
@Athaman
Jun 29 2016 08:20
you really should learn to do the formatting, it makes our lives a lot easier
Shivam Mehta
@shivam13
Jun 29 2016 08:22

function mutation(arr) {
arr[0]=arr[0].toLowerCase();
arr[1]=arr[1].toLowerCase();
var a= arr[1].split('');
for(i=0;i<arr.length;i++){ if((arr[0].indexOf(a[i]))>=0){
return true;
}
return false;
}
}

mutation(["hello", "hey"]);

Keone Martin
@Athaman
Jun 29 2016 08:22
@shivam13 first up you need to have one of your return statements outside of the for loop. at the moment as soon as one letter matches it gets returned tru, and when one letter doesn't match it gets returned false
one of those has to change
also you can use index of on a string so you don't need to split it
Shivam Mehta
@shivam13
Jun 29 2016 08:24
ok
Keone Martin
@Athaman
Jun 29 2016 08:26
you should have the for loop checking to see if indexOf returns -1 and if it does return false from there... then have return true outside the for loop so that if it makes it to the end it gets sent
peibowl
@peibowl
Jun 29 2016 08:27
hello
Keone Martin
@Athaman
Jun 29 2016 08:28
hi there
peibowl
@peibowl
Jun 29 2016 08:28
On lesson 155, I don't really understand what I have to do. Can someone give me a tp, please
tip
Keone Martin
@Athaman
Jun 29 2016 08:28
155 is your number of brownie points not the lesson :) what's it called?
peibowl
@peibowl
Jun 29 2016 08:29
lol
Keone Martin
@Athaman
Jun 29 2016 08:29
about @peibowl
CamperBot
@camperbot
Jun 29 2016 08:29
:cookie: 155 | @peibowl |http://www.freecodecamp.com/peibowl
peibowl
@peibowl
Jun 29 2016 08:29
u r right
Keone Martin
@Athaman
Jun 29 2016 08:29
;)
peibowl
@peibowl
Jun 29 2016 08:29
Word Blanks then
that is the lesson
Keone Martin
@Athaman
Jun 29 2016 08:29
1 sec i'll read the specs
Shivam Mehta
@shivam13
Jun 29 2016 08:30

function mutation(arr) {
arr[0]=arr[0].toLowerCase();
arr1=arr1.toLowerCase();
for(i=0;i<arr.length;i++){
if((arr[0].indexOf(arr1))==-1){
return false;
}
return true;
}}

mutation(["hello", "hey"]);

is this right?? @Athaman

peibowl
@peibowl
Jun 29 2016 08:30
I tried joining all the word in the result variable
but it says that is wrong
Keone Martin
@Athaman
Jun 29 2016 08:30
ok, so they pass in a bunch of words to the function under the names like myNoun, myAdjective. you need to put them together into one string by using the + operator
Shivam Mehta
@shivam13
Jun 29 2016 08:30

function mutation(arr) {
arr[0]=arr[0].toLowerCase();
arr1=arr1.toLowerCase();
for(i=0;i<arr.length;i++){
if((arr[0].indexOf(arr1))==-1){
return false;
}
return true;
}}

mutation(["hello", "hey"]);

Keone Martin
@Athaman
Jun 29 2016 08:31
@shivam13 please learn formatting. and don't spam your code
peibowl
@peibowl
Jun 29 2016 08:31
yeah I did that but it said it was wrong
:S
Shivam Mehta
@shivam13
Jun 29 2016 08:31
help room not support [] xD
CamperBot
@camperbot
Jun 29 2016 08:31
no wiki entry for: room not support xd
Keone Martin
@Athaman
Jun 29 2016 08:31
it does if you use formatting
help format
CamperBot
@camperbot
Jun 29 2016 08:31

:point_right: code formatting [wiki]

Multi line Code

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