These are chat archives for FreeCodeCamp/HelpJavaScript

19th
Apr 2016
Chase Webb
@jerrybaggin
Apr 19 2016 00:01
@moigithub currently I have this. i'm supposed to use both dot and bracket notation. var gloveBoxContents = myStorage.car.inside["glovebox"]
Moisés Man
@moigithub
Apr 19 2016 00:01
@jerrybaggin almost...
but if u check again the property name.. its not exactly
glovebox but
glove box <- with an space
Micah Bales
@micahbales
Apr 19 2016 00:02
quick question for any regex experts out there. What does "$1 $2" signify in this expression?
.replace(/([a-z])([A-Z])/g, '$1 $2')
Moisés Man
@moigithub
Apr 19 2016 00:03
capture groups
Hector Garcia
@augmt
Apr 19 2016 00:03
@micahbales $1 represents what the regex in the first parentheses captured and $2 represents what the regex in the second parentheses captured
Moisés Man
@moigithub
Apr 19 2016 00:03
match the content of ( )
Chase Webb
@jerrybaggin
Apr 19 2016 00:06
@moigithub lol I swear I tired it with a space before?! Worked this time.
@moigithub thanks
CamperBot
@camperbot
Apr 19 2016 00:07
jerrybaggin sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
Moisés Man
@moigithub
Apr 19 2016 00:07
:+1:
CamperBot
@camperbot
Apr 19 2016 00:07
:star: 959 | @moigithub | http://www.freecodecamp.com/moigithub
Micah Bales
@micahbales
Apr 19 2016 00:07
@augmt Interesting. But I don't understand how that ends up adding a space between the lowercase and capital letters...
Hector Garcia
@augmt
Apr 19 2016 00:08
@micahbales you have a space between $1 and $2
Micah Bales
@micahbales
Apr 19 2016 00:09
ooooooooh brilliant
lol, thanks @augmt
Hector Garcia
@augmt
Apr 19 2016 00:09
np :p
Micah Bales
@micahbales
Apr 19 2016 00:09
So I can always use $1, $2, etc., to represent my (captured) values from regex?
Hector Garcia
@augmt
Apr 19 2016 00:10
yep
i can say so for regex in at least javascript
Micah Bales
@micahbales
Apr 19 2016 00:11
nice. that's awesome. regex is the shit.
Tyler
@tylergross
Apr 19 2016 00:11
in RegExp how do i make a part of it optional? I have an expression at the beginning that I want to be optional and return a function if or if not matched
Hector Garcia
@augmt
Apr 19 2016 00:13
@tylergross you can use {0,} or ? after the optional regex
Tyler
@tylergross
Apr 19 2016 00:14
@augmt I will give it a shot
Anas R. Firdousi
@afirdousi
Apr 19 2016 00:14

Want to start writing JavaScript ES6(ES2015) today? Start with these 6 basic features! Here is my latest post:

http://anasfirdousi.com/6-things-to-start-with-in-ecma-6-ecma-2015-javascript-let-const-spread-default-params-templates-es6.html

Tyler
@tylergross
Apr 19 2016 00:15
@augmt didn't help I'm trying to input a number 1 555 555 5555 or 555 555 5555 and get true, right now it only returns true for the 1 in front
function smallestCommons(arr) {
  var str = "555 555 5555";
  var a = new RegExp(/^([1])?[ ]\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/);
  var b = str.match(a);
  if(b){
    return true;
  }else{
    return false;
  }
}
Hector Garcia
@augmt
Apr 19 2016 00:17
@tylergross 555 555 5555 works if there's a space at the beginning of the string
the regex in your code makes the space mandatory
Tyler
@tylergross
Apr 19 2016 00:18
@augmt thanks for the hint
CamperBot
@camperbot
Apr 19 2016 00:18
tylergross sends brownie points to @augmt :sparkles: :thumbsup: :sparkles:
:star: 385 | @augmt | http://www.freecodecamp.com/augmt
henrywashere
@henrywashere
Apr 19 2016 00:29

i need help with this exercise:

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

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.

this is the "Stand in Line" challenge
Wesly Jason
@wesly-jason
Apr 19 2016 00:30
help stand in line
CamperBot
@camperbot
Apr 19 2016 00:30

:point_right: checkpoint stand in line [wiki]

Checkpoint: Stand In Line

About queues

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

Instructions

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

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

The nextInLine function should return the element that was removed.

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

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

Wesly Jason
@wesly-jason
Apr 19 2016 00:31
here you go @henrywashere
'''function nextInLine(arr, item) {
// Your code here
arr.push(item);
var removed = arr.shift();
return removed; // Change this line
}'''
CamperBot
@camperbot
Apr 19 2016 00:31
:bulb: to format code use backticks! ``` more info
Wesly Jason
@wesly-jason
Apr 19 2016 00:32
```
Tyler
@tylergross
Apr 19 2016 00:33
@augmt right now my RegExp checks for "(" and ")" but it still returns true if one is missing. Is there a RegExp formula to ensure that both are within the sequence?
Ro (Lora Rose)
@aroseartist
Apr 19 2016 00:34
I just cannot figure out what this is asking for! Suggestions?
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");
Frank XC
@tenkdayz
Apr 19 2016 00:35
@aroseartist form a sentence
Hector Garcia
@augmt
Apr 19 2016 00:35
@tylergross there may be but i couldn't think of one =/
what i did was i had two if blocks check if there were any unopened or unclosed parentheses in the string separate from the RegExp
Moisés Man
@moigithub
Apr 19 2016 00:36
@aroseartist use ALL the words passed throug the parameters to form a phrase
Tyler
@tylergross
Apr 19 2016 00:36
@augmt that's what I was thinking of doing but figured there has to be another method
Ian Smith
@TOAOIanSmith
Apr 19 2016 00:36
'''js 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"
}
};
CamperBot
@camperbot
Apr 19 2016 00:36
:bulb: to format code use backticks! ``` more info
Ian Smith
@TOAOIanSmith
Apr 19 2016 00:37
Cannot figure this out... sorry one sec
How would you access 1245:{
Argh
Nvm
Tyler
@tylergross
Apr 19 2016 00:38
@TOAOIanSmith it is an array that holds objects
Josh
@joshweaver23
Apr 19 2016 00:38
@aroseartist that's the one asking you to combine those into a string?
Moisés Man
@moigithub
Apr 19 2016 00:38
@TOAOIanSmith use the parameters/variables names
@tylergross is not an array.. but a big object.. with nested object/arrays inside
Tyler
@tylergross
Apr 19 2016 00:39
so collection["2548"] ?
Moisés Man
@moigithub
Apr 19 2016 00:39
ye
Tyler
@tylergross
Apr 19 2016 00:39
looked like an array containing objects at first, my bad
Moisés Man
@moigithub
Apr 19 2016 00:40
but instead of hardcoding.. need to use the variables provided
Chris Humphreys
@ChrisCHumphreys
Apr 19 2016 00:42
Can someone help with the map the debris challenge?
I am just trying to get the formula to spit out the right seconds but cant get it.
I think it might by my order of operations being off.
'''

function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;
// T = 2pisqrt(earthRadius + avgAlt to the cube / GM)
var orbPer = 6.18 * Math.pow(earthRadius + Math.pow(arr[0].avgAlt, 3) / GM, 0.5);
return orbPer;
}

orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);

'''
Moisés Man
@moigithub
Apr 19 2016 00:44
@aroseartist calling this wordBlanks("dog", "big", "ran", "quickly");
should return "dog big ran quickly"
or if u like.. adding some "decorators/extra words"
"the dog almost got hit by a big truck and ran quickly" <--notice it includes all words passed to the function
Chris Humphreys
@ChrisCHumphreys
Apr 19 2016 00:44
This message was deleted
CamperBot
@camperbot
Apr 19 2016 00:44
:bulb: to format code use backticks! ``` more info
Chris Humphreys
@ChrisCHumphreys
Apr 19 2016 00:45
This message was deleted
Moisés Man
@moigithub
Apr 19 2016 00:45
pi = Math.PI
Tyler
@tylergross
Apr 19 2016 00:45
@geochris35 you should paste your code using the backticks and make sure to post them on a new line IE
Ticks
PASTE CODE
Ticks
Moisés Man
@moigithub
Apr 19 2016 00:46
@geochris35 and sqrt is Math.sqrt
Josh
@joshweaver23
Apr 19 2016 00:46
can someone give me a general idea of how to use the arguments object? I'm having trouble understanding what to do with it
Moisés Man
@moigithub
Apr 19 2016 00:47
@geochris35 ahh saw u using Math.pow + 0.5 should works too
Chris Humphreys
@ChrisCHumphreys
Apr 19 2016 00:47
function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
// T = 2*pi*sqrt(earthRadius + avgAlt to the cube / GM)
  var orbPer = 6.18 * Math.pow(earthRadius + Math.pow(arr[0].avgAlt, 3) / GM, 0.5);
  return orbPer;
}
orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
sorry, took me a sec to figure out the code. I am getting wrong answer even when just doing it by hand
Moisés Man
@moigithub
Apr 19 2016 00:48
@geochris35 what exercise is that ? post link
Chris Humphreys
@ChrisCHumphreys
Apr 19 2016 00:48
it is called Map the Debris
Hector Garcia
@augmt
Apr 19 2016 00:49
@geochris35 you need to be returning an array, not a number
Chris Humphreys
@ChrisCHumphreys
Apr 19 2016 00:49
I haven't gotten there yet. Right now I am just trying to get the correct solution.
Hector Garcia
@augmt
Apr 19 2016 00:50
ah ok
Ebonie Lumpkin
@elumpkin
Apr 19 2016 00:50

Hello, all. for some reason my button is not working. any help would be appreciated. codepen link below:

http://codepen.io/elumpkin/pen/LNmaqa

Frank XC
@tenkdayz
Apr 19 2016 00:50
@geochris35 I finished that one today.. if you need help.. it was fun
Chris Humphreys
@ChrisCHumphreys
Apr 19 2016 00:51
@tenkdayz that would be great. Any chance you could just give me some pointers on why my formula is not working?
Frank XC
@tenkdayz
Apr 19 2016 00:53
@geochris35 where are you getting the 0.5 from?
Hector Garcia
@augmt
Apr 19 2016 00:53
@geochris35 you should use Math.PI instead of 6.18
Chris Humphreys
@ChrisCHumphreys
Apr 19 2016 00:53
@tenkdayz I was using that to get the square root.
Frank XC
@tenkdayz
Apr 19 2016 00:53
@geochris35 and you need Math.PI somewhere in there
Chris Humphreys
@ChrisCHumphreys
Apr 19 2016 00:53
@augmt I just added Math.PI instead of 3.14.
Hector Garcia
@augmt
Apr 19 2016 00:54
you also need to raise earthRadius + arr[0].avgAlt to the third power, not just arr[0].avgAlt
Frank XC
@tenkdayz
Apr 19 2016 00:54
@geochris35 use Math.sqrt()
Chris Humphreys
@ChrisCHumphreys
Apr 19 2016 00:54
@tenkdayz ok. I will give that a shot
@augmt I will update that as well.
Thanks you guys. I still have a lot of messing around to do but you have given me a good start.
I did what you guys said and I am now getting right answer! Thanks @tenkdayz @augmt
CamperBot
@camperbot
Apr 19 2016 00:57
geochris35 sends brownie points to @tenkdayz and @augmt :sparkles: :thumbsup: :sparkles:
:star: 386 | @augmt | http://www.freecodecamp.com/augmt
:star: 420 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
Frank XC
@tenkdayz
Apr 19 2016 00:58
@geochris35 :+1:
Tyler
@tylergross
Apr 19 2016 01:02
just finished the validate telephone challenge, man was that a pain but got a great understanding of Regexp in doing so
Benjamin Gonzalez
@xasuma
Apr 19 2016 01:03
Hey guys, could someone help me with my toggle button here? I can't get it to toggle properly.
http://codepen.io/xasuma/pen/ONQXGO
WilliamDecker
@WilliamDecker
Apr 19 2016 01:06
hello, I have a question regarding Mutations in Basic Algorithm Scripting
Tharun James
@xplorejames
Apr 19 2016 01:07
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for(i=0;i<arr.length;i++)
    {
      for(j=0;j<arr.length[i];j++)
        {

        return product(arr[i][j]);

        }
    }

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
WilliamDecker
@WilliamDecker
Apr 19 2016 01:07
that's my code from what I gather characters are being counted twice
Tharun James
@xplorejames
Apr 19 2016 01:07
Whats the error
Im getting the same product as declared
Moisés Man
@moigithub
Apr 19 2016 01:08
@xplorejames u returning too soon
u should multiplicate ALL ur numbers first.. before returning
remember return Exit the function
Tharun James
@xplorejames
Apr 19 2016 01:10
@moigithub i cant remember can you give me a hand please
:)
Moisés Man
@moigithub
Apr 19 2016 01:10
@xplorejames also.. product ( something) follow by parentesis will tell javascript this is a function, and it will try to execute it
WilliamDecker
@WilliamDecker
Apr 19 2016 01:11
you need to get the product before you return it
@xplorejames notice below the commented line "only change code above this line" it has a return product; ?
you want to return after you exit your loop
Moisés Man
@moigithub
Apr 19 2016 01:12
@xplorejames product is a variable.. if u check below.. its returning product
so u need to store on product variable..the calc/multiplicatoin of all those numbers in the array
Tharun James
@xplorejames
Apr 19 2016 01:12
product*=arr[i][j];
will this work
?
WilliamDecker
@WilliamDecker
Apr 19 2016 01:13
give it a try!
Tharun James
@xplorejames
Apr 19 2016 01:13
nope its still returning 1
Moisés Man
@moigithub
Apr 19 2016 01:13
ur second loop is incorrect
for(j=0;j<arr.length[i];j++)
WilliamDecker
@WilliamDecker
Apr 19 2016 01:13
length[i]
Moises, do you think you could look at my codepen?
i'm not sure how to use the indexOf method
I'm counting duplicate letters
Moisés Man
@moigithub
Apr 19 2016 01:14
indexOf works on array and on strings
"12345".indexOf(9) will return -1 (not found)
[1,2,3,4,5].indexOf(1) will return 0 (cuz 0 is the first index position the number 1 is)
Ozan Araz
@haraldur12
Apr 19 2016 01:16
product = arr[i][j] product
(( product = arr[i][j] product ))
damn the asterisk
Moisés Man
@moigithub
Apr 19 2016 01:17
with backticks
****
Tharun James
@xplorejames
Apr 19 2016 01:18
@moigithub Thank you so much
CamperBot
@camperbot
Apr 19 2016 01:18
xplorejames sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 960 | @moigithub | http://www.freecodecamp.com/moigithub
Tharun James
@xplorejames
Apr 19 2016 01:18
im so dubm to put the index on the length
Moisés Man
@moigithub
Apr 19 2016 01:18
:D
Ozan Araz
@haraldur12
Apr 19 2016 01:18
product *= arr[i][j] * product should do it
Moisés Man
@moigithub
Apr 19 2016 01:19
u got a extra * @haraldur12
WilliamDecker
@WilliamDecker
Apr 19 2016 01:19
that's a lot of errors in programming :D use the "rubber duck" method to find them :)
I managed to complete the Mutations challenge, but I know my code is flawed
if I put the test case LLL and the letters ELO
it'll pass as true because I'm not correctly counting if all the letters occur in a string
Tyler
@tylergross
Apr 19 2016 01:22
@WilliamDecker hence why software patches are pushed out so frequently
Moisés Man
@moigithub
Apr 19 2016 01:26
@WilliamDecker u only need 1 loop.. cuz "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."
it only asking u to check if first is on second...
and not also if second is on first..
ManBearPigg
@ManBearPigg
Apr 19 2016 01:27
How can I select only data.nick and style it? I don’t want to style the whole #chat div the same
function(data) {

    $('#chat').append(data.nick + "<br/>" + data.msg + "<br/>");
  });
Ozan Araz
@haraldur12
Apr 19 2016 01:27
data[nick]
or could be data.[nick]
ManBearPigg
@ManBearPigg
Apr 19 2016 01:28
How do you mean
I’m trying to style data.nick
Moisés Man
@moigithub
Apr 19 2016 01:28
@WilliamDecker i guess ur second loop is not doing what i though :).. but u dont need count.. u overdoing
@WilliamDecker "The arguments ["hello", "hey"] should return false because the string "hello" does not contain a "y""
u can "return sooner"
no count needed
WilliamDecker
@WilliamDecker
Apr 19 2016 01:36
I was using the example on the MDN
Moisés Man
@moigithub
Apr 19 2016 01:36
@ManBearPigg put data.nick inside a container...
WilliamDecker
@WilliamDecker
Apr 19 2016 01:36
the one at the bottom
Using indexOf() to count occurrences of a letter in a string
was I incorrect in my selection of an example, or did I just implement it incorrectly?
Moisés Man
@moigithub
Apr 19 2016 01:37
$('#chat').append("<span class="nick">"+data.nick + "</span> <br/>" + data.msg + "<br/>");
@ManBearPigg
then u can style that .nick class
WilliamDecker
@WilliamDecker
Apr 19 2016 01:38
do I just check the string, and if it returns -1, return it as false?
Moisés Man
@moigithub
Apr 19 2016 01:39
@WilliamDecker that example.. is for counting ocurrences of same letter.. so
if u have "eeeeee" it will count 6
aerowinc
@aerowinc
Apr 19 2016 01:39
my if statement is not registering my inputs, any suggestions why it might not?
Moisés Man
@moigithub
Apr 19 2016 01:40
@WilliamDecker but on ur code.. u have "hello" vs "hey"
if count "y" will be only 1
@WilliamDecker and u comparing "y".length vs "hey".length
(i think)
aerowinc
@aerowinc
Apr 19 2016 01:42
heres my code if anyone wants to look into my issue

var count = 0;

function cc(card) {
if(card < 7 && card > 1){
count += count;
}else if(card < 10 && card > 6){
count = count;
}
else{
count -= count;
}
return count;
}

Moisés Man
@moigithub
Apr 19 2016 01:42
"hello" vs "hey"
should
"h" is on "hello"
"e"is on "hello"
"y" is on "hello" <--- return false
return true
@WilliamDecker
WilliamDecker
@WilliamDecker
Apr 19 2016 01:43
yeah I think I understand it better when you explained that -1 = false
so I came up with this
a lot less code, and it works in all cirsumstances :D
*circumstances
correctly
Moisés Man
@moigithub
Apr 19 2016 01:44
@aerowinc its not exactly count = count + count
but increment +1 (or decrement -1 )
WilliamDecker
@WilliamDecker
Apr 19 2016 01:44
thanks @moigithub
CamperBot
@camperbot
Apr 19 2016 01:44
williamdecker sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 961 | @moigithub | http://www.freecodecamp.com/moigithub
aerowinc
@aerowinc
Apr 19 2016 01:45
@moigithub wow, thanks i didnt even think about that being an issue but definitely explains the issue
CamperBot
@camperbot
Apr 19 2016 01:45
aerowinc sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 962 | @moigithub | http://www.freecodecamp.com/moigithub
willamgriffin
@willamgriffin
Apr 19 2016 01:46
how do I set a variable from an input/form
Moisés Man
@moigithub
Apr 19 2016 01:46
<input type="text" value="hello" >
@willamgriffin
willamgriffin
@willamgriffin
Apr 19 2016 01:47
i mean from an html input
like a form
Moisés Man
@moigithub
Apr 19 2016 01:48
tats an html input :)
Ozan Araz
@haraldur12
Apr 19 2016 01:48
var question = prompt()
willamgriffin
@willamgriffin
Apr 19 2016 01:48
i'm trying to use something other than prompts
html form ?
willamgriffin
@willamgriffin
Apr 19 2016 01:49
yeah
Just use jquery then
Moisés Man
@moigithub
Apr 19 2016 01:50
<form>
    Name <input type="text" value="hello">
</form>
Ozan Araz
@haraldur12
Apr 19 2016 01:50
I think he wants to save the data as well
Tyler
@tylergross
Apr 19 2016 01:50

doing the symmetric difference equation

function sym(args) {
  var counter = 0;
  var finalArr = arguments[0];
  for(var i = 1; i < arguments.length; i++){
    for(var k = 0; k < arguments[i].length; k++){
      for(var j = 0; j < finalArr[j]; j++){
        if(finalArr.indexOf(arguments[i][k]) >= 0){
          finalArr.splice(0,j);
        }else{
          finalArr.push(arguments[i][k]);
        }
      }
    }
  } 
  //var a = fruits.indexOf("Apple");
  return finalArr;
}

sym([1, 2, 3], [5, 2, 1, 4]);

I would expect my splice and push arguments to create me an array based on all given arguments but I am only receiving the numbers I do not want to see. Any ideas?

willamgriffin
@willamgriffin
Apr 19 2016 01:51
@haraldur12 yes
Moisés Man
@moigithub
Apr 19 2016 01:51
ok.. u need to use some javscript to retrieve the user (value) input
Islam Ibakaev
@dagman
Apr 19 2016 01:52
i were doing Truncate string bonfire and finally find decision. Just curious is there an elegant decision. My decision is
function truncateString(str, num) {
  if(str.length > num) {
    if(num < 3) {
      str = str.slice(0, num) + '...';
    }
    else {
      str = str.slice(0, num - 3) + '...';
    }
  }
  return str;
}
willamgriffin
@willamgriffin
Apr 19 2016 01:52
i guess save is the operative word
Tyler
@tylergross
Apr 19 2016 01:52
I think my splice() parameters were wrong
Moisés Man
@moigithub
Apr 19 2016 01:55
@dagman str slice.. seems duplicated.. u can refactor i think
Tharun James
@xplorejames
Apr 19 2016 01:55
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(firstName, prop){
// Only change code below this line]
for (var x = 0; x < contacts.length; x++){
    if (contacts[x].firstName === firstName) {
        if (contacts[x][prop]) {
            return contacts[x][prop];
        } else {
            return "No such property";
        }
    }
}
return "No such contact";

}
// Only change code above this line


// Change these values to test your function
lookUp("Akira", "address");
Islam Ibakaev
@dagman
Apr 19 2016 01:56
@moigithub what u can offer?
Tharun James
@xplorejames
Apr 19 2016 01:56
Eveything is going great but it says nothing is correct . but the output is same
Moisés Man
@moigithub
Apr 19 2016 01:56

if(num<3) count = num else count=num-3
or

var count = num<3? num:num-3;   // ternary op
str = str.slice(0, count) + '...';

@dagman

Tyler
@tylergross
Apr 19 2016 01:57
can someone tell me the correct usage of Array.splice() to remove a value from an array?
Moisés Man
@moigithub
Apr 19 2016 01:58
@xplorejames check the uppercase or lowercase of ur messages
@xplorejames if all ok.. then refresh ur browser
if still dont work.. copy ur code, reset, paste, run again
Elbert Cortez
@trip16661
Apr 19 2016 02:13
function smallestCommons(arr) {
  var result,a = 0;
  var arrA = [];
  var arrB = [];
  while(arrA.indexOf(arrB[a]) === -1){
    a++;
    arrA.push(arr[0] * a);
    arrB.push(arr[1] * a);
    result = arrB[a];

  }
  return arrB;
}


smallestCommons([1,5]);
is my logic wrong ?
Moisés Man
@moigithub
Apr 19 2016 02:18
@trip16661 u need some math knowledge to complete that one....
i have to google for an algorithm cuz im no good at math :P
Boyce
@Yijianc
Apr 19 2016 02:19
@xplorejames u may check the prop if it's the property of contacts by hasOwnProperty function
Elbert Cortez
@trip16661
Apr 19 2016 02:23
@dagman is that chinese ? i don't get any
anything written there xD
@moigithub @dagman i guess i just have to read xD
friesenet21
@friesenet21
Apr 19 2016 02:25

for "Stand in Line" ```
function nextInLine(arr, item) {
arr.push(6);// Your code here
arr.shift(0);
return testArr0; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];
```do I need another function?

MiteyDrill
@MiteyDrill
Apr 19 2016 02:26
Still can't figure this out, how am I supposed to get the 'Charlie' to access the 'charlie' inside the object? http://prntscr.com/au0acb
friesenet21
@friesenet21
Apr 19 2016 02:26
return testArr[0];
Kyle Morton
@kmorton1988
Apr 19 2016 02:26
I'm seriously about to give up on this stupid twitch api project.
Moisés Man
@moigithub
Apr 19 2016 02:27
@friesenet21 shift() method give back the removed element...
inside ur function.. u should work with ur parameters only.. not with testArr
Tyler
@tylergross
Apr 19 2016 02:27
function sym(args) {
  var finalArr = [];
  var checkedArr = [];
  for(var i = 0; i < arguments.length; i++){
    for(var j = 0; j < arguments[i].length; j++){
      if((checkedArr.indexOf(arguments[i][j])) >= 0){
        checkedArr.push(arguments[i][j]);
      }else{
        if((finalArr.indexOf(arguments[i][j])) >= 0){
            finalArr.splice(finalArr.indexOf(arguments[i][j]), 1);
            checkedArr.push(arguments[i][j]);
        }else{
          finalArr.push(arguments[i][j]);
          checkedArr.push(arguments[i][j]);
        }
      }
    }
  }
  return finalArr;
}

sym([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5]);
does anyone see any errors here? I'm not getting the correct output and cannot figure out what i did wrong
MiteyDrill
@MiteyDrill
Apr 19 2016 02:27
You're close @friesenet21
Kyle Morton
@kmorton1988
Apr 19 2016 02:28
why do you have double parenthasis at the start of if((finalArr.indexof(arguments[i][j])) >= 0) @tylergross
Tyler
@tylergross
Apr 19 2016 02:29
for a math function, I just realized that and removed them and still didn't change the outcome @kmorton1988
Moisés Man
@moigithub
Apr 19 2016 02:29
@MiteyDrill u cant use dot notation with variables... use the other notation for object access
Kyle Morton
@kmorton1988
Apr 19 2016 02:30
what's the goal? @tylergross
Tyler
@tylergross
Apr 19 2016 02:31
@kmorton1988 the goal is to compare the first two arrays and return only the numbers that are unique. and then to compare the returned numbers against the third array and repeat the process
my thought process was compare the arrays in order and add values to a new array and a "check" array. then if the values were already in the array later on, to remove them with splice. or if the values were in the checked array, to skip and continue processing
Kyle Morton
@kmorton1988
Apr 19 2016 02:32
what's the name of that challenge?
Tyler
@tylergross
Apr 19 2016 02:32
@kmorton1988 symmetric difference
Islam Ibakaev
@dagman
Apr 19 2016 02:33
@trip16661 i have recently rebuild it
function smallestCommons(arr) {
  var array = range(arr);

  return array.reduce(function(x, y) {
   return scm(x, y); 
  });

  function range(arr) {
    var array = [],
        big = arr[0] > arr[1] ? arr[0] : arr[1],
        little = arr[0] > arr[1] ? arr[1] : arr[0];
    for (var i = little; i <= big; i++) {
      array.push(i);
    }
    return array;
  }

  function gcd (x, y) {
    return (x % y === 0) ? y : gcd(y, x%y);
  }

  function scm (x, y) {
    return (x * y) / gcd(x, y); 
  }

}
Kyle Morton
@kmorton1988
Apr 19 2016 02:33
Haven't gotten that far, yet. hmm.
MiteyDrill
@MiteyDrill
Apr 19 2016 02:33
Okay i'll try @moigithub
Tyler
@tylergross
Apr 19 2016 02:33
@dagman looks a lot more pretty than mine did
Moisés Man
@moigithub
Apr 19 2016 02:33
@tylergross if u check the arguments... it have 3 values(arrays passed)
Kyle Morton
@kmorton1988
Apr 19 2016 02:33
is there a gitter room specific for help with projects?
buonarfcc
@buonarfcc
Apr 19 2016 02:33

Hello anyone good evening .... Can anyone help me with a hint on what I have missed in applying the logic into proper object & prop notation? txs ->//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,lastName,number,likes, prop){
// Only change code below this line
for(var i=0; i < contacts.length; i++) {
contacts = contacts[i];
if (contacts.hasOwnProperty[firstName] && contacts.hasOwnProperty[prop] ){return contacts[prop];}
else if ( !contacts.hasOwnProperty[firstName] ){return "No such Property";}
else if ( !contacts.hasOwnProperty[firstName] && !contacts.haswOwnProperty[prop]){return "No such Property";}

else return "No such property";

}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "lastName");
so far I go -> only -> No such Property....:)

Moisés Man
@moigithub
Apr 19 2016 02:34
@tylergross
[1, 1, 2, 5],
[2, 2, 3, 5],
[3, 4, 5, 5]
Tyler
@tylergross
Apr 19 2016 02:34
@moigithub right that's why i ran a for loop to parse all given arguments
Moisés Man
@moigithub
Apr 19 2016 02:34
This message was deleted
This message was deleted
nvm
Tyler
@tylergross
Apr 19 2016 02:35
yeah im not using arr
I had it close at one point and then restructured my formula and now im stuck again ha
I found the problem
my code places everything i've checked into checked and quits there if it already exists in that array. What I should be doing is an else statement to check if it exists in the other array as well so i can remove it
Duncan T
@dtweedle
Apr 19 2016 02:46
Anyone here consider themselves clued up with Routing in Angular.js?
WilliamDecker
@WilliamDecker
Apr 19 2016 02:54
i'm having a hard time understanding how to correctly use the .filter() method, the MDN article doesn't make sense to me, does anyone else have a resource I could use that my prove more helpful?
missNasser
@missNasser
Apr 19 2016 02:54
hey can anyone help me with my comment box in javascript please
Frank XC
@tenkdayz
Apr 19 2016 02:55
@missNasser yup
missNasser
@missNasser
Apr 19 2016 02:56

I have created a comment box that will show me my comments but i would like to store in in the file its self here is an example of a web page that you can open and close and it will still save the data

<!DOCTYPE html>

<html>
<head>
<script>
function clickCounter() {
if(typeof(Storage) !== "undefined") {
if (localStorage.clickcount) {
localStorage.clickcount = Number(localStorage.clickcount)+1;
} else {
localStorage.clickcount = 1;
}
document.getElementById("result").innerHTML = "You have clicked the button " + localStorage.clickcount + " time(s).";
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support web storage...";
}
}
</script>
</head>
<body>
<p><button onclick="clickCounter()" type="button">Click me!</button></p>
<div id="result"></div>
<p>Click the button to see the counter increase.</p>
<p>Close the browser tab (or window), and try again, and the counter will continue to count (is not reset).</p>
</body>
</html>
i would like something similar like that but with my comment
<html>
<H1>SHOUTOUT!!!!!!!<H1>
<P>Welcome to shout out you can put what ever you want in this page</P>
<head>
<script>

function add_comment() {
var comments_div=document.getElementById('comments');
var comment=prompt("Please enter your comment");
comments_div.innerHTML+=comment+"<br/>";
}

</script>
</head>
<body>

<input type="button" onclick="add_comment()" value="Add comment">
<div id="comments"></div>

<script type="text/javascript">
function count()
{
var current= document.getElementById('show');
if (current.innerHTML == "")
{
current.innerHTML = 0;
var count = parseInt(current.innerHTML, 10) + parseInt(1);
current.innerHTML = count;
}
else
{
var count = parseInt(current.innerHTML, 10) + parseInt(1);
current.innerHTML = count;
}
}

function reset()
{
var current= document.getElementById('show');
current.innerHTML="";
}

function down()
{
var current= document.getElementById('show');
if (current.innerHTML == "")
{
current.innerHTML = 0;
var count = parseInt(current.innerHTML, 10) - parseInt(1);
current.innerHTML = count;
}
else
{
var count = parseInt(current.innerHTML, 10) - parseInt(1);
current.innerHTML = count;
}
}

</script>

<div id='show'></div>
<button onclick="count()">like</button>
<button onclick="down()">Dislike</button>
<button onclick="reset()">Undo</button>

</body>
</html>

Kyle B.
@manbearkyle
Apr 19 2016 02:58
anyone out there willing to help a brother out with challenge 226 (Golf Code)
missNasser
@missNasser
Apr 19 2016 02:59
@tenkdayz how are you doing
Frank XC
@tenkdayz
Apr 19 2016 03:00
@missNasser is that a challenge?
missNasser
@missNasser
Apr 19 2016 03:01
yes
Frank XC
@tenkdayz
Apr 19 2016 03:01
@missNasser whats the name?
missNasser
@missNasser
Apr 19 2016 03:01
is my own challenge
it is my own challenge and i would like help with it i just want to it to store comments in the file like in the counter
Frank XC
@tenkdayz
Apr 19 2016 03:03
@missNasser ok I see... are you using a database?
missNasser
@missNasser
Apr 19 2016 03:03
No i am not i want to use the html 5 local storage
Tyler Moore
@devopsec
Apr 19 2016 03:03

hey guys i keep getting error: fahrenheit not defined when i run this:function convertToF(celsius) {
// Only change code below this line
celsius = 30;
var farenheight = celsius * (9/5) + 32;

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

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

Frank XC
@tenkdayz
Apr 19 2016 03:04
@missNasser I'm not familiar with that..
Artur Sęp
@a-sep
Apr 19 2016 03:04
@manbearkyle use "if, else if" or "swich" :D
missNasser
@missNasser
Apr 19 2016 03:05
thats my challenge anyway and im struggling with it
Frank XC
@tenkdayz
Apr 19 2016 03:05
@missNasser I'll read on it ..if it's simple I'll take a second look.
ahitt6345
@ahitt6345
Apr 19 2016 03:06
@DevOps-redteam You spelled the second fahrenheight wrong
@DevOps-redteam On the return
Tyler Moore
@devopsec
Apr 19 2016 03:06
@ahitt6345 lmao thanks for letting me know I cant spell
CamperBot
@camperbot
Apr 19 2016 03:06
devops-redteam sends brownie points to @ahitt6345 :sparkles: :thumbsup: :sparkles:
:star: 31 | @ahitt6345 | http://www.freecodecamp.com/ahitt6345
Artur Sęp
@a-sep
Apr 19 2016 03:07
@DevOps-redteam you have typo :D "return fahrenheit;" is not a "var farenheight" :)
Kyle B.
@manbearkyle
Apr 19 2016 03:07

@a-sep I have every test passed except for the two pars. I'm stuck trying to get both of them to pass...

function golfScore(par, strokes) {
// Only change code below this line
if (par, strokes <= 1) {
return "Hole-in-one!";
}

else if (par, strokes <= 2) {
return "Eagle";
}

else if (par, strokes <= 3) {
return "Birdie";
}

else if (par, strokes <= 4) {
return "Par";
}

else if (par, strokes <= 5) {
return "Par";
}

else if (par, strokes <= 5) {
return "Bogey";
}

else if (par, strokes <= 6) {
return "Double Bogey";
}

else if (par, strokes >= 7) {
return "Go Home!";
}
// Only change code above this line
}

// Change these values to test
golfScore(4, 5);

Tyler Moore
@devopsec
Apr 19 2016 03:07
@a-sep got it! I learned how to spell haha thanks
CamperBot
@camperbot
Apr 19 2016 03:07
devops-redteam sends brownie points to @a-sep :sparkles: :thumbsup: :sparkles:
:star: 324 | @a-sep | http://www.freecodecamp.com/a-sep
Kristoforus Rua
@kru
Apr 19 2016 03:10

Hello, I need a help.

function fearNotLetter(str) {
  var strCode = [],
      flCode = [],
      initVal = str.codePointAt(str.charAt(0)),
      lastElm = str.charAt(str.length-1),
      endVal = str.codePointAt(lastElm);

console.log(initVal + '  and  ' + endVal);
console.log(initVal + ' and ' + lastElm);
}
fearNotLetter('abce')

result from the first console.log is 97 and 97, but second console.log output is 97 and e.
I want the output from the endVal = 101 which is char code from 'e'.

Artur Sęp
@a-sep
Apr 19 2016 03:11
@manbearkyle I think there is something wrong with in yours conditions "par, strokes "...
this is my solution:
  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 if(strokes>= par + 3)return    "Go Home!";

  else return "Change Me";
Kristoforus Rua
@kru
Apr 19 2016 03:11
*I want the output from the first console.log is endVal = 101 which is char code from 'e'.
Kyle B.
@manbearkyle
Apr 19 2016 03:15
@a-sep wow thank you so much! I never even thought of breaking the arguments like that. I have a bad tendency to keep the arguments in the same form as they appear after the function
CamperBot
@camperbot
Apr 19 2016 03:15
manbearkyle sends brownie points to @a-sep :sparkles: :thumbsup: :sparkles:
:star: 325 | @a-sep | http://www.freecodecamp.com/a-sep
Artur Sęp
@a-sep
Apr 19 2016 03:16
@manbearkyle :+1:
Kyle B.
@manbearkyle
Apr 19 2016 03:18
what's the trick to displaying code same way it appears in the editor?
Jan Nissi Harrison
@NissiHarrison
Apr 19 2016 03:18
pls help me
//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
if (firstName==contacts[firstName]&&contacts.hasownProperty(prop)){
  return contacts[prop];
}
  else if(firstName!=contacts[firstName]){
    return "No such contact";
  }
  else if(prop!=contacts[prop]){
    return "No such property";
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Nathan
@natertot12
Apr 19 2016 03:18
@krua It returns 97 and e for me is that what you want?
Kristoforus Rua
@kru
Apr 19 2016 03:21
yes @natertot12, but when we take the variable lastElm as the argument of endVal it will show 97 instead of 101.
Frank XC
@tenkdayz
Apr 19 2016 03:23
@missNasser you have like 6 body tags and 4 head tags..
Nathan
@natertot12
Apr 19 2016 03:24
@krua Instead of doing it the way you are, I suggest that you use a for loop to go through the str
missNasser
@missNasser
Apr 19 2016 03:24
?
Benjamin Gonzalez
@xasuma
Apr 19 2016 03:25
Can someone help me get my toggle button working please? I have been trying all alfernoon. lol
http://codepen.io/xasuma/pen/ONQXGO
missNasser
@missNasser
Apr 19 2016 03:27
@tenkdayz did you split the two codes up
Nathan
@natertot12
Apr 19 2016 03:27
@xasuma Whats wrong about it?
missNasser
@missNasser
Apr 19 2016 03:27
@tenkdayz this is the counter code

<!DOCTYPE html>

<html>
<head>
<script>
function clickCounter() {
if(typeof(Storage) !== "undefined") {
if (localStorage.clickcount) {
localStorage.clickcount = Number(localStorage.clickcount)+1;
} else {
localStorage.clickcount = 1;
}
document.getElementById("result").innerHTML = "You have clicked the button " + localStorage.clickcount + " time(s).";
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support web storage...";
}
}
</script>
</head>
<body>
<p><button onclick="clickCounter()" type="button">Click me!</button></p>
<div id="result"></div>
<p>Click the button to see the counter increase.</p>
<p>Close the browser tab (or window), and try again, and the counter will continue to count (is not reset).</p>
</body>
</html>

Frank XC
@tenkdayz
Apr 19 2016 03:28
@missNasser I dont think it changed anything.. I just made it more understandable for myself
missNasser
@missNasser
Apr 19 2016 03:28
and this one is my comment box
<html>
<H1>SHOUTOUT!!!!!!!<H1>
<P>Welcome to shout out you can put what ever you want in this page</P>
<head>
<script>

function add_comment() {
var comments_div=document.getElementById('comments');
var comment=prompt("Please enter your comment");
comments_div.innerHTML+=comment+"<br/>";
}

</script>
</head>
<body>

<input type="button" onclick="add_comment()" value="Add comment">
<div id="comments"></div>

<script type="text/javascript">
function count()
{
var current= document.getElementById('show');
if (current.innerHTML == "")
{
current.innerHTML = 0;
var count = parseInt(current.innerHTML, 10) + parseInt(1);
current.innerHTML = count;
}
else
{
var count = parseInt(current.innerHTML, 10) + parseInt(1);
current.innerHTML = count;
}
}

function reset()
{
var current= document.getElementById('show');
current.innerHTML="";
}

function down()
{
var current= document.getElementById('show');
if (current.innerHTML == "")
{
current.innerHTML = 0;
var count = parseInt(current.innerHTML, 10) - parseInt(1);
current.innerHTML = count;
}
else
{
var count = parseInt(current.innerHTML, 10) - parseInt(1);
current.innerHTML = count;
}
}

</script>

<div id='show'></div>
<button onclick="count()">like</button>
<button onclick="down()">Dislike</button>
<button onclick="reset()">Undo</button>

</body>
</html>
Benjamin Gonzalez
@xasuma
Apr 19 2016 03:28
@natertot12 when you press it, the Celsius don't show up. I can't get them to show up. I can either toggle them both on and off, or fharenheit and toggle it off.
Frank XC
@tenkdayz
Apr 19 2016 03:29
@missNasser I have both.. just trying to see whats going on.
Kristoforus Rua
@kru
Apr 19 2016 03:29
@natertot12 I wondering why the initVal can work with str.charAt(0) but endVal with str.charAt(str.length-1) doesn't return last element of string.
missNasser
@missNasser
Apr 19 2016 03:29
@tenkdayz well what i want to do is just store the comments in a facebook style i know you can use a database like mysql ect but i want to use local storage using html 5
Frank XC
@tenkdayz
Apr 19 2016 03:32
@missNasser is clickcount a property of localStorage?
I'm guessing it isnt
missNasser
@missNasser
Apr 19 2016 03:32
I dont much about the local storage but i would like to use it with my comment box
I had a go editing it and i did have success
Nathan
@natertot12
Apr 19 2016 03:34
@krua str.charAt(str.length-1) is returning the last element for me, but there is not really any reason to look at the last element in the str
Frank XC
@tenkdayz
Apr 19 2016 03:36
@missNasser how is localStorage used.. in the wild
Kristoforus Rua
@kru
Apr 19 2016 03:37
@natertot12 how about console.log(initVal + ' and ' + endVal);
is it returns 97 and 101 for you?
missNasser
@missNasser
Apr 19 2016 03:37
its like a cookie it stores information
Nathan
@natertot12
Apr 19 2016 03:39
@krua Use this
lastElm = str.length-1,
      endVal = str.charCodeAt(lastElm);
Kristoforus Rua
@kru
Apr 19 2016 03:40
@natertot12 I want to compare two of two array of char code to find the missing one, so I need the last element of string to create .
ok, let me try it.
Xavier Artot
@xavierartot
Apr 19 2016 03:42
hi
who's used json and the method getJson
buonarfcc
@buonarfcc
Apr 19 2016 03:42
@NissiHarrison I think you still need this -> iteration process before anything else? for(var i=0;i<contacts.length;i++)?
Xavier Artot
@xavierartot
Apr 19 2016 03:42
my alert() method retrieve nothing
Nathan
@natertot12
Apr 19 2016 03:43
@xavierartot Can you paste your code?
Kristoforus Rua
@kru
Apr 19 2016 03:43
thank you @natertot12 it works now :)
CamperBot
@camperbot
Apr 19 2016 03:43
krua sends brownie points to @natertot12 :sparkles: :thumbsup: :sparkles:
:star: 436 | @natertot12 | http://www.freecodecamp.com/natertot12
Xavier Artot
@xavierartot
Apr 19 2016 03:43
        $.getJSON( "test.json", function( data ) {
          alert('dddd');
          var items = [];
          $.each( data, function( key, val ) {
            items.push( "<li id='" + key + "'>" + val + "</li>" );
          });

          $( "<ul/>", {
            "class": "my-new-list",
            html: items.join( "" )
          }).appendTo( "body" );
        });
WilliamDecker
@WilliamDecker
Apr 19 2016 03:43
help Falsy Bouncer
CamperBot
@camperbot
Apr 19 2016 03:43

:point_right: algorithm falsy bouncer [wiki]

Problem Explanation:

Remove all falsy values from an array.

:pencil: read more about algorithm falsy bouncer on the FCC Wiki

Nathan
@natertot12
Apr 19 2016 03:44
@xavierartot What url are you trying to get?
Xavier Artot
@xavierartot
Apr 19 2016 03:44
a json file, test.json in the same directorie
{
  {
    'name'   :   'Frid',
    'age'    :   2,
    'color'  :   'gray'
  },
  {
    'name'   :   'sist',
    'age'    :   3,
    'color'  :   'white'
  }
}
but at least I'd like to have a console.log or alert...
I have no error, my console is just empty?
Nathan
@natertot12
Apr 19 2016 03:47
@xavierartot Maybe its because of chrome's security? http://stackoverflow.com/questions/7346563/loading-local-json-file
Xavier Artot
@xavierartot
Apr 19 2016 03:48
no way?
WilliamDecker
@WilliamDecker
Apr 19 2016 03:49
i spent so long reading the MDN article on the .filter() method, and the code required to do the Falsy Bouncer problem was so small compared to what I thought it was
Nathan
@natertot12
Apr 19 2016 03:50
@xavierartot Maybe this will work? http://codepen.io/KryptoniteDove/post/load-json-file-locally-using-pure-javascript I have to go sorry
Xavier Artot
@xavierartot
Apr 19 2016 03:51
doesn't make sense, I'll try with firefox...
AaronCs
@AaronCs
Apr 19 2016 03:51
I am so confused on using the twitter api
Does someone have a good place for me to learn how to use apis?
Frank XC
@tenkdayz
Apr 19 2016 03:53
@missNasser I think i got it
missNasser
@missNasser
Apr 19 2016 03:53
@tenkdayz great :)
Frank XC
@tenkdayz
Apr 19 2016 03:54
@missNasser I mean i got to store a string
AaronCs
@AaronCs
Apr 19 2016 03:55
I guess not
missNasser
@missNasser
Apr 19 2016 03:56
@tenkdayz can i see please
@missNasser store string button shows the string.
missNasser
@missNasser
Apr 19 2016 04:07
looking good we can get rid of the clicker button
is it possible to get the comments and likes simlar to a facebook style so one under another saying how many likes ect
Frank XC
@tenkdayz
Apr 19 2016 04:13
@missNasser sure.. but I'll be working on something else right now. this is new to me but it's good to know about.
you can localStore.setItem() to anything it seems
missNasser
@missNasser
Apr 19 2016 04:15
how would i add that to anything
an example
Frank XC
@tenkdayz
Apr 19 2016 04:18
@missNasser you can inspect the page to see it but anyhow. something like
var str = doc.getElebyid().value;
localStorage.setItem("foo",str);
then to recall localStorage.getItem("foo");
Amor Kumar
@itsamoreh
Apr 19 2016 04:19

hey everyone, I'm on the "Testing Objects for Properties" exercise and I was wondering if anyone could tell me why this returns the property:

return myObj[checkProp];

and this was not returning anything:

return myObj.checkProp;

checkProp is a string.

missNasser
@missNasser
Apr 19 2016 04:23
@tenkdayz is there anyway it can work with out intenet access
Frank XC
@tenkdayz
Apr 19 2016 04:26
@missNasser dont think so.
missNasser
@missNasser
Apr 19 2016 04:26
the add item is only working once now
Alex Myers
@qckpckt
Apr 19 2016 04:26
Hi all, looking to get some feedback on my solution to the title case a sentence challenge. I got it working but I feel like I could simplify my solution.
whats the best way for me to submit it so that its not a spoiler?
Frank XC
@tenkdayz
Apr 19 2016 04:28
@missNasser in your code or mine?
missNasser
@missNasser
Apr 19 2016 04:29
your code
Prithvi-A
@Prithvi-A
Apr 19 2016 04:29
How to solve Using Objects for Lookups?
I'm stuck here
Frank XC
@tenkdayz
Apr 19 2016 04:31
@missNasser it's working ..
Prithvi-A
@Prithvi-A
Apr 19 2016 04:31
Anyone who has already worked on it?
Dmitry
@DmitryShutov
Apr 19 2016 04:31
@itsamoreh string is not a valid identifier you can read about on MDN -> property accessors
Norvin Burrus
@ndburrus
Apr 19 2016 04:31
@Prithvi-A Do you want assistance with Using Objects for Lookups?
Prithvi-A
@Prithvi-A
Apr 19 2016 04:32
yes
Norvin Burrus
@ndburrus
Apr 19 2016 04:32
@Prithvi-A ok, I may be able to assist. What's going on?
Prithvi-A
@Prithvi-A
Apr 19 2016 04:32
The instruction says - Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.
Does this mean I need to create a new lookup table from scartch?
Amor Kumar
@itsamoreh
Apr 19 2016 04:33
@DmitryShutov that's perfect! thank you very much!
CamperBot
@camperbot
Apr 19 2016 04:33
itsamoreh sends brownie points to @dmitryshutov :sparkles: :thumbsup: :sparkles:
:star: 369 | @dmitryshutov | http://www.freecodecamp.com/dmitryshutov
Norvin Burrus
@ndburrus
Apr 19 2016 04:34
@Prithvi-A ok, so we're going to need a lookup table. then, we're going to use the lookup table (a variable) to lookup the value in a key value pair.
@Prithvi-A can you post ur code?
@Prithvi-A I believe u can use the table already presented (it has the needed corresponding values)
@Prithvi-A alpha - foxtroxt & adams - frank
Norvin Burrus
@ndburrus
Apr 19 2016 04:40
js
<    var lookup = {
    "alpha":"Adams",
    "bravo":"Boston",
    "charlie":"Chicago",
    "delta":"Denver",
    "echo":"Easy",
    "foxtrot":"Frank",
  };>
@Prithvi-A does this help?
Jan Nissi Harrison
@NissiHarrison
Apr 19 2016 04:42
help me please
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {

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

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

var myCar = new Car();

var myBike = new Bike();
myBike.setGear(4);
CamperBot
@camperbot
Apr 19 2016 04:42
no wiki entry for: me pleasevar car function this is a private variable var speed 10 these are public methods thisaccelerate functionchange speed change thisdecelerate function speed - 5 thisgetspeed function return speed var bike function only change code below this linevar gear thissetgearfunctionchange changegear thisgetgearfunction return gear var mycar new carvar mybike new bikemybikesetgear4
Jan Nissi Harrison
@NissiHarrison
Apr 19 2016 04:44
help Make Object Properties Private
CamperBot
@camperbot
Apr 19 2016 04:44

:point_right: challenge make object properties private [wiki]

Objects have their own attributes, called properties_, and their own functions, called _methods.

You can use the this keyword to reference public properties and methods of the current objects. However, when You need to create private ones so they are not accessible from the outside of the object you just remove the keyword this from the object property or method declaration and declare it with var so that it is private outside its scope.

var Bike = function() {
  var speed = 100; // private
  function addUnit(value) { // private
    return value + "KM/H";
  }

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

};

Another example:

:pencil: read more about challenge make object properties private on the FCC Wiki

HunterHelms
@HunterHelms
Apr 19 2016 04:51
i honestly have no idea how to 175 word blanks
to do*
cannelflow
@cannelflow
Apr 19 2016 04:55
@HunterHelms make a sentence using input variable in function
Prithvi-A
@Prithvi-A
Apr 19 2016 05:02
@ndburrus
// Setup
function phoneticLookup(val) {
  var result = "";

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

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

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

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

(function lookup(val) {
  var result = lookup.val;
  return result;
})();

lookup("charlie");
still get errors
phoneticLookup("") should equal undefined
You should not use case, switch, or if statements
Norvin Burrus
@ndburrus
Apr 19 2016 05:03
@Prithvi-A ok, let me get back to that one...
MiteyDrill
@MiteyDrill
Apr 19 2016 05:03
You're putting the code in the wrong place
gotta replace the (switch) code with anObject{};
and then call it
also you're using dot notation, in this case you gotta use another type of notation cause dot notation will cause the function to search for 'val' instead of what the value input is
Norvin Burrus
@ndburrus
Apr 19 2016 05:05
@Prithvi-A ok, u need to delete the switch code. also, place ur var lookup code in the proper position
js
<(function lookup(val) {
  var result = lookup.val;
  return result;
})();>
@Prithvi-A of that code, only use "result = lookup[val];"
@Prithvi-A finally, use phoneticLookup (not just "lookup") as the example code does. and u should be fine.
Norvin Burrus
@ndburrus
Apr 19 2016 05:14
are there any other questions i might be able to assist with?
MiteyDrill
@MiteyDrill
Apr 19 2016 05:38
yo
GowthamReddyAmbati
@GowthamReddyAmbati
Apr 19 2016 05:46

Hi Team, Would you please let me know what is the wrong with this code.. ```
function largestOfFour(arr) {
// You can do this!
var largestarr =[0,0,0,0];

for(var i=0;i<arr.length;i++){
for(var j=0; j<arr[i].lenght;j++)
{
if(largestarr[i] < arr[i][j])
{
largestarr[i] = arr[i][j];

     }

  }

}
return largestarr;

}

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

```

Matt Green
@mattxgreen
Apr 19 2016 05:48
@GowthamReddyAmbati typo on arr.length
GowthamReddyAmbati
@GowthamReddyAmbati
Apr 19 2016 05:49
@mattxgreen Thank you
CamperBot
@camperbot
Apr 19 2016 05:49
gowthamreddyambati sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 457 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
Matt Green
@mattxgreen
Apr 19 2016 05:49
@GowthamReddyAmbati creative solution... haven't seen that one yet
most people .sort then return the arr[i][0]
MiteyDrill
@MiteyDrill
Apr 19 2016 05:50
Having the hardest time trying to insert stuff into JSON objects :(!
Matt Green
@mattxgreen
Apr 19 2016 05:51
@MiteyDrill post it, I have time for one more
MiteyDrill
@MiteyDrill
Apr 19 2016 05:52

http://prntscr.com/au1lfb

So i'm supposed to replace stuff and delete st00f but I have no idea where to start :(

I make an if statement like if(collection['value'] !== '' && collection[prop] !== "tracks") but idk if that's right
Are there things I can review?
missNasser
@missNasser
Apr 19 2016 05:53
can anyone help me with my comment box using html 5 local storage just to store comments
Matt Green
@mattxgreen
Apr 19 2016 05:54
@MiteyDrill you're close
missNasser
@missNasser
Apr 19 2016 05:55
<html>
<H1>SHOUTOUT!!!!!!!<H1>
<P>Welcome to shout out you can put what ever you want in this page</P>
<head>
<script>

function add_comment() {
var comments_div=document.getElementById('comments');
var comment=prompt("Please enter your comment");
comments_div.innerHTML+=comment+"<br/>";
}

</script>
</head>
<body>

<input type="button" onclick="add_comment()" value="Add comment">
<div id="comments"></div>

<script type="text/javascript">
function count()
{
var current= document.getElementById('show');
if (current.innerHTML == "")
{
current.innerHTML = 0;
var count = parseInt(current.innerHTML, 10) + parseInt(1);
current.innerHTML = count;
}
else
{
var count = parseInt(current.innerHTML, 10) + parseInt(1);
current.innerHTML = count;
}
}

function reset()
{
var current= document.getElementById('show');
current.innerHTML="";
}

function down()
{
var current= document.getElementById('show');
if (current.innerHTML == "")
{
current.innerHTML = 0;
var count = parseInt(current.innerHTML, 10) - parseInt(1);
current.innerHTML = count;
}
else
{
var count = parseInt(current.innerHTML, 10) - parseInt(1);
current.innerHTML = count;
}
}

</script>

<div id='show'></div>
<button onclick="count()">like</button>
<button onclick="down()">Dislike</button>
<button onclick="reset()">Undo</button>

</body>
</html>
here is my comment box
i want to store comments using local storage i want to store the comments in the .html file its self
V Arun Kumar
@arunvkumr
Apr 19 2016 05:55
@MiteyDrill you got that almost right, each object has an id value, you have to use those id values to check in collection object instead of value.
MiteyDrill
@MiteyDrill
Apr 19 2016 05:56
@mattxgreen Thx matt for the comforting words rofl xD I'll keep trying to analyze whatever is going on
CamperBot
@camperbot
Apr 19 2016 05:56
miteydrill sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 458 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
MiteyDrill
@MiteyDrill
Apr 19 2016 05:56
@arunkumrv lol thx Arun x(!
CamperBot
@camperbot
Apr 19 2016 05:56
miteydrill sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 474 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Matt Green
@mattxgreen
Apr 19 2016 05:56
@MiteyDrill this is probably closer if(collection[prop].length && collection[prop] !== "tracks")
MiteyDrill
@MiteyDrill
Apr 19 2016 05:57
Oh I see .length converts it to a number
nice
That helps a bunch thx
Matt Green
@mattxgreen
Apr 19 2016 05:58
and 0 is falsy... so if it HAS LENGTH
MiteyDrill
@MiteyDrill
Apr 19 2016 05:58
Ye I see
Matt Green
@mattxgreen
Apr 19 2016 05:59
@MiteyDrill try be patient with the people trying to help you in the future.
MiteyDrill
@MiteyDrill
Apr 19 2016 06:00
Lol srry i'm trying to be as thankful as possible D:!
missNasser
@missNasser
Apr 19 2016 06:00
can anyone help me
Matt Green
@mattxgreen
Apr 19 2016 06:01
I appreciate the gratitude, gl with the rest
@missNasser did you try the frontend room?
missNasser
@missNasser
Apr 19 2016 06:02
No I havent
My question is to do with javascript
I have created a comment box but i would like to store my comments using html 5 local storage like it is used in this code

<!DOCTYPE html>

<html>
<head>
<script>
function clickCounter() {
if(typeof(Storage) !== "undefined") {
if (localStorage.clickcount) {
localStorage.clickcount = Number(localStorage.clickcount)+1;
} else {
localStorage.clickcount = 1;
}
document.getElementById("result").innerHTML = "You have clicked the button " + localStorage.clickcount + " time(s).";
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support web storage...";
}
}
</script>
</head>
<body>
<p><button onclick="clickCounter()" type="button">Click me!</button></p>
<div id="result"></div>
<p>Click the button to see the counter increase.</p>
<p>Close the browser tab (or window), and try again, and the counter will continue to count (is not reset).</p>
</body>
</html>

that code is my counter that stores how many times the button is clicked but i would like a simlar thing but to store my comments
this is my comment box here
<html>
<H1>SHOUTOUT!!!!!!!<H1>
<P>Welcome to shout out you can put what ever you want in this page</P>
<head>
<script>

function add_comment() {
var comments_div=document.getElementById('comments');
var comment=prompt("Please enter your comment");
comments_div.innerHTML+=comment+"<br/>";
}

</script>
</head>
<body>

<input type="button" onclick="add_comment()" value="Add comment">
<div id="comments"></div>

<script type="text/javascript">
function count()
{
var current= document.getElementById('show');
if (current.innerHTML == "")
{
current.innerHTML = 0;
var count = parseInt(current.innerHTML, 10) + parseInt(1);
current.innerHTML = count;
}
else
{
var count = parseInt(current.innerHTML, 10) + parseInt(1);
current.innerHTML = count;
}
}

function reset()
{
var current= document.getElementById('show');
current.innerHTML="";
}

function down()
{
var current= document.getElementById('show');
if (current.innerHTML == "")
{
current.innerHTML = 0;
var count = parseInt(current.innerHTML, 10) - parseInt(1);
current.innerHTML = count;
}
else
{
var count = parseInt(current.innerHTML, 10) - parseInt(1);
current.innerHTML = count;
}
}

</script>

<div id='show'></div>
<button onclick="count()">like</button>
<button onclick="down()">Dislike</button>
<button onclick="reset()">Undo</button>

</body>
</html>
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 19 2016 06:06
Hello every one
I need a help
Matt Green
@mattxgreen
Apr 19 2016 06:08
@missNasser ok, so how are your JS abilities?
missNasser
@missNasser
Apr 19 2016 06:08
basic
V Arun Kumar
@arunvkumr
Apr 19 2016 06:08
@malangaveuday post your code.
missNasser
@missNasser
Apr 19 2016 06:09
I haven`t coded in a while but i came across this code and i would like to make my comment box store comments
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 19 2016 06:09
I am working on virtual keyboard
i want to change my input string change uppercase to lowercase randomly with every string character hold its text-transfer property
Matt Green
@mattxgreen
Apr 19 2016 06:10
Ok, and you realize the comments will only be stored on the computer of the person who enters a comment? So my comment will only be visible to me.
missNasser
@missNasser
Apr 19 2016 06:10
yeah
I tidy'd up your JS a bit, you had a ton of duplicate declarations...
<html>
<H1>SHOUTOUT!!!!!!!
    <H1>
        <P>Welcome to shout out you can put what ever you want in this page</P>
        <head>
            <script>
                function add_comment() {
                    var comments_div = document.getElementById('comments');
                    var comment = prompt("Please enter your comment");
                    comments_div.innerHTML += comment + "<br/>";
                }
            </script>
        </head>
        <body>

        <input type="button" onclick="add_comment()" value="Add comment">

        <div id="comments"></div>

        <script type="text/javascript">
            function count() {
                var current = document.getElementById('show');
                if (current.innerHTML == "") {
                    current.innerHTML = parseInt(current.innerHTML, 10) + parseInt(1);
                }
                else {
                    current.innerHTML = parseInt(current.innerHTML, 10) + parseInt(1);
                }
            }

            function reset() {
                var current = document.getElementById('show');
                current.innerHTML = "";
            }

            function down() {
                var current = document.getElementById('show');
                if (current.innerHTML == "") {
                    current.innerHTML = parseInt(current.innerHTML, 10) - parseInt(1);
                }
                else {
                    current.innerHTML = parseInt(current.innerHTML, 10) - parseInt(1);
                }
            }
        </script>

        <div id='show'></div>
        <button onclick="count()">like</button>
        <button onclick="down()">Dislike</button>
        <button onclick="reset()">Undo</button>

        </body>
</html>
Shivam Arora
@shivamarora13
Apr 19 2016 06:13
I need to call a same function, 1 time, if person performs correct action, than 2 times, if again perform correct action, than 3 times, than so on. can anyone help
V Arun Kumar
@arunvkumr
Apr 19 2016 06:13
@malangaveuday so it's like if i enter HELLO it can return hElLo or heLLOetc.. like this?
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 19 2016 06:14
yeah
Zach
@Moose1551
Apr 19 2016 06:14
Okay, I think I'm somewhat on the right track with "Title Case a Sentence" (Probably not at all, actually). Can someone take a looksy at my code? I put comments inside trying to explain my thought process.
function titleCase(str) {
  var allLowerString = str.toLowerCase().split(" "); //splits each element into array with all lowercase
   //not sure what to do here
  for (var i = 0; i <= allLowerString.length - 1; i++) { //I know that .length - 1 goes through the whole array, doesn't it? But how do I apply it to the first character of each word? Do I need to use more methods like toUpperCase(), etc?  
  allLowerString *= [i]; //can't figure out how to apply the loop
  }
  return allLowerString; 
}

titleCase("I'm a little tea pot");
```
V Arun Kumar
@arunvkumr
Apr 19 2016 06:15
@malangaveuday you are about to start or you have some code to work on?
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 19 2016 06:15
@arunkumrv example Hello Every One
yeah i have code
Matt Green
@mattxgreen
Apr 19 2016 06:16
@shivamarora13 I can prolly help
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 19 2016 06:16
(function(){
    var keyValue="";


    //  print value in input text box
      function printClick(){
         $("#text-box").val(keyValue);
     };

    //  general keys click function
     $(".key").on("click", function(){
        keyValue += $(this).text();
        printClick();
     });


    // backspace key function
    $("#backSpace").on("click", function(){
        keyValue = keyValue.slice(0,-1);
        printClick();
    });

    //clear key function
    $("#clear-text").on("click", function(){
        keyValue = "";
        printClick();
    });

    //space key function
    $("#space-key").on("click", function(){
        keyValue += " ";
        printClick();
    });

    //all keys capital
    $("#caps-key").on("click",function(){
        $(".key").toggleClass("key-caps");
        if($("#text-box").hasClass("key-caps")){
            $("#text-box").removeClass("key-caps");
        }else{
            $("#text-box").addClass("key-caps");
        }
    });
})();
Matt Green
@mattxgreen
Apr 19 2016 06:16
@shivamarora13 you got code?
V Arun Kumar
@arunvkumr
Apr 19 2016 06:18
@shivamarora13 if he performs correct then call the function again or call the function twice?
missNasser
@missNasser
Apr 19 2016 06:18
thats not working at all for me
<html>
<H1>SHOUTOUT!!!!!!!<H1>
<P>Welcome to shout out you can put what ever you want in this page</P>
<head>
<script>

function add_comment() {
var comments_div=document.getElementById('comments');
var comment=prompt("Please enter your comment");
comments_div.innerHTML+=comment+"<br/>";
}

</script>
</head>
<body>

<input type="button" onclick="add_comment()" value="Add comment">
<div id="comments"></div>

<script type="text/javascript">
function count()
{
var current= document.getElementById('show');
if (current.innerHTML == "")
{
current.innerHTML = 0;
var count = parseInt(current.innerHTML, 10) + parseInt(1);
current.innerHTML = count;
}
else
{
var count = parseInt(current.innerHTML, 10) + parseInt(1);
current.innerHTML = count;
}
}

function reset()
{
var current= document.getElementById('show');
current.innerHTML="";
}

function down()
{
var current= document.getElementById('show');
if (current.innerHTML == "")
{
current.innerHTML = 0;
var count = parseInt(current.innerHTML, 10) - parseInt(1);
current.innerHTML = count;
}
else
{
var count = parseInt(current.innerHTML, 10) - parseInt(1);
current.innerHTML = count;
}
}
localStorage.setItem('add comment','');

var = localStorage.getItem('add comment');
// -> "vanilla"
</script>

<div id='show'></div>
<button onclick="count()">like</button>
<button onclick="down()">Dislike</button>
<button onclick="reset()">Undo</button>

</body>
</html>
Shivam Arora
@shivamarora13
Apr 19 2016 06:20
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 19 2016 06:20
@arunkumrv you get my problem?
Shivam Arora
@shivamarora13
Apr 19 2016 06:20
Please see, if you can help.
V Arun Kumar
@arunvkumr
Apr 19 2016 06:21
@malangaveuday i'm looking into it.. :smile:
Matt Green
@mattxgreen
Apr 19 2016 06:22
@shivamarora13 you'll have to get more specific at what you need help with
Shivam Arora
@shivamarora13
Apr 19 2016 06:23
@mattxgreen ok, I have a function with name showBox() in my code, basically, when it runs for the first time, and user perform correct action, it should now run two times, and wait for two responses and match the responses of user, it correct, it works again, and now for 3 times, and do the same thing.
V Arun Kumar
@arunvkumr
Apr 19 2016 06:23
@malangaveuday can you share your pen?
Shivam Arora
@shivamarora13
Apr 19 2016 06:23
if u got it? :|
@mattxgreen
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 19 2016 06:24
@arunkumrv :smile:
Matt Green
@mattxgreen
Apr 19 2016 06:25
@shivamarora13 you're going to have to restructure your approach
missNasser
@missNasser
Apr 19 2016 06:26
i have found this that works

<!doctype html>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

<title>HTML5 Local Storage</title>
<link rel="stylesheet" href="css/style.css?v=2">
<script src="js/libs/modernizr-1.7.min.js"></script>
</head>

<body >

<div id="wrapper" align="center">
<section id="tutorial">
<article id="demo" class="altura">
<h2>HTML5 Local Storage</h2>
<p>Please Enter your name here.</p>

        <ul id="lista" contenteditable="true">
          <li>&nbsp;</li>
        </ul>
        <p>Please refresh it.even the data cant be loosed</p>
        <button id="limpar">Clear Me</button>
    </article>
</section>

</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js"></script>
<script>window.jQuery || document.write("<script src='js/libs/jquery-1.5.1.min.js'></script>")</script>
<script type="text/javascript">
$(function() {

    if (Modernizr.localstorage) {

        $("#lista").keypress(function() {
            localStorage.setItem('dados', $("#lista").html());
        });

        if (localStorage.getItem('dados')) {
            $("#lista").html(localStorage.getItem('dados'));
        }

        $("#limpar").click(function() {
            localStorage.clear();
            window.location = window.location;
        });

    } 
    else {
        alert ("Seu browser não tem suporte a API Storage =/");
    }

});

</script>

<script src="js/prevent.js"></script>

</body>
</html>

is there anyway i could make a like under them and make it store that too
Shivam Arora
@shivamarora13
Apr 19 2016 06:27
@mattxgreen can you make me understand how, and why?
Matt Green
@mattxgreen
Apr 19 2016 06:27
@shivamarora13 you should hold the random selections in an array, then iterate over the array, and verify the user presses match the array as the user makes selections until the user has made (#)array.length selections. At that point you'd make a new random selection, push it onto the array, and display to user (repeat)
Shivam Arora
@shivamarora13
Apr 19 2016 06:29
ok, so u r saying, that I put one random element at once, if user performs right action, than I push one more random array, and check the array of userResponse, and do it again and again?
right?
@mattxgreen
V Arun Kumar
@arunvkumr
Apr 19 2016 06:31
@shivamarora13 i don't know whether this solves your problem, you can try this..
create 2 for loops, the inner loop can be used to call the function, for first try inner loop n take as 1 and after inner for loop you can call the function which returns the user is correct or not based on take increament the value of n and the outer for loop will take care of how many times the inner loop needs to be called.
@malangaveuday can you share you codepen link?
Matt Green
@mattxgreen
Apr 19 2016 06:31
@shivamarora13 not quite... generate your first random selection, and play it to the user, then wait for input. After each input you will incriment a var tracking how many inputs the user has made, which correlates to the index of the random selection array to test
after making one correct selection, generate a new random selection, and push it onto that array, then play those 2. Your function to display to the user should just iterate over the array. If there is 1 item on the array, it'll only run once, but with 10 it'll run 10 times (etc)
Shivam Arora
@shivamarora13
Apr 19 2016 06:33
@arunkumrv this is also I right, I think it can solve my problem.
@mattxgreen ok, I got you. I am trying to work on it. Hope to get it sorted this way!
thanks!
@arunkumrv thanks!
CamperBot
@camperbot
Apr 19 2016 06:34
shivamarora13 sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 475 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Shivam Arora
@shivamarora13
Apr 19 2016 06:34
@mattxgreen thanks : )
CamperBot
@camperbot
Apr 19 2016 06:34
shivamarora13 sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 459 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
Jesus Vega
@ParagonChuy
Apr 19 2016 06:47
help Drop It
CamperBot
@camperbot
Apr 19 2016 06:47

:point_right: algorithm drop it [wiki]

Explanation:

Basically while the second argument is not true, you will have to remove the first element from the left of the array that was passed as the first argument.

:pencil: read more about algorithm drop it on the FCC Wiki

Jesus Vega
@ParagonChuy
Apr 19 2016 06:51
Who here has done the drop[ it algorithm?
Mahmoud Abdulazim
@aze3ma
Apr 19 2016 06:52
Hi there!
var myStr = "<a href='http://www.example.com' target='_blank'>Link</a>";
I think something gonna wrong with me
Ankit Padia
@InsaneSkull
Apr 19 2016 06:52
@aze3ma what?
buiphuking
@buiphuking
Apr 19 2016 06:52

hi guys, i do Exact Change, someone explain

["QUARTER", 2.05]

how many quarters do we have, and the formula to get that number . plz

Mahmoud Abdulazim
@aze3ma
Apr 19 2016 06:53
Remove all the backslashes \
You should have two single quotes' and four double quotes "
Only remove the backslashes \ used to escape quotes.
@InsaneSkull I think I make it right ?
Ankit Padia
@InsaneSkull
Apr 19 2016 06:54
@aze3ma challenge name?
Mahmoud Abdulazim
@aze3ma
Apr 19 2016 06:57
Quoting Strings with Single Quotes
Ankit Padia
@InsaneSkull
Apr 19 2016 06:58
@aze3ma it's var myStr = '<a href="http://www.example.com" target="_blank">Link</a>'; single quote whole string. misunderstanding of you.
Mahmoud Abdulazim
@aze3ma
Apr 19 2016 07:00
@InsaneSkull Thank you !
CamperBot
@camperbot
Apr 19 2016 07:00
aze3ma sends brownie points to @insaneskull :sparkles: :thumbsup: :sparkles:
:star: 323 | @insaneskull | http://www.freecodecamp.com/insaneskull
Jesus Vega
@ParagonChuy
Apr 19 2016 07:00
function dropElements(arr, func) {
  // Drop them elements.
  var dropped = arr.filter(func);
  return dropped;
}
dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;});
I don't understand how this doesn't pass the second and last test.
alpox
@alpox
Apr 19 2016 07:05
@ParagonChuy with filter you filter the whole array. You are asked in this challenge to only remove elements from the beginning of the array until a call to func with the current element raises true and dont test elements after that
@buiphuking you have 2.5/0.25 quarters
=10 quarters
Jesus Vega
@ParagonChuy
Apr 19 2016 07:10
@alpox Soo only loop until the test is true once?
alpox
@alpox
Apr 19 2016 07:10
Yep
Jesus Vega
@ParagonChuy
Apr 19 2016 07:11
Okay thanks @alpox
CamperBot
@camperbot
Apr 19 2016 07:11
paragonchuy sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 553 | @alpox | http://www.freecodecamp.com/alpox
alpox
@alpox
Apr 19 2016 07:11
Youre welcome
buonarfcc
@buonarfcc
Apr 19 2016 07:16

Hi @alpox if you have a chance please hlp me with this short codes ->// Example
function ourFunction(ourMin, ourMax) {

return Math.floor(Math.random() * (ourMax - ourMin + 1 ) + ourMin);
}

//ourFunction(1, 9);

// Only change code below this line.

function randomRange(myMin, myMax) {

return ourFunction(myMin,myMax); // Change this line

}

// Change these values to test your function
var myRandom = randomRange(5, 15);
console.log(myRandom); I still can't generate the last answer on the very bottom -> randomRange should use both myMax and myMin, and return a random number in your range. it is stil X red! Txs :)

buonarfcc
@buonarfcc
Apr 19 2016 07:25
Hi mattxgreen are you avail?
Blauelf
@Blauelf
Apr 19 2016 07:30
@buonarfcc Maybe you are meant to copy that line from ourFunction and replace any our with my?
Coryphaeus
@cvdeby
Apr 19 2016 07:45
@buonarfcc You don't need that +1 on ourMax - ourMin + 1
GitH7
@GitH7
Apr 19 2016 07:50
what's wrong

function updateRecords(id, prop, value) {

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

After updateRecords(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element.
even i'm getting correct results
Justin
@daemedeor
Apr 19 2016 07:53
@GitH7 there aren't some closed quotes on your checks
else if(collection[id][prop].tracks === '') <--
{
delete collection[id][prop];
}
if(collection[id][prop] === '') <--
{
delete collection[id][prop];
}
wait i lie
it looks like a single double quote
T-T
Marc Schöni
@marcschoeni
Apr 19 2016 07:54
Hello Everyone
Justin
@daemedeor
Apr 19 2016 07:54
@GitH7 try maybe refreshing the page?
welcoem @marcschoeni
Marc Schöni
@marcschoeni
Apr 19 2016 07:55

Whats wrong with this Code ```
function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch(val){
case "a":
answer="apple";
break;

case "b":
answer="bird";
break;

case "c":
answer="cat";
break;

default:
answer="stuff";
break;

}

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

// Change this value to test
switchOfStuff(b);
```

function switchOfStuff(val) {
  var answer = "";
  // Only change code below this line
  switch(val){
  case "a":
  answer="apple"; 
  break;

  case "b":
  answer="bird"; 
  break;

  case "c":
  answer="cat"; 
  break;


  default:
  answer="stuff"; 
  break;

}

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

// Change this value to test
switchOfStuff(b);
Justin
@daemedeor
Apr 19 2016 07:56
@marcschoeni well... b is not a string for one
but ummm looks right otherwise
Marc Schöni
@marcschoeni
Apr 19 2016 07:58
there are an issue open on Github
alpox
@alpox
Apr 19 2016 08:01
@buonarfcc maybe add ourMin after the parens? (just an idea), i don't remember this challenge, so i don't know the test cases ^^
Justin
@daemedeor
Apr 19 2016 08:02
@marcschoeni try change the b to a string like switchOfStuff("b")
Marc Schöni
@marcschoeni
Apr 19 2016 08:03
Ok but then it's a bad example on the left side xD
Justin
@daemedeor
Apr 19 2016 08:03
@marcschoeni its fine
alpox
@alpox
Apr 19 2016 08:04

@buonarfcc Yup i was right, i see the initial setup was:

// Example
function ourFunction(ourMin, ourMax) {

  return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}

ourFunction(1, 9);

// Only change code below this line.

function randomRange(myMin, myMax) {

  return 0; // Change this line

}

// Change these values to test your function
var myRandom = randomRange(5, 15);

you were not meant to change the upper function. But i think you were meant to rewrite a function like that on your own, so basically its the same with other parameters.

Abd-afeez Abd-hamid Adedamola
@Itsdenty
Apr 19 2016 08:10
The loop is not working with the replace method, n I don't know why, when I tried debugging with a specific number like 0 n 1 instead of I, it worked n replaced the specific symbol.

function convertHTML(str) {
 var char = ["&", "<", ">", "\"", "\'"] ;
var html = ["&amp;", "&lt;", "&gt;", "&quot;", "&apos;"];
var result = "";

  for (var i=0; i<5; i++) {  
result = str.replace(char[i], html[i]);
}
   return result;
   }

convertHTML("Dolce & Gabbana");
Justin
@daemedeor
Apr 19 2016 08:11
This message was deleted
then you save the newly replaced strings entirely overwriting result
and don't save the results from before
oh wait
no out of bounds
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Apr 19 2016 08:14
It was writing out of bounds b4 n that was why I created the variable outside d loop
Justin
@daemedeor
Apr 19 2016 08:15
you want to replace result once
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Apr 19 2016 08:15
The confusion here is why it will work with the supposed numbers for I in the loop but the loop itself fails to work
Justin
@daemedeor
Apr 19 2016 08:15
instead of overwriting it so the final apostrophe change will be there but the rest will be discarded
because you're overwriting result without having done anything extra
str is the original string
Coryphaeus
@cvdeby
Apr 19 2016 08:16
@ltegman try to use regex with callback function and dictionary. Your method works, but it's bad for performance.
Justin
@daemedeor
Apr 19 2016 08:16
@cvdeby are you sure it works?
cause it doesn't
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Apr 19 2016 08:17
That's true, the final loop for char[4] and html[4] would be the shown result
Coryphaeus
@cvdeby
Apr 19 2016 08:17
@daemedeor I used that method)
Ups
Justin
@daemedeor
Apr 19 2016 08:17
@cvdeby no the for loop is fine, but that code he has doesn't work -.-"
and really regex vs replace is just as bad
neither are great for performance
Naveen
@naveenm60
Apr 19 2016 08:18
i need help with "title case a sentence" challenge
Justin
@daemedeor
Apr 19 2016 08:18
but are appropriate solutions
BBLongman
@BBLongman
Apr 19 2016 08:18
Truncate a string
function truncateString(str, num) {
  // Clear out that junk in your trunk
    if (num >= str.length){
      return str;
    }
    if (num <= 3){
      return str.slice(0,num)+"...";
    }
    var outStr = "";
    var outArr = str.slice(0,num).split(" ");
    var outArr2 = str.split(" ");
    for (var i=0; i<outArr.length;i++){
      if (outStr.length+outArr[i].length<=num && outArr[i]===outArr2[i]){
        outStr = outStr + outArr[i] + " ";
      }
      else{
        outStr = outStr.slice(0,outStr.length-1);
        break;
      }

    }

  return outStr + "...";
}
Anyone come up with a neater solution?
Coryphaeus
@cvdeby
Apr 19 2016 08:19
@daemedeor Instead of \' you can write '- just one think, why it doesn't work.
@Itsdenty )
Justin
@daemedeor
Apr 19 2016 08:19
@cvdeby ... no its because he's overwriting result until the last one he doesn't have to have to escape it but thats probably the least of the worries
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Apr 19 2016 08:19
The problem I have with Regex is, how to specify what gets replaced,
Justin
@daemedeor
Apr 19 2016 08:20
also @cvdeby its bad form to overoptimize too early
@BBLongman
function truncateString(str, num) {
  var tempStr = "";

  if(str.length > num){

    if(num > 3){
      tempStr += str.slice(0,num-3) + "...";
    }else {
      tempStr += str.slice(0, num) + "...";
    }

  }else {
    tempStr = str;
  }


  return tempStr;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
alpox
@alpox
Apr 19 2016 08:22
@daemedeor @BBLongman And things gets much easier when working step by step:
function truncate(str, num) {
  if(str.length <= num) return str;
  if(num > 3) num = num - 3;
  return str.slice(0, num) + "...";
}
Coryphaeus
@cvdeby
Apr 19 2016 08:22
@Itsdenty It should be var result = str; and inside the loop result = result.replace(char[i], html[i]);
Cleofe
@cleofebelina
Apr 19 2016 08:22
df
Justin
@daemedeor
Apr 19 2016 08:22
@alpox i don't like code golf though ^.^ but fair enough
alpox
@alpox
Apr 19 2016 08:24
@daemedeor I just post it for showing other ways to solve a problem, like the early return in the first case, which makes things easier afterwards. I think people should learn this pattern :-)
Justin
@daemedeor
Apr 19 2016 08:24
@alpox i did say fair enough, didn't say it was horrible ^.^
alpox
@alpox
Apr 19 2016 08:24
@daemedeor :thumbsup:
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Apr 19 2016 08:27
Thanks @cvdeby
CamperBot
@camperbot
Apr 19 2016 08:27
itsdenty sends brownie points to @cvdeby :sparkles: :thumbsup: :sparkles:
:star: 350 | @cvdeby | http://www.freecodecamp.com/cvdeby
GitH7
@GitH7
Apr 19 2016 08:28
@daemedeor refreshing didn't work,
Naveen
@naveenm60
Apr 19 2016 08:28
hey i need a little help over "title case a sentence" challenge.
this is the code i have:

function titleCase(str) {
var arr=str.split(" ");
for(var i=0;i<arr.length;i++){
arri.toUpperCase();
}
str=arr.join(" ");
return str;
}

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

buonarfcc
@buonarfcc
Apr 19 2016 08:29
Duuuh --- I miss that! Thank you for your great eyes alpox!!!!:)
Naveen
@naveenm60
Apr 19 2016 08:29
it is arr[i][0].toUpperCase();
inside the for loop

function titleCase(str) {
var arr=str.split(" ");
for(var i=0;i<arr.length;i++){
arr[i][0].toUpperCase();
}
str=arr.join(" ");
return str;
}

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

DJ
@qualitymanifest
Apr 19 2016 08:30
arr[i] is still a string, and strings are immutable, so you can't change arr[i][0]
alpox
@alpox
Apr 19 2016 08:30
@naveenm60 toUpperCase doesn't change anything on the string, since strings are immutable. It only returns the letter in uppercase
Naveen
@naveenm60
Apr 19 2016 08:31
ok so i should change the entire string
alpox
@alpox
Apr 19 2016 08:31
@naveenm60 You cannot "change" the string, but you can replace it with a new string
Naveen
@naveenm60
Apr 19 2016 08:32
how?
Justin
@daemedeor
Apr 19 2016 08:33
arr[i][0].toUpperCase() returns the new string
alpox
@alpox
Apr 19 2016 08:33
@naveenm60 assign a new string to arr[i]. You can still use uppercase, since its just returns the letter in uppercase
Justin
@daemedeor
Apr 19 2016 08:33
oh
woops
late
alpox
@alpox
Apr 19 2016 08:33
And you have to add the rest too
Justin
@daemedeor
Apr 19 2016 08:33
arr[i] = arr[i][0].toUpperCase() + arr[i].slice(1).toLowerCase();
dum de dum dum
DJ
@qualitymanifest
Apr 19 2016 08:33
This message was deleted
Coryphaeus
@cvdeby
Apr 19 2016 08:34
@daemedeor I made this function. I thought, that regex works faster than loop, so made this function. Is it bad for performance against for loop? And which method is more preferable?
function convertHTML(str) {
  // &colon;&rpar;
  var dictionary = {
    '&' : '&amp;',
    '<' : '&lt;',
    '>' : '&gt;',
    '"' : '&quot;', 
    "'" : '&apos;'
  };
  var converter = function (match) {
    return dictionary[match];
  };
  return str.replace(/[&<>'"]/gi, converter);
}
convertHTML("Dolce & Gabbana");
Naveen
@naveenm60
Apr 19 2016 08:35
@daemedeor is thr any other way without using slice()?
Justin
@daemedeor
Apr 19 2016 08:35
@cvdeby na you're good
honestly i prefer the for loop but that's because i don't like regex, also don't use the i flag
@naveenm60 without slice, errr yea but its longer, why not slice?
Coryphaeus
@cvdeby
Apr 19 2016 08:37
@daemedeor In most cases I prefer loop too)
Naveen
@naveenm60
Apr 19 2016 08:37
i didn't come across slice() yet. so don't wanna use it
Coryphaeus
@cvdeby
Apr 19 2016 08:37
@daemedeor Thanks)
CamperBot
@camperbot
Apr 19 2016 08:37
cvdeby sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 572 | @daemedeor | http://www.freecodecamp.com/daemedeor
Justin
@daemedeor
Apr 19 2016 08:38
@naveenm60 meh ~ imo thats a silly concern.. but the lessons go over slice if i remember
in fact slice is possibly one that they say as a hint
Naveen
@naveenm60
Apr 19 2016 08:39
hint here is split()
CamperBot
@camperbot
Apr 19 2016 08:39
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
buiphuking
@buiphuking
Apr 19 2016 08:40
@camperbot can i ask you a question ?
Justin
@daemedeor
Apr 19 2016 08:41
then one moment
BBLongman
@BBLongman
Apr 19 2016 08:41

@naveenm60

function titleCase(str) {
  return str.split(" ").map(function(a){return a.split("")[0].toUpperCase().concat(a.slice(1).toLowerCase());}).join(" ");

}

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

This was my solution.

Coffee must have hit the spot ;)
Justin
@daemedeor
Apr 19 2016 08:42
they should use splice instead of split imo seems crazy to split the rest
@BBLongman still using splice though
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Apr 19 2016 08:50
I finally passed the challenge though I had to use Regexp too because the string.replace method only replaces the first instance not multiple instances of the parameters. So @cvdeby you were right, d Regexp was unavoidable.
Luca
@broc93
Apr 19 2016 08:58
help format
CamperBot
@camperbot
Apr 19 2016 08:58

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Naveen
@naveenm60
Apr 19 2016 08:59
ok, i completed the challenge without using regex
Luca
@broc93
Apr 19 2016 09:00
function titleCase(str) {
  var arr = str.split(" ");
  var ret = '';
  var l = "";
  for (var i = 0; i<arr.length; i++) {
    l = arr[i][0].toUpperCase();
    for (var j = 1; j<arr[i].length; j++) {
      l=l.concat(arr[i][j].toLowerCase());
    }
    ret = ret.concat(l+ " ");
  }
  return ret.slice(0, -1);
}

titleCase("I'm a little tea pot");
Hello, this is my code for the task "Title Case a Sentence". It works but it's pretty long and I think there must be some more intelligent way of doing it. Any suggestions?
Markus Kiili
@Masd925
Apr 19 2016 09:00
@broc93 This is one common way:
function titleCase(str) {
  return str.split(' ').map(function(val){
    return val.charAt(0).toUpperCase() + val.substr(1).toLowerCase();
  }).join(' ');
}
Luca
@broc93
Apr 19 2016 09:01
oh right, map! Thank you @Masd925 !
CamperBot
@camperbot
Apr 19 2016 09:01
broc93 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1380 | @masd925 | http://www.freecodecamp.com/masd925
Naveen
@naveenm60
Apr 19 2016 09:02
yep i too did that exactly
ricky0512
@ricky0512
Apr 19 2016 09:05
I'm really stocked, if someone could help me for profile lookup.

//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){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i].prop;
}else{
return "No such property";
}
}else{
return "No such contact";
}
}

// Only change code above this line
}

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

why my code without color :P
Coy Sanders
@coymeetsworld
Apr 19 2016 09:06
help format
CamperBot
@camperbot
Apr 19 2016 09:06

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

ricky0512
@ricky0512
Apr 19 2016 09:07

//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){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i].prop;
}else{
return "No such property";
}
}else{
return "No such contact";
}
}

// Only change code above this line
}

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

Ultras05
@Ultras05
Apr 19 2016 09:07

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

// Only change code below this line
var lookup = {
1 : "Adams",
2 : "Boston",
3 : "Chicago",
4 :"Denver",
5 :"Easy",
6 :"Frank"
};

// Only change code above this line

}

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

Coy Sanders
@coymeetsworld
Apr 19 2016 09:07
you need to use bracket notation to get the property of the contact too, thats the issue I think @ricky0512
shouldn't be contacts[i].prop
ricky0512
@ricky0512
Apr 19 2016 09:08

//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){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i].prop;
}else{
return "No such property";
}
}else{
return "No such contact";
}
}

// Only change code above this line
}

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

//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){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i].prop;
}else{
return "No such property";
}
}else{
return "No such contact";
}
}

// Only change code above this line
}

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

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){
      if(contacts[i].hasOwnProperty(prop)){
        return contacts[i].prop;
      }else{
        return "No such property";
      }
    }else{
      return "No such contact";
    }
 }

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
Coy Sanders
@coymeetsworld
Apr 19 2016 09:12
hmm, my solution isn't working right now
strange the function needs to be lookUpProfile but it says lookup in the description
Kevin
@KevinBruland
Apr 19 2016 09:13
I'm a little stuck on the palindrome checker if someone has a minute
cannelflow
@cannelflow
Apr 19 2016 09:14
@Benalron show your code
Kevin
@KevinBruland
Apr 19 2016 09:14
function palindrome(str) {
  // Good luck!
  str = str.replace(/\W/g,'');
  str = str.split("");
  var revstr = str
  revstr = revstr.reverse();
  return str;
  }



palindrome("ABC");
I don't want the direct answer, I just dont understand why str is reversing in this case
Coy Sanders
@coymeetsworld
Apr 19 2016 09:15
you're missing a semicolon for one
Kevin
@KevinBruland
Apr 19 2016 09:16
looking at it, I would think revstr is a reverse of str, and str would be in the same order, but split
Coy Sanders
@coymeetsworld
Apr 19 2016 09:16
also theres no reverse function for string
Kevin
@KevinBruland
Apr 19 2016 09:16
I convered it to an array with .split
to reverse the array
the reversing is working fine, but somehow str is also being reversed
kuhan
@nkuhan
Apr 19 2016 09:17
@Benalron yes you are checking both ways are okay
Kevin
@KevinBruland
Apr 19 2016 09:17
so when I run that, when str is returned, my result is ["C", "B". "A"]
I have nothing in there reversing str, only reversing revstr
cannelflow
@cannelflow
Apr 19 2016 09:19
@Benalron https://repl.it/CHHY you need to join also
Kevin
@KevinBruland
Apr 19 2016 09:20
@cannelflow, I know I need to join, but I removed that until I sort out the reversing... even if I join, its still reversing str
Coy Sanders
@coymeetsworld
Apr 19 2016 09:20
str and revstr are pointing to the same array thats why
revstr is a reference to str
Dardan Demiri
@dardandemiri
Apr 19 2016 09:21
Does anybody know what's wrong here
kuhan
@nkuhan
Apr 19 2016 09:21
function checkPalindrom(str) {
return str == str.split('').reverse().join('');
}
Dardan Demiri
@dardandemiri
Apr 19 2016 09:21
function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var sourceKeys = Object.keys(source);

  collection.filter(function(value,key){
    for( var index = 0; index < source.length; index++){
      for(var i = 0; i < collection.length; i++){
      if(source[index].sourceKeys == collection[i].sourceKeys){
        return true;
      }else{
        return false;
      }
    }
    }
  });

  // Only change code above this line

}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Kevin
@KevinBruland
Apr 19 2016 09:21
oh, I thought I was creating a new variable that had the same properties, until I modified them @coymeetsworld ?
ricky0512
@ricky0512
Apr 19 2016 09:21
@coymeetsworld thank for reply. I changed it to lookUp, not working still @@"
CamperBot
@camperbot
Apr 19 2016 09:21
ricky0512 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 590 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
cannelflow
@cannelflow
Apr 19 2016 09:21
:point_up: April 19, 2016 2:49 PM see my link
@Benalron
Coy Sanders
@coymeetsworld
Apr 19 2016 09:22
hes not asking for the answer @cannelflow
I'm not 100% sure what's going on @Benalron, but do you really need to have a separate variable anyways?
UtkarshShukla7
@UtkarshShukla7
Apr 19 2016 09:22
@Benalron your regular expression should also test for _
Stephen James
@sjames1958gm
Apr 19 2016 09:23
@dardandemiri The filter function is already looping over the collection array the inner for loop is not needed. Make sure you check all the keys in your source object before returning true or false.
Kevin
@KevinBruland
Apr 19 2016 09:23
well, I tried an if (str === str.reverse()) statement, and that didnt work
cannelflow
@cannelflow
Apr 19 2016 09:23
@coymeetsworld sry just tried to explain that you can console log every steps so that you can see what is going on with your code
kuhan
@nkuhan
Apr 19 2016 09:24
@Benalron ==
E YG
@laed37
Apr 19 2016 09:24
why can't I console log jsondata when I click the button?
<form class='form-inline'>
   <button type='submit' class='btn btn-primary' id='testBtn'>Click here</button>
</form>

$(document).ready(function() {
   $('#testBtn').click(function() {
      console.log('click function works');
      $.getJSON('https://api.myjson.com/bins/3abzc', function(jsondata) {
         console.log(jsondata);
      });
   });
});
kuhan
@nkuhan
Apr 19 2016 09:24
@Benalron return str == str.split('').reverse().join('');
Coy Sanders
@coymeetsworld
Apr 19 2016 09:24
@ricky0512 no its supposed to be lookUpProfile, did you go w/ my suggestion from before? need to use bracket notation over dot notation?
lol
guess were just giving answers now :)
UtkarshShukla7
@UtkarshShukla7
Apr 19 2016 09:25
@Benalron /[\W_]+/g
Coy Sanders
@coymeetsworld
Apr 19 2016 09:26
@UtkarshShukla7 the regex isn't the problem
E YG
@laed37
Apr 19 2016 09:26
Here's a link to my pen... http://codepen.io/laed37/pen/EKRPvJ
Naveen
@naveenm60
Apr 19 2016 09:27
hey can anyone tell me why this isn't working properly?

function largestOfFour(arr) {
// You can do this!
var a=arr0;
var b=[];
for(var i=0;i<arr.length;i++){ for(var j=0;j<arr[i].length;j++){ if(a>arr[i][j]){
b.push(a);
}else{
b.push(arr[i][j]);
}
}
}
return b;
}

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

ricky0512
@ricky0512
Apr 19 2016 09:27
@coymeetsworld bracket?
E YG
@laed37
Apr 19 2016 09:27
when I move the getjson function out of the click, it works, and it appears the click function also works because it logs the string when I click it...
Coy Sanders
@coymeetsworld
Apr 19 2016 09:27
return contacts[i].prop;
that part isn't right @ricky0512
Naveen
@naveenm60
Apr 19 2016 09:27
var a=arr0;

function largestOfFour(arr) {
// You can do this!
var a=arr[0][0];
var b=[];
for(var i=0;i<arr.length;i++){ for(var j=0;j<arr[i].length;j++){ if(a>arr[i][j]){
b.push(a);
}else{
b.push(arr[i][j]);
}
}
}
return b;
}

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

why isn't the above code working?
ricky0512
@ricky0512
Apr 19 2016 09:28
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].hasOwnProperty(prop)){ return contacts[i].prop; }else{ return "No such property"; } }else{ return "No such contact"; } } // Only change code above this line }
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].hasOwnProperty(prop)){
        return contacts[i].prop;
      }else{
        return "No such property";
      }
    }else{
      return "No such contact";
    }
 }
// Only change code above this line
}
Stephen James
@sjames1958gm
Apr 19 2016 09:30
@naveenm60 1) You need to check the largest of each subarray, so some setup needs to be done before your inside loop. Looks like you can push more than one value from the inside loop, only select largest of each subarray
ricky0512
@ricky0512
Apr 19 2016 09:30
Oh ooooo ... still not working and no output in the consle @@"
Stephen James
@sjames1958gm
Apr 19 2016 09:31
@ricky0512 Since prop is a variable contacts[i].prop will not do what you want. contacts[i][prop] should.
Coy Sanders
@coymeetsworld
Apr 19 2016 09:31
yup
Stephen James
@sjames1958gm
Apr 19 2016 09:32
@ricky0512 contacts[i].prop returns the property "prop" contacts[i][prop] returns the property whose name is stored in prop
Dardan Demiri
@dardandemiri
Apr 19 2016 09:32
@sjames1958gm thanks ;)
CamperBot
@camperbot
Apr 19 2016 09:32
dardandemiri sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 697 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Naveen
@naveenm60
Apr 19 2016 09:32
@sjames1958gm what stup needs to be done before the loop?
Mooli
@Mooli88
Apr 19 2016 09:33
i'm looking to fill up my knowledge holes i acquire while learning js. so can you please quickly help me understand whats the difference between
function funcName(){} to var funcName = function(){} ?
ricky0512
@ricky0512
Apr 19 2016 09:34
@sjames1958gm thanks a lot
CamperBot
@camperbot
Apr 19 2016 09:34
ricky0512 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 698 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
ricky0512
@ricky0512
Apr 19 2016 09:34
I tried that before
the response kind of weired
Stephen James
@sjames1958gm
Apr 19 2016 09:34
@naveenm60 Like you are trying to do but for each inside loop. largest = arr[i][0]; then for the remaining items if larger that current largest set largest, after loop push onto response array
Naveen
@naveenm60
Apr 19 2016 09:35
@Mooli88 second one is a constructor used to create objects
Mooli
@Mooli88
Apr 19 2016 09:36
@naveenm60 and nothing else ?
Dardan Demiri
@dardandemiri
Apr 19 2016 09:37
@sjames1958gm
This should be working
function myReplace(str, before, after) {
  var re = '/'+ before +'/gi';

  var changedString = str.replace(re, after);

  return changedString;
}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
Mooli
@Mooli88
Apr 19 2016 09:37
@naveenm60 why can't function funcname() create an object ?
Dardan Demiri
@dardandemiri
Apr 19 2016 09:37
but is not
Stephen James
@sjames1958gm
Apr 19 2016 09:37
@Mooli88 There are some subtle differences. If you write the first form anywhere in the file, then it can be used anywhere. If you write the second form it can only be used after the starement itslef
Stephen James
@sjames1958gm
Apr 19 2016 09:38
@dardandemiri Cannot build a regex that way. Try re = new RegExp(before, "gi");
Dardan Demiri
@dardandemiri
Apr 19 2016 09:38
ahhh
perfect, thank you
thank you @sjames1958gm
CamperBot
@camperbot
Apr 19 2016 09:39
dardandemiri sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: dardandemiri already gave sjames1958gm points
Mooli
@Mooli88
Apr 19 2016 09:39
@daemedeor thanks i'll read it now
:D
docs docs docs docs :D
Mooli
@Mooli88
Apr 19 2016 09:40
This message was deleted
CamperBot
@camperbot
Apr 19 2016 09:41
mooli88 sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 574 | @daemedeor | http://www.freecodecamp.com/daemedeor
Mooli
@Mooli88
Apr 19 2016 09:41
@daemedeor can you explain what is that mean " Function Declarations occur as standalone constructs and cannot be nested within non-function blocks. ex: function innerFunction1 () { }; " cannot be nested within non-function blocks. ?
Naveen
@naveenm60
Apr 19 2016 09:42
@sjames1958gm is this what u are saying?
This message was deleted
This message was deleted
Justin
@daemedeor
Apr 19 2016 09:43

@Mooli88 basically if you have

{
  function(){}
}

is a no go

Naveen
@naveenm60
Apr 19 2016 09:43
wait a min
Justin
@daemedeor
Apr 19 2016 09:43
or
if(){
function(){
}
}
also no good
so if its not a function block then you can't do it
eg.
function(){
   function newExample(){
   }
}
that's valid
Naveen
@naveenm60
Apr 19 2016 09:45

@sjames1958gm function largestOfFour(arr) {
// You can do this!
var a=arr0;
var b=[];
for(var i=0;i<arr.length;i++){
for(var j=0;j<arr[i].length;j++){
if(a<arr[i][j]){
a=arr[i][j];
b.push(a);
}
}
}
return b;
}

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

@daemedeor can u tell me whats wrong in that code?
var a=arr[0][0];
Mooli
@Mooli88
Apr 19 2016 09:46
@daemedeor when can you use function(){}? as a callback?
Justin
@daemedeor
Apr 19 2016 09:48
@Mooli88 whenever you can use callbacks
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 19 2016 09:49
var keysArraySymbols = ['~', '!', '@', '#', '$', '`',    '^', '&', '*', '(', ')', '-', '_', '=', '{', '}', '<', '>', '|', '/', '.', ',', '[', ']', ':', '?'];

function shuffleSymbols(){
        var copyOfArray = keysArraySymbols;

        for(i = 0; i <= keysArraySymbols.length; i++){
            console.log(i,keysArraySymbols.length);
            var randomNum = Math.floor(Math.random() * (copyOfArray.length));
            var testSymbols = copyOfArray[randomNum];
            copyOfArray.splice(randomNum,1);
        }
    }
shuffleSymbols();
guys please clear my doubt
why keysArraySymbols length decreasing through each iteration of loop?
Justin
@daemedeor
Apr 19 2016 09:49
@naveenm60 you want to return the largest in the group not the largest compared to arr[0] (which is an array itself) so... while you're getting the inside value you're trying to compare it to the entire array
which is not how you compare in the arrays
Kelvin
@loweehahn
Apr 19 2016 09:52
Can you perform arithmetic on indexes? For example largest[i][j - 1] = arr[i][j];
Mooli
@Mooli88
Apr 19 2016 09:53
@daemedeor i've read the post on stackoverflow but still dont really get it . i just seems that Function declaration is always the better option unless i need a function for an object ...
Justin
@daemedeor
Apr 19 2016 09:53
@loweehahn yes
@Mooli88 bascially they're not TOO different in reality typically you do the this.name = function(){} on an object
Kelvin
@loweehahn
Apr 19 2016 09:55
Thanks for the clarification @daemedeor
CamperBot
@camperbot
Apr 19 2016 09:55
loweehahn sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 575 | @daemedeor | http://www.freecodecamp.com/daemedeor
Naveen
@naveenm60
Apr 19 2016 09:55
ok i understand.. bust still not sure how to go about it. @daemedeor
alpox
@alpox
Apr 19 2016 09:56

@daemedeor

so if its not a function block then you can't do it

Well you can do it, but its not so nice :D

Justin
@daemedeor
Apr 19 2016 09:57
@malangaveuday when you slice an array it is modified and when you do var copyOfArray = keysArraySymbols you're really just pointing a reference to the memory array
@naveenm60 for each array, go through it and find the biggest number, once you find the biggest number push it into the new array
@alpox is most cases but not always
Claudio Restifo
@Marmiz
Apr 19 2016 10:00

Hi folks! A quick help about the map method:
in the description it says that

your callback can also include arguments for the index and array being acted on.

I have tried to play around but always receive error messages; can someone please preovide me with an example of how to do it?

here's my idea of how i can access index inside the array:

var newArray = oldArray[1].map(function(val){
  //some function
});

the error message states:

var newArray = oldArray[1].map is not a function

Markus Kiili
@Masd925
Apr 19 2016 10:07
@Mooli88 If you are talking about the difference between declaring a function or assigning a function expression to a variable, it is a property of all languages with 1st class functions, that there is no real difference. The names of functions do not have any special status; they are treated like ordinary variables with a function type.
Stephen James
@sjames1958gm
Apr 19 2016 10:08
@Masd925 For javascript there is a subtle difference in that function expressions are not hoisted.
Markus Kiili
@Masd925
Apr 19 2016 10:09
@sjames1958gm Yes, some subtle differences exist.
Stephen James
@sjames1958gm
Apr 19 2016 10:18
@Marmiz The signature of the function that map calls has the index function(item, index, array) see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
@Marmiz var arr = [1, 2, 3]; arr.map(function(item, index) {});
Claudio Restifo
@Marmiz
Apr 19 2016 10:21
@sjames1958gm Now i see the login in it! Thanks for linking the page... it's a great resource. (It should be added in the lesson page in my opinion)
CamperBot
@camperbot
Apr 19 2016 10:21
marmiz sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 699 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Naveen
@naveenm60
Apr 19 2016 10:21
is there something else i should do in this?

function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
if(str[str.length-1]==target){
return true;
}
return false;
}

confirmEnding("Bastian", "n");

it's not returning expected output in case of sentences.
example:confirmEnding("He has to give me a new name", "name") should return true.
but the code above is returning false for that
Stephen James
@sjames1958gm
Apr 19 2016 10:23
@naveenm60 Since the target is not just size 1 you need to use substring of str, not just []
Markus Kiili
@Masd925
Apr 19 2016 10:23
@naveenm60 You are only checking the last character.
@naveenm60 Cut the end part of str so it is the same length as target and then compare it to target.
Stephen James
@sjames1958gm
Apr 19 2016 10:23
@naveenm60 Also, if (x == y) return true; else false; is simplified to return (x== y);
Naveen
@naveenm60
Apr 19 2016 10:24
ok thanks @sjames1958gm
CamperBot
@camperbot
Apr 19 2016 10:24
naveenm60 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 700 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Naveen
@naveenm60
Apr 19 2016 10:24
thanks @Masd925
CamperBot
@camperbot
Apr 19 2016 10:24
naveenm60 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1381 | @masd925 | http://www.freecodecamp.com/masd925
Naveen
@naveenm60
Apr 19 2016 10:25
@Masd925 which end part should i cut?
Markus Kiili
@Masd925
Apr 19 2016 10:27
@naveenm60 If target length is for example 5, you should make a substring from str with the last 5 charaters of str.
Romain Mondon-Cancel
@skasch
Apr 19 2016 10:27
@naveenm60 You want to grab the last few characters of your string and compare it to the target =)
Stephen James
@sjames1958gm
Apr 19 2016 10:28
This page is a great reference for String functions that you might use. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
Naveen
@naveenm60
Apr 19 2016 10:30
@Masd925 target length is different in different cases.
so i cannot fix a substring from str with some fixed value.'
Markus Kiili
@Masd925
Apr 19 2016 10:31
@naveenm60 Use target.length in combination with substr/substring/slice method.
Naveen
@naveenm60
Apr 19 2016 10:31
@Masd925 is this correct?

function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
if(str.substr(target.length)==target){
return true;
}
return false;
}

confirmEnding("Bastian", "n");

Markus Kiili
@Masd925
Apr 19 2016 10:32
@naveenm60 The start index is not correct.
Naveen
@naveenm60
Apr 19 2016 10:35
what should be the start index then?
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 19 2016 10:37
@daemedeor hey my before code pointing reference object
```js
Markus Kiili
@Masd925
Apr 19 2016 10:37
@naveenm60 If str length is 5 and tagret length is 2, you should start the substring from index 3. Then the substring has elements from indices 3 and 4 and length is 2 also.
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 19 2016 10:37
var copyOfArray = keysArraySymbols.map(function(val){return val});
at above code its making new object right?
Markus Kiili
@Masd925
Apr 19 2016 10:38
@malangaveuday Yes, but there are easier ways to copy an array.
Naveen
@naveenm60
Apr 19 2016 10:38
so i should start from -target.length.. got it
thanks @Masd925
CamperBot
@camperbot
Apr 19 2016 10:38
naveenm60 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: naveenm60 already gave masd925 points
Stephen James
@sjames1958gm
Apr 19 2016 10:40
@naveenm60 If you open your browser devtools and console - you can try these functions yourself. This way you see and probably better retain what is happening.
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 19 2016 10:40
@Masd925 hey yeah I did not goggle for it
another and easy way is array.slice();
right?
Markus Kiili
@Masd925
Apr 19 2016 10:41
@malangaveuday Yes.
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 19 2016 10:42
well without any argument pass in slice how he slice the array?
every first content of array?
Bridget
@bridgetfagan3
Apr 19 2016 10:42
how do they want us to encode the following sequence separated by spaces,-- backslash tab tab carriage-return new-line ?
Markus Kiili
@Masd925
Apr 19 2016 10:43
@malangaveuday If no start index is given, .slice() slices from index 0 (the whole array).
Bridget
@bridgetfagan3
Apr 19 2016 10:43
var myStr = "\backslash\ \ttab\t \ttab\t \rcarriage-return\r \nnew-line\n"; // Change this line ??
Dardan Demiri
@dardandemiri
Apr 19 2016 10:44
@bridgetfagan3 you added a lot of \t's
Ultras05
@Ultras05
Apr 19 2016 10:44

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

function checkObj(checkProp) {
// Your Code Here

return "Change Me!";
}

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

Andre Christoga
@christoga
Apr 19 2016 10:45
Is something wrong with my code?
Bridget
@bridgetfagan3
Apr 19 2016 10:45
the word tab is given twice, so I thought it would need to separate encodings
Andre Christoga
@christoga
Apr 19 2016 10:45
// Example
var changed = 0;

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

changed = change(10);

// Setup
var processed = 0;

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

// Only change code below this line


var processed = process(7);
var processArg = processed;
Please help me
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 19 2016 10:45
@Masd925 yeah good thank you
CamperBot
@camperbot
Apr 19 2016 10:45
malangaveuday sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1382 | @masd925 | http://www.freecodecamp.com/masd925
Dardan Demiri
@dardandemiri
Apr 19 2016 10:46
@christoga what are you trying to do ?
Ultras05
@Ultras05
Apr 19 2016 10:49
need some help

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

function checkObj(checkProp) {
// Your Code Here

return "Change Me!";
}

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

Bridget
@bridgetfagan3
Apr 19 2016 10:49
never mind got it :)
Stephen James
@sjames1958gm
Apr 19 2016 10:50
@Ultras05 So you are to return the property stored in checkProp for the object myObj
Ultras05
@Ultras05
Apr 19 2016 10:51
how
@sjames1958gm
Stephen James
@sjames1958gm
Apr 19 2016 10:53
@Ultras05 Well if the property name is in a variable you will have to use [] which was probably covered in a previous challenge
fluffystub
@RakshithNM
Apr 19 2016 10:53

'''
function sumAll(arr) {
var smal= Math.min(arr);
var big = Math.max(arr);
var temp= [];
for(var i=smal; i<=big; i++){
temp.push(i);
var total = temp.reduce(function(a, b) {
return a + b;
});
console.log(total);
}
}

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

CamperBot
@camperbot
Apr 19 2016 10:53
:bulb: to format code use backticks! ``` more info
fluffystub
@RakshithNM
Apr 19 2016 10:53
'''
CamperBot
@camperbot
Apr 19 2016 10:53
:bulb: to format code use backticks! ``` more info
Timothy Davis
@timothycdavis
Apr 19 2016 10:53
Could I have some help me one of the javascript lessons?
fluffystub
@RakshithNM
Apr 19 2016 10:55
function sumAll(arr) {
  var smal= Math.min(arr);
  var big = Math.max(arr);
  var temp= [];
  for(var i=smal; i<=big; i++){
      temp.push(i);
      var total = temp.reduce(