These are chat archives for FreeCodeCamp/HelpJavaScript

25th
Jun 2017
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:02 UTC

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

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

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

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

//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 (contacts.hasOwnProperty(firstName) && contacts.hasOwnProperty(prop)) {
   return firstName + prop;
 } 
// Only change code above this line
}

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

until now, im trying to achieve the first step ( to verify if both of them are true and then return the values)

really dont know what to do here
can someone explain me
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:03 UTC
@CroRaptor i skipped it because i couldnt find the answer haha
Matej P.
@CroRaptor
Jun 25 2017 00:03 UTC
yeah but i cant skip lessons :D
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:04 UTC
why?
Matej P.
@CroRaptor
Jun 25 2017 00:04 UTC
cause wanna solve them all
luccifer00
@luccifer00
Jun 25 2017 00:04 UTC
@mauriciodeleonc let me help you. i am a newbie but, i did the exercice few hours ago
Matej P.
@CroRaptor
Jun 25 2017 00:05 UTC
so help US :smile:
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:05 UTC
@CroRaptor ohhhhh me too...but maybe you´ll find the answers you seek in further excercises
@luccifer00 please, show me the way lucifer
Matej P.
@CroRaptor
Jun 25 2017 00:07 UTC
our hopes stand in line with lucifer
:P
luccifer00
@luccifer00
Jun 25 2017 00:07 UTC
@mauriciodeleonc my english is not so good, i am from spain .. but i can try.... wait a momnt @CroRaptor while i anwering try read the lastes challenges , that the tick!
Matej P.
@CroRaptor
Jun 25 2017 00:07 UTC
haahah
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:07 UTC
im mexican so you can explain in spanish if you want to (but i think it will be better for others if it´s in english)
luccifer00
@luccifer00
Jun 25 2017 00:08 UTC
@mauriciodeleonc you should create a loop. i did exactly what you do a condicional && condicional.... but if you not create a loop, you cant figure out the exact name.
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:08 UTC
hmmm
let me try that
thanks
@luccifer00 thanks (this way the bot gives you points haha)
CamperBot
@camperbot
Jun 25 2017 00:09 UTC
mauriciodeleonc sends brownie points to @luccifer00 :sparkles: :thumbsup: :sparkles:
:cookie: 224 | @luccifer00 |http://www.freecodecamp.com/luccifer00
Hello911
@Hello911
Jun 25 2017 00:09 UTC
Could anyone check why my quote generation JQuery code isn't working? It is supposed to get a new quote every time the page refreshes. https://codepen.io/Hello911/pen/qjrVom?editors=0010
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:10 UTC
@Hello911 newbie here, sorry
zakaos
@zakaos
Jun 25 2017 00:10 UTC
i cant for the life of me figure out why thisnonclick is not firing
Jan Shah
@JanShah
Jun 25 2017 00:10 UTC
@Hello911 Uncaught ReferenceError: $ is not defined
Jan Shah
@JanShah
Jun 25 2017 00:11 UTC
no jquery
@Hello911
zakaos
@zakaos
Jun 25 2017 00:11 UTC
also cant figurebout why .quotebox's css isnt working
Ryan Malm
@Rybar
Jun 25 2017 00:12 UTC
hello @Hello911 you don't have JQuery loaded. console says $ is not defined
^ @CentropyIT beat me to it. :D
Jan Shah
@JanShah
Jun 25 2017 00:14 UTC
@zakaos can you clarify? your button is working but doesn't do anything useful yet
luccifer00
@luccifer00
Jun 25 2017 00:14 UTC

so for your challenge @mauriciodeleonc
you should create a loop with contacts[i]
create a conditonal if contacts[i] firstName is === to firstName

when that is true
you shold create a hasOwnisProperty to prop, if prop conincide so show prop,, and whatch out where you put your returns of no such property or no such contact

zakaos
@zakaos
Jun 25 2017 00:14 UTC
so, it is not triggering the function getquote
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:15 UTC
oooo okay i think i get it
thanks @luccifer00
CamperBot
@camperbot
Jun 25 2017 00:15 UTC
mauriciodeleonc sends brownie points to @luccifer00 :sparkles: :thumbsup: :sparkles:
:warning: mauriciodeleonc already gave luccifer00 points
Jan Shah
@JanShah
Jun 25 2017 00:15 UTC
@zakaos your quotebox css is inside body css
unreachable code
zakaos
@zakaos
Jun 25 2017 00:15 UTC
i have it set to onclick="getquote()" but onclick it is not running the function
Jan Shah
@JanShah
Jun 25 2017 00:16 UTC
@zakaos it is triggering the function, the function doesn't do anything.
luccifer00
@luccifer00
Jun 25 2017 00:16 UTC
@CroRaptor you have to use the push() and shitf()
Jan Shah
@JanShah
Jun 25 2017 00:16 UTC
add console.log('triggered') inside the function and then press the button, you will see the button is working
@zakaos
Matej P.
@CroRaptor
Jun 25 2017 00:17 UTC
@luccifer00 i know that but dont know how to code it in function haha
Jan Shah
@JanShah
Jun 25 2017 00:17 UTC
j.InnerHTML="newquote";
as far as I'm aware, this doesn't do anything useful. I could be wrong
zakaos
@zakaos
Jun 25 2017 00:18 UTC
Ahhh ok thanks jahngir
so regarding css, i didnt close my body properly? or body overwrites .quotebox style?
luccifer00
@luccifer00
Jun 25 2017 00:20 UTC
@CroRaptor you should to push(item) into your arr argument, and return arr deleting the first one, this could be with shift
Jan Shah
@JanShah
Jun 25 2017 00:21 UTC
@zakaos each tag should be enclosed. check where are your parentheses are. The fact that the body tag isn't enclosed means the other tags are ignored
it affects everything going down the stylesheet
luccifer00
@luccifer00
Jun 25 2017 00:21 UTC
with that you can do all the challenge.... so analyze it word by word! hahaha
zakaos
@zakaos
Jun 25 2017 00:21 UTC
ahhhh in my html, noty css
i goofed thanks againan
Jan Shah
@JanShah
Jun 25 2017 00:23 UTC
@zakaos it's something else with yours actually, just double checked. There are strange character returns in your code that is causing problems. once I deleted and re-entered new lines, the css started working
no parantheses needed
zakaos
@zakaos
Jun 25 2017 00:24 UTC
ahhhhh, maybe cause of being on mobile
Jan Shah
@JanShah
Jun 25 2017 00:24 UTC
you're using a mobile device? it shouldn't really cause problems. what device are you using, out of interest?
zakaos
@zakaos
Jun 25 2017 00:24 UTC
i had some issues when on codecamo challenges as well
android note 4
heidisdad2
@heidisdad2
Jun 25 2017 00:24 UTC
var product = [];
function destroyer(arr) {
  // Remove all the values

  function removeNum(val){
    for(var i=0; i<arr.length-1; i++){

      return val !== arr[i];

    }

  }  
  return arr.filter(removeNum);
}

destroyer([1,2,2,3], 2, 3);
can anyone tell me why i cant get this for loop to work?
Jan Shah
@JanShah
Jun 25 2017 00:25 UTC
something is wrong with this line: return val !== arr[i];
@heidisdad2
Danny
@WaterYourRoots
Jun 25 2017 00:31 UTC
what am I missing here (1.) to create (2.)
  1. var myStr = "FirstLine,\r\n\SecondLine\,/r/n ThirdLine";
  1. FirstLine
    \SecondLine\
    ThirdLine
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:31 UTC
@CroRaptor
function nextInLine(arr, item) {
  arr.push(item);
  arr.shift();
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
i have that
could you do it?
i did screenshot minute ago
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:32 UTC
i get the same results
didnt notice the ss
kumquatfelafel
@kumquatfelafel
Jun 25 2017 00:33 UTC
@WaterYourRoots reread the description on the left. It tells you what characters you need to include, and you can get those from the table. Also, as @CentropyIT points out, \n is not /n, as... similarly \r is not /r
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:33 UTC
but why are you adding it to the testArray and not the arr?
Jan Shah
@JanShah
Jun 25 2017 00:33 UTC
@WaterYourRoots \n creates a new line /n doesn't
Matej P.
@CroRaptor
Jun 25 2017 00:33 UTC
hmm ill try just arr
its same haha
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:34 UTC
testArr is part of your arguments, changing that affects the function
Matej P.
@CroRaptor
Jun 25 2017 00:34 UTC
yeah i know now
i did it mistake
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:34 UTC
dw
Matej P.
@CroRaptor
Jun 25 2017 00:34 UTC
but it doesnt work again
haha
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:34 UTC
but still cant figure it out haha
@helpPlease
Michael G.
@MichaelBlue
Jun 25 2017 00:35 UTC
How's everyone doing?? :D
Mirza Arslan
@arslan555
Jun 25 2017 00:35 UTC
Hello everyone, previously i have experience of java and work on mobile application now i want to work on web applications so , where from i started ,javascript ?? can someone guides me
Michael G.
@MichaelBlue
Jun 25 2017 00:36 UTC
Youtube it bro
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:36 UTC

@MichaelBlue not so good...croRaptor and I are having problems with this

@CroRaptor
```
function nextInLine(arr, item) {
arr.push(item);
arr.shift();
return item; // Change this line
}

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

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

i dont know what happened there but it was supposed to be this
function nextInLine(arr, item) {
arr.push(item);
arr.shift();
return item; // Change this line
}
// Test Setup
var testArr = [1,2,3,4,5];
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Danny
@WaterYourRoots
Jun 25 2017 00:37 UTC
@kumquatfelafel @CentropyIT Thank you, didnt see that layout they provided on the left
CamperBot
@camperbot
Jun 25 2017 00:37 UTC
wateryourroots sends brownie points to @kumquatfelafel and @centropyit :sparkles: :thumbsup: :sparkles:
:cookie: 304 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
:cookie: 399 | @centropyit |http://www.freecodecamp.com/centropyit
kumquatfelafel
@kumquatfelafel
Jun 25 2017 00:38 UTC

@WaterYourRoots one thing that sometimes trips people up anyway (preemptively)... Make sure to capitalize the L. Oh right. You've already done that.

Sorry, on automatic help mode.

mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:38 UTC
@arslan555 the freeCodeCamp tutorials help a lot with JavaScript, and with the experience you have with programming, you´ll get the hang of it easily
Matej P.
@CroRaptor
Jun 25 2017 00:38 UTC
@mauriciodeleonc we should change return
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:38 UTC
i know...but idk to what
Michael G.
@MichaelBlue
Jun 25 2017 00:38 UTC
`
Matej P.
@CroRaptor
Jun 25 2017 00:38 UTC
me too hahahah
Mirza Arslan
@arslan555
Jun 25 2017 00:40 UTC
@mauriciodeleonc thank you sir .
CamperBot
@camperbot
Jun 25 2017 00:40 UTC
arslan555 sends brownie points to @mauriciodeleonc :sparkles: :thumbsup: :sparkles:
:cookie: 215 | @mauriciodeleonc |http://www.freecodecamp.com/mauriciodeleonc
kumquatfelafel
@kumquatfelafel
Jun 25 2017 00:41 UTC
@arslan555 in terms of free code camp you can start at very beginning, you can also start with the javascript if you want... you could also alternate between the two. You'd probably be better off not doing something like "advanced algorithm scripting" without some idea of what you're doing though ;)
luccifer00
@luccifer00
Jun 25 2017 00:41 UTC
yees @CroRaptor and @mauriciodeleonc you should return arr.shift(); delete the keyword "item"
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:41 UTC
@arslan555 you´re welcome, and dont stop in just this tutorial, youtube and google have a lot of tutorials so you can learn more
kumquatfelafel
@kumquatfelafel
Jun 25 2017 00:42 UTC
^and as noted, don't be afraid to get info from other sources as well. On related note, the challenge description often give you links as clue how to do challenges.
Mirza Arslan
@arslan555
Jun 25 2017 00:42 UTC
yeah sure . @mauriciodeleonc :)
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:42 UTC
@luccifer00 HAHAHA what
heidisdad2
@heidisdad2
Jun 25 2017 00:42 UTC
@CentropyIT is there something wrong with that line?
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:42 UTC
i still dont understand how it works
but thanks @luccifer00
CamperBot
@camperbot
Jun 25 2017 00:42 UTC
mauriciodeleonc sends brownie points to @luccifer00 :sparkles: :thumbsup: :sparkles:
:warning: mauriciodeleonc already gave luccifer00 points
Jan Shah
@JanShah
Jun 25 2017 00:43 UTC
@heidisdad2 I think it's a bit deeper than that. You should console log your input to see what's coming into the function, then work with that to get the relevant output. I logged a couple of variables and it's not close yet
Matej P.
@CroRaptor
Jun 25 2017 00:43 UTC
i wrote that and its not working hahahaha
heidisdad2
@heidisdad2
Jun 25 2017 00:45 UTC
@CentropyIT ok, not quite sure how to console.log...i have a problem with the loop. i don't know why i just cant get it in my head all the way. i have it understood like 90% but for some reason i cant get the i to loop.
Jan Shah
@JanShah
Jun 25 2017 00:45 UTC
@heidisdad2 in this one you need to use 'arguments'
kumquatfelafel
@kumquatfelafel
Jun 25 2017 00:45 UTC
@mauriciodeleonc *can I have link to that challenge?
Jan Shah
@JanShah
Jun 25 2017 00:45 UTC
there are three in this one, only the first is an array
@kumquatfelafel
Moisés Man
@moigithub
Jun 25 2017 00:46 UTC
@mauriciodeleonc most functions takes an input.. then DO something.. and return a result back
Jan Shah
@JanShah
Jun 25 2017 00:46 UTC
@heidisdad2 I say need, but it's one way of doing it I guess, there are umpteen solutions to every problem
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:46 UTC
@CroRaptor change your arguments to the way i have them
kumquatfelafel
@kumquatfelafel
Jun 25 2017 00:46 UTC
@mauriciodeleonc ah. I see.
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:47 UTC
@moigithub thanks, after looking at my screen for 3 hours i kinda understood it haha
CamperBot
@camperbot
Jun 25 2017 00:47 UTC
mauriciodeleonc sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3414 | @moigithub |http://www.freecodecamp.com/moigithub
kumquatfelafel
@kumquatfelafel
Jun 25 2017 00:47 UTC
@mauriciodeleonc .shift function actually returns the item that it removes. This is the item you want to return, not "item". "item" is what you're adding to line.
heidisdad2
@heidisdad2
Jun 25 2017 00:47 UTC
@CentropyIT ok i will try with arguements. how do i do console.log
Jan Shah
@JanShah
Jun 25 2017 00:48 UTC
@heidisdad2
var product = [];
function destroyer(arr) {
  // Remove all the values
  var args = arguments
  console.log(args[0],args[1],args[2]) 
}

destroyer([1,2,2,3], 2, 3);
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:48 UTC
@kumquatfelafel so it would be like doing to things at the same time, youre telling the function to remove the item and at the same time "return" it
Jan Shah
@JanShah
Jun 25 2017 00:50 UTC
@heidisdad2 you can log virtually anything, complete functions, calls to functions, sums, variables, objects, etc etc. limitless what you can do with it.
heidisdad2
@heidisdad2
Jun 25 2017 00:50 UTC
and i view it in my console in chrome?
Jan Shah
@JanShah
Jun 25 2017 00:50 UTC
@heidisdad2 yep
heidisdad2
@heidisdad2
Jun 25 2017 00:50 UTC
ahh ok, let me try
Jan Shah
@JanShah
Jun 25 2017 00:51 UTC
@heidisdad2 I started writing all my code in scratchjs, it's an addon for chrome
kumquatfelafel
@kumquatfelafel
Jun 25 2017 00:51 UTC
@mauriciodeleonc well... I suppose you could call it killing two birds with one stone. I don't know about "at the same time" ;P ;)
Jan Shah
@JanShah
Jun 25 2017 00:52 UTC
use it in developer tools, it's the easiest way to write, rewrite and check your code instantly, much better than the constant refreshes in codepen
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:53 UTC
1 random question
how do you add emojis here?
kumquatfelafel
@kumquatfelafel
Jun 25 2017 00:53 UTC
(but yeah. more or less)
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:53 UTC
is it because you´re on the phone and not on the computer?
heidisdad2
@heidisdad2
Jun 25 2017 00:53 UTC
scratchjs i will have to check that out
Stephen James
@sjames1958gm
Jun 25 2017 00:53 UTC
Just start with a : colon then a menu will show
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:53 UTC
OHHH hahah
kumquatfelafel
@kumquatfelafel
Jun 25 2017 00:53 UTC

: p ; )

: will show a menu that has a lot of stuff (many of which you may not even want)

mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:54 UTC
thanks @sjames1958gm @kumquatfelafel
CamperBot
@camperbot
Jun 25 2017 00:54 UTC
:cookie: 305 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
mauriciodeleonc sends brownie points to @sjames1958gm and @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:star2: 7880 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:54 UTC
@CroRaptor yep
just like that
Matej P.
@CroRaptor
Jun 25 2017 00:55 UTC
but i dont understand it anymore hahaha
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:55 UTC
did it work?
okay so what i understood was, first you push the last number into the array, then you take the first one out, writing the shift thing in the return part has nothing to do with the push part
the only reason to put it directly in return is because if you didnt do that you would have to have a variable where you store that argument, and then write that in return
victortran2015
@victortran2015
Jun 25 2017 00:58 UTC

Instructions
Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

var myStr = "FirstLine\n \SecondLine\ \rThirdline"; // Change this line
can anyone tell me what is wrong with my code ?
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:58 UTC
you could do it the other way around
function nextInLine(arr, item) {
arr.shift();
return arr.push(item);
}
// Test Setup
var testArr = [1,2,3,4,5];
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
and you would get the same answer
Michael G.
@MichaelBlue
Jun 25 2017 00:59 UTC
I need help with the following:
total should be declared and initialized to 0
total should equal 20
var myArr = [ 2, 3, 4, 5, 6];
var Total = 2;

for (var i = 0; i < myArr.length; i++) {
  Total += myArr[i];
}
kumquatfelafel
@kumquatfelafel
Jun 25 2017 00:59 UTC
@mauriciodeleonc no, because push won't give you the item you're trying to return.
Michael G.
@MichaelBlue
Jun 25 2017 00:59 UTC
Also says: "Total is undefined"
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:59 UTC
hmmm
Michael G.
@MichaelBlue
Jun 25 2017 00:59 UTC
I feel like such a noob
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 00:59 UTC
then ignore me @CroRaptor
i just started yesterday haha
@MichaelBlue too
victortran2015
@victortran2015
Jun 25 2017 01:00 UTC
@mauriciodeleonc can you help me please ??
Stephen James
@sjames1958gm
Jun 25 2017 01:00 UTC
@MichaelBlue Total is not the same as total
Matej P.
@CroRaptor
Jun 25 2017 01:00 UTC
@mauriciodeleonc i am reading what u wrote and dont understand yet hahaha
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:01 UTC
@victortran2015 could you please send me the link to the challenge?
Stephen James
@sjames1958gm
Jun 25 2017 01:01 UTC
@victortran2015 YOu are not supposed to have any spaces, and it is ThirdLine not Thirdline
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:01 UTC
@CroRaptor yeah my english is rusty...but still i got it wrong haha
victortran2015
@victortran2015
Jun 25 2017 01:01 UTC
this one
Jan Shah
@JanShah
Jun 25 2017 01:01 UTC
@victortran2015 \n is what you need
heidisdad2
@heidisdad2
Jun 25 2017 01:01 UTC
@CentropyIT this is what i got back fro args[0]
Matej P.
@CroRaptor
Jun 25 2017 01:01 UTC
@victortran2015 \ backslash
heidisdad2
@heidisdad2
Jun 25 2017 01:02 UTC
(4) [1, 2, 2, 3]
VM2985:7 (4) [1, 2, 2, 3]
VM2983:7 (6) [1, 2, 3, 1, 2, 3]
VM2983:7 (7) [1, 2, 3, 5, 1, 2, 3]
VM2983:7 (5) [3, 5, 1, 2, 2]
VM2983:7 (4) [2, 3, 2, 3]
VM2983:7 (3) ["tree", "hamburger", 53]
Stephen James
@sjames1958gm
Jun 25 2017 01:02 UTC
@victortran2015 Because of chat we cannot tell but you should have 6 \
Christopher McCormack
@cmccormack
Jun 25 2017 01:02 UTC
:wave:
Jan Shah
@JanShah
Jun 25 2017 01:02 UTC
@heidisdad2 ???
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:02 UTC
@victortran2015 var myStr = "FirstLine"+"\n"+"\SecondLine\"+"\r"+"ThirdLine";
that is what i did
literally just adding the "+" signs in between
Matej P.
@CroRaptor
Jun 25 2017 01:02 UTC
@victortran2015 \ \
heidisdad2
@heidisdad2
Jun 25 2017 01:02 UTC
@CentropyIT i dont get it
Jan Shah
@JanShah
Jun 25 2017 01:02 UTC
@mauriciodeleonc that's a clever solution, but not right :)
I'm really surprised it passed
@heidisdad2 neither do i, when I sent you the code it was 1 array and two variables :)
Stephen James
@sjames1958gm
Jun 25 2017 01:03 UTC
@CentropyIT The value of myStr is correct, so it passed, it is not wrong.
Jan Shah
@JanShah
Jun 25 2017 01:03 UTC
I don't know what that is above
Matej P.
@CroRaptor
Jun 25 2017 01:03 UTC
@victortran2015 var myStr = "FirstLine\n\SecondLine\\rThirdLine";
Jan Shah
@JanShah
Jun 25 2017 01:03 UTC
@sjames1958gm ok mate :)
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:04 UTC
@CentropyIT i knew it wasnt the solution as the way asked, but it worked because it asked for the string to be the way it was displayed
kumquatfelafel
@kumquatfelafel
Jun 25 2017 01:04 UTC

@mauriciodeleonc you could do something like

var item2 = arr.shift();
arr.push(item);
return item2;

But even this is a bit questionable. What happens if arr is empty? Do we add and then remove the thing we just added? Do we remove nothing and then add? This is sort of a corner case you have to consider (and I don't remember if there was a test included along those lines) The description makes it sound like they want you to add to array first though. In which case, you should really be shifting last, regardless of whether they actually test for that or not.

mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:04 UTC
still dont know how to properly answer the challenge
heidisdad2
@heidisdad2
Jun 25 2017 01:04 UTC
@CentropyIT yeah i just console.logged args[0]
Hello911
@Hello911
Jun 25 2017 01:04 UTC
@Hello911
My console has this error for my API url. How do I fix it?
index.html:1 XMLHttpRequest cannot load https://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not allowed access.
Jan Shah
@JanShah
Jun 25 2017 01:04 UTC
@mauriciodeleonc clever solution, as I said :)
Steven
@LemonTruth
Jun 25 2017 01:04 UTC
 for(i = 0; i < arr.length; i + size){
    final.push(arr.slice(i, i + size));
  }
I'm having trouble understanding why this is an infinite loop. Could someone explain to me?
Jan Shah
@JanShah
Jun 25 2017 01:04 UTC
@heidisdad2 ["tree", "hamburger", 53] was definitely not in there
Matej P.
@CroRaptor
Jun 25 2017 01:05 UTC
that is how i solve that
victortran2015
@victortran2015
Jun 25 2017 01:05 UTC
thank you all
heidisdad2
@heidisdad2
Jun 25 2017 01:05 UTC
i know, maybe because i am in freed code camp module
victortran2015
@victortran2015
Jun 25 2017 01:05 UTC
i got it
Jan Shah
@JanShah
Jun 25 2017 01:05 UTC
@heidisdad2 idk bro, I didn't have the same problem using arguments
Stephen James
@sjames1958gm
Jun 25 2017 01:05 UTC
@LemonTruth i + size doesn't change i
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:06 UTC
@victortran2015 you´re welcome
Stephen James
@sjames1958gm
Jun 25 2017 01:06 UTC
@kumquatfelafel They do test for that and the instructions are specific about adding to the array first then removing.
Steven
@LemonTruth
Jun 25 2017 01:06 UTC
@sjames1958gm NO F)(*^(&^&% WAAAAYYY
@sjames1958gm TAHNK YOU SOOO MUCH. CANT BELIEVE I DIDN'T NOTICE E THAT
Jan Shah
@JanShah
Jun 25 2017 01:07 UTC
@heidisdad2 definitely nothing in the exercise that I can see. I'd re-open the page and try working on it again. definitely try using scratch because it's so much more convenient to mess about with the code until it's right
kumquatfelafel
@kumquatfelafel
Jun 25 2017 01:08 UTC
@sjames1958gm I am glad to hear they test for that. It's pretty much the most obvious thing that can go wrong. :p
Stephen James
@sjames1958gm
Jun 25 2017 01:08 UTC
@LemonTruth :+1:
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:08 UTC

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


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

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

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

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

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

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

Ashley Owens
@yelhsa
Jun 25 2017 01:08 UTC
I'm on the stand in line challenge and I've solved it using an if-else statement but idk if that how it was supposed to be done. Anyone have any insight?
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:09 UTC
the if-else is taught after that challenge isnt it?
Jan Shah
@JanShah
Jun 25 2017 01:10 UTC
@yelhsa if you've solved it you've found a solution :) I think there are loads of ways of solving each problem, I wouldn't worry about it
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:10 UTC
i mean, it´s coding, you can get to the answer using any path you want, as long as you get it there´s nothing wrong
Ashley Owens
@yelhsa
Jun 25 2017 01:11 UTC
@mauriciodeleonc I had to look it up. I didn't understand what it was asking me to do.
Stephen James
@sjames1958gm
Jun 25 2017 01:11 UTC
@mauriciodeleonc 1) you aren't testing for hasOwnProperty before returning the property
You aren't actually even returning the property and
contacts[i].prop !== prop is not checking for the property either
Christopher McCormack
@cmccormack
Jun 25 2017 01:11 UTC
@mauriciodeleonc this should be an if conditional - contacts.hasOwnProperty(prop);
Ashley Owens
@yelhsa
Jun 25 2017 01:11 UTC
@CentropyIT I just want to make sure i take away what i'm supposed to from this lesson
Stephen James
@sjames1958gm
Jun 25 2017 01:11 UTC
@yelhsa stand in line doesn't need any if checks
@cmccormack contacts[i].hasOwnProperty(prop)
Jan Shah
@JanShah
Jun 25 2017 01:12 UTC
@yelhsa in that case, probably not what the answer is looking for
Christopher McCormack
@cmccormack
Jun 25 2017 01:12 UTC
@sjames1958gm yes that as well :) @mauriciodeleonc
victortran2015
@victortran2015
Jun 25 2017 01:12 UTC
anyone is doing Hackreactor prep
i'm stuck at Module 0
:(
Jan Shah
@JanShah
Jun 25 2017 01:13 UTC
@victortran2015 what that ?
prep for what?
victortran2015
@victortran2015
Jun 25 2017 01:13 UTC
it's a prep course for Hackreactor bootcamp @CentropyIT
Jan Shah
@JanShah
Jun 25 2017 01:13 UTC
is it free?
victortran2015
@victortran2015
Jun 25 2017 01:13 UTC
yeah
Jan Shah
@JanShah
Jun 25 2017 01:14 UTC
I like free, tastes better
victortran2015
@victortran2015
Jun 25 2017 01:14 UTC
lolz
they make it hard
so you can pay for the paid version
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:14 UTC
@CentropyIT :laughing:
victortran2015
@victortran2015
Jun 25 2017 01:16 UTC
@mauriciodeleonc you wanna do it too bro ?
kumquatfelafel
@kumquatfelafel
Jun 25 2017 01:17 UTC

@mauriciodeleonc adding to what @sjames1958gm said, your logic is a bit off here.
Consider conditions a and b:
if(a)
else if (not a)
else if (b)

it will only go to else statements if the previous conditions in the chain are not satisfied. Is there a way for it to reach b then?

mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:17 UTC
@sjames1958gm okay soooo... im totally not getting it, im more of a visual guy, so could you /anyone write the piece of code where im making the mistake please? but still, thanks a lot, if i spoke coding i would totally get you hah
CamperBot
@camperbot
Jun 25 2017 01:17 UTC
mauriciodeleonc sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: mauriciodeleonc already gave sjames1958gm points
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:19 UTC
@kumquatfelafel okay this helps
Manish Giri
@Manish-Giri
Jun 25 2017 01:19 UTC
@victortran2015 what are you stuck at?
victortran2015
@victortran2015
Jun 25 2017 01:19 UTC
@Manish-Giri module 0
Manish Giri
@Manish-Giri
Jun 25 2017 01:20 UTC
I meant which problem?
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:20 UTC
i understand the flaw in my logic.... so, what you´re saying is that i should do 2 separate ifs?
Manish Giri
@Manish-Giri
Jun 25 2017 01:20 UTC
I hope not "transform employee data"
@victortran2015
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:21 UTC

@kumquatfelafel

i understand the flaw in my logic.... so, what you´re saying is that i should do 2 separate ifs?

kumquatfelafel
@kumquatfelafel
Jun 25 2017 01:24 UTC

@mauriciodeleonc depending on what those ifs are and whether or not you think else is also needed anywhere and how you define "separate"... Maybe? :laughing:

You also have to be very careful about location and content of return statements.

I have to go so... plenty more people on here and can always review earlier challenges if get stuck.

mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:25 UTC
yup dont worry
you´ve helped me a lot @kumquatfelafel thanks
CamperBot
@camperbot
Jun 25 2017 01:25 UTC
mauriciodeleonc sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:warning: mauriciodeleonc already gave kumquatfelafel points
Manish Giri
@Manish-Giri
Jun 25 2017 01:25 UTC
@mauriciodeleonc also note that prop is a variable which contains the object property, so dot notation won't work here
(contacts[i].prop
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:26 UTC
yep thats where im stuck...because the result i get is "Akira", "likes" where likes is an array...and im trying to access that array
thats where im stuck
heidisdad2
@heidisdad2
Jun 25 2017 01:28 UTC
@CentropyIT wow thanks, i have been playing around with console.log and it great
CamperBot
@camperbot
Jun 25 2017 01:28 UTC
heidisdad2 sends brownie points to @centropyit :sparkles: :thumbsup: :sparkles:
:cookie: 400 | @centropyit |http://www.freecodecamp.com/centropyit
Manish Giri
@Manish-Giri
Jun 25 2017 01:29 UTC
@mauriciodeleonc here's some pseudocode
//loop through contacts array 
 if firstName is a match 
   a. if property found - return it's value
   b. else return no prop found
//outside the loop, return no contacts found
fdemaa
@fdemaa
Jun 25 2017 01:30 UTC
i dont understand the algorithm truncate a string, how much i have to cut ?
The maximum length? im a bit lost on this one lol
Stephen James
@sjames1958gm
Jun 25 2017 01:31 UTC
@fdemaa The string you return should be num length if num > 3
Unless the input string is already less than num
if num <= 3 then the truncated string will be num + 3 in length (because of the added ...)
fdemaa
@fdemaa
Jun 25 2017 01:32 UTC
@sjames1958gm thanks , i will try it
CamperBot
@camperbot
Jun 25 2017 01:32 UTC
fdemaa sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7881 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 01:33 UTC
@Manish-Giri ohhh, okay i got the firstName matching (returning its value) and no matching (returning the message), but can you do an if inside another if (without writing else if, or else)
fdemaa
@fdemaa
Jun 25 2017 01:34 UTC
you mean
if ( whatever && whatever)
@mauriciodeleonc
Manish Giri
@Manish-Giri
Jun 25 2017 01:36 UTC
@mauriciodeleonc yes you can
fdemaa
@fdemaa
Jun 25 2017 01:36 UTC
hi manish
Panayiotis Mangafas
@mangafas
Jun 25 2017 01:41 UTC
hey im having a problem with my code any thoughts?

var count = 0;

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



  return count + answer;




  // Only change code above this line
}


// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Stephen James
@sjames1958gm
Jun 25 2017 01:41 UTC
@mangafas Missing "A" in else if
You are not returning count + string only string
Panayiotis Mangafas
@mangafas
Jun 25 2017 01:43 UTC
what do you mean on returning count + string only string?
aRtoo
@artoodeeto
Jun 25 2017 01:45 UTC

hi guys. you do you target this css attr to jqury?

.bubble:after
{
content: '';
position: absolute;
border-style: solid;
border-width: 25px 16px 0;
border-color: #FFFFFF transparent;
display: block;
width: 0;
z-index: 1;
bottom: -25px;
left: 97px; <---- i want to change this to right if direction of character is facing right
}

.bubble:before
{
content: '';
position: absolute;
border-style: solid;
border-width: 26px 17px 0;
border-color: #ACABB4 transparent;
display: block;
width: 0;
z-index: 0;
bottom: -28px;
left: 96px; i want to change this to right if direction of character is facing right
}

heres my code in jquery

    quote = data[0].quote;
          character = data[0].character;
          img = data[0].image;
          direction = data[0].characterDirection;

          if(direction === 'Left'){
            $('.bubble').attr("right", "Left")
            console.log(direction);
          }else{
            console.log(direction);
          }

hi guys. you do you target this css attr to jqury?

.bubble:after
{
content: '';
position: absolute;
border-style: solid;
border-width: 25px 16px 0;
border-color: #FFFFFF transparent;
display: block;
width: 0;
z-index: 1;
bottom: -25px;
left: 97px; <---- i want to change this to right if direction of character is facing right
}

.bubble:before
{
content: '';
position: absolute;
border-style: solid;
border-width: 26px 17px 0;
border-color: #ACABB4 transparent;
display: block;
width: 0;
z-index: 0;
bottom: -28px;
left: 96px; i want to change this to right if direction of character is facing right
}

heres my code in jquery

    quote = data[0].quote;
          character = data[0].character;
          img = data[0].image;
          direction = data[0].characterDirection;

          if(direction === 'Left'){
            $('.bubble').attr("right", "Left")
            console.log(direction);
          }else{
            console.log(direction);
          }
Adam Bohannon
@abohannon
Jun 25 2017 01:47 UTC
Anyone willing to help me understand how recursion in the steamroller challenge works? I understand it conceptually, but having trouble reading it/understanding the execution of the logic.

function steamrollArray(arr) {

  var oneArray = [];

  flatten(arr);

  function flatten(arr){
    arr.forEach(function(arr2){
      if(!Array.isArray(arr2)){
        oneArray.push(arr2);
      }
      else{
        flatten(arr2);
      }
    });
  }


  return oneArray;

}

steamrollArray([1, [2], [3, [[4]]]]);
Moisés Man
@moigithub
Jun 25 2017 01:49 UTC
@artoodeeto .attr("attribute name", "value")
its NOT .attr("attribute", "attribute")
Abhishek Tiwari
@fillopfy
Jun 25 2017 01:49 UTC
@mangafas return count+" Bet" for card>0 and count+"Hold" using else
aRtoo
@artoodeeto
Jun 25 2017 01:49 UTC
@moigithub tried it bro nothing happens
Moisés Man
@moigithub
Jun 25 2017 01:50 UTC
@artoodeeto if u wanna change right to left..
then u need to remove left,, then add right with some value
aRtoo
@artoodeeto
Jun 25 2017 01:50 UTC
@moigithub right. thats what i thougt. because u cant replace the attribute name directly
Moisés Man
@moigithub
Jun 25 2017 01:51 UTC
$('.bubble').removeAttr("left" )
$('.bubble').attr("right", "100px")
https://api.jquery.com/removeAttr/
Stephen James
@sjames1958gm
Jun 25 2017 01:51 UTC
@abohannon Basically a recursive process breaks the problem down into smaller and smaller pieces (calling the function with these reduced problems) until a base condition is met.
In this case the base condition is !Array.isArray(arr2) when this condition is hit then a value is pushed and that branch of recursion is stopped.
Panayiotis Mangafas
@mangafas
Jun 25 2017 01:53 UTC
@fillopfy still wrong, are we sure that the rest of the code is correct?
Abhishek Tiwari
@fillopfy
Jun 25 2017 01:53 UTC
@mangafas no....why have you set answer=hold in the beginning
Adam Bohannon
@abohannon
Jun 25 2017 01:54 UTC
@sjames1958gm so is the array being modified every time the function runs? And that's why the first index returns false and thus is pushed?
aRtoo
@artoodeeto
Jun 25 2017 01:54 UTC
@moigithub thanks bro
CamperBot
@camperbot
Jun 25 2017 01:54 UTC
artoodeeto sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3415 | @moigithub |http://www.freecodecamp.com/moigithub
Adam Bohannon
@abohannon
Jun 25 2017 01:54 UTC
@sjames1958gm i was confused because if you check isArray on each index it gives your false, true, true
Moisés Man
@moigithub
Jun 25 2017 01:54 UTC
@mangafas ur code returing 1Bet and shouldbe 1 Bet <-- witha space
saem thing with hold
Panayiotis Mangafas
@mangafas
Jun 25 2017 01:54 UTC
because if it wasnt bigger than 0 then it would return be default hold
Abhishek Tiwari
@fillopfy
Jun 25 2017 01:54 UTC
@mangafas remove that and use if else to return count+string
Panayiotis Mangafas
@mangafas
Jun 25 2017 01:55 UTC
@fillopfy @moigithub it was the space thingy... thanks
CamperBot
@camperbot
Jun 25 2017 01:55 UTC
mangafas sends brownie points to @fillopfy and @moigithub :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @fillopfy |http://www.freecodecamp.com/fillopfy
:star2: 3416 | @moigithub |http://www.freecodecamp.com/moigithub
fdemaa
@fdemaa
Jun 25 2017 01:56 UTC
@sjames1958gm hey dude this is entire wrong or i can fix over this? I have 2 conditions i dont pass yet
function truncateString(str, num) {

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

} else{
  return str.slice(0,num) + "...";

}

}

truncateString("Absolutely Longer", 2);
Mirza Arslan
@arslan555
Jun 25 2017 01:57 UTC
var myStr = "FirstLine\n\SecondLine\rThirdLine";
var myStr = "FirstLine\n\SecondLine\rThirdLine";
this is my code what;s wrong with it ?
instruction : FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
Abhishek Tiwari
@fillopfy
Jun 25 2017 01:58 UTC
@arslan555 double backlash slash after \n and before \r
Stephen James
@sjames1958gm
Jun 25 2017 01:59 UTC
@abohannon So at the top level (the first call to flatten isArray is false, true, true
For false 1 is pushed, for true flatten([2]) is called and flatten([3, [[4]]]) is called
flatten([2]) results in isArray of false only and 2 is pushed
flatten([3, [[4]]) results in isArray of false, true, so 3 is pushed and flatten([[4]]) is called
So you see each time flatten is called and arr2 is a new value the problem is reduced
Mirza Arslan
@arslan555
Jun 25 2017 01:59 UTC
@fillopfy thank you very much
CamperBot
@camperbot
Jun 25 2017 01:59 UTC
arslan555 sends brownie points to @fillopfy :sparkles: :thumbsup: :sparkles:
:cookie: 287 | @fillopfy |http://www.freecodecamp.com/fillopfy
Stephen James
@sjames1958gm
Jun 25 2017 02:00 UTC
@arslan555 missing the backslash escaped before \r
@fdemaa Your first check shoiuld be if the truncation is needed at all if (str.length > num)
I think your check should also be num > 3
Daniel Lim
@ddanielnp
Jun 25 2017 02:01 UTC
https://www.freecodecamp.com/challenges/make-object-properties-private need some help with this..
var Bike = function() {

  // Only change code below this line.
var getGear = 0;

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


var myCar = new Car();

var myBike = new Bike();
Stephen James
@sjames1958gm
Jun 25 2017 02:02 UTC
@ddanielnp The private variable should be gear not getGear
You should have two functions getGear and setGear
Jan Shah
@JanShah
Jun 25 2017 02:02 UTC
@ddanielnp return setGear; I think here you want to set the value of gear, not return the value
fdemaa
@fdemaa
Jun 25 2017 02:03 UTC
@sjames1958gm ohh what an idiot, thanks !!!
CamperBot
@camperbot
Jun 25 2017 02:03 UTC
fdemaa sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: fdemaa already gave sjames1958gm points
mblasik933
@mason933blasik
Jun 25 2017 02:04 UTC
var myData = myArray[0][0] + myArray [2][0];
can someone help me out? whats wrong with my code?
Dan Stockham
@DanStockham
Jun 25 2017 02:04 UTC
@mason933blasik What is the issue?
@mason933blasik What challenge is it?
mblasik933
@mason933blasik
Jun 25 2017 02:05 UTC
@DanStockham modify array with indexes
Stephen James
@sjames1958gm
Jun 25 2017 02:05 UTC
@mason933blasik I think you were supposed to change the indexes inside the myArray[0][0]
not add a value
mblasik933
@mason933blasik
Jun 25 2017 02:06 UTC
alright ill try that thanks
Dan Stockham
@DanStockham
Jun 25 2017 02:06 UTC
@mason933blasik Which challenge is it?
zambrinf
@zambrinf
Jun 25 2017 02:10 UTC
"Local Scope and Functions" has bug?
Adam Bohannon
@abohannon
Jun 25 2017 02:10 UTC
@sjames1958gm ok so maybe i don't fully understand how forEach works. As the method iterates through the array, is it doing this?
1
[2]
2
[3, [[4]]]
3
[[4]]
[4]
4
Justus
@GraniteHope
Jun 25 2017 02:10 UTC
Do they allow recursion on the JS challenges? I tried to use a recursive solution and it gets stuck with the text "testing challenge..."
Stephen James
@sjames1958gm
Jun 25 2017 02:10 UTC
@zambrinf Probably not, but sometimes you have to refrwsh your browser
zambrinf
@zambrinf
Jun 25 2017 02:11 UTC
@sjames1958gm got stuck, even refreshing I can't do it
Stephen James
@sjames1958gm
Jun 25 2017 02:11 UTC
@abohannon Well sort of. Each recursive call invokes another call to forEach.
Justus
@GraniteHope
Jun 25 2017 02:11 UTC
function steamrollArray(arr) { // I'm a steamroller, baby recLevel++; if(recLevel > 5) return "RECURSION LIMIT"; for(var i = 0; i < arr.length;i++){ if(!Array.isArray(arr[i])) retArr.push(arr[i]); else retArr.push(steamrollArray(arr[i])); } return retArr; }
Stephen James
@sjames1958gm
Jun 25 2017 02:11 UTC
@zambrinf Show you code?
zambrinf
@zambrinf
Jun 25 2017 02:12 UTC

@sjames1958gm

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

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

// Run and check the console
// myVar is not defined outside of myLocalScope
// Now remove the console log line to pass the test

aRtoo
@artoodeeto
Jun 25 2017 02:12 UTC
@moigithub bro its not working.
.bubble:after
{
content: '';
position: absolute;
border-style: solid;
border-width: 25px 16px 0;
border-color: #FFFFFF transparent;
display: block;
width: 0;
z-index: 1;
bottom: -25px;
left: 97px; <--- i cant remove this by the jquery code
}
$('.bubble').removeAttr("left");
Stephen James
@sjames1958gm
Jun 25 2017 02:13 UTC
@zambrinf I think you need to restore that 'use strict' to its own line and give myVar a different value
@abohannon So here these numbers next to the value are how many calls to flatten recursively when the forEach is done.
1       // 1
[2]    // 1
2       //  2
[3, [[4]]]  // 1
3 // 2
[[4]] // 2
[4] // 3
4 // 4
zambrinf
@zambrinf
Jun 25 2017 02:20 UTC
@sjames1958gm not working
Stephen James
@sjames1958gm
Jun 25 2017 02:22 UTC
@zambrinf Best thing is to reset the challenge and try again
zambrinf
@zambrinf
Jun 25 2017 02:25 UTC
@sjames1958gm pressed 1000 times F5, worked
lol
Stephen James
@sjames1958gm
Jun 25 2017 02:26 UTC
@zambrinf lol
Alex
@LosAngalex
Jun 25 2017 02:29 UTC
I'm having a lot of trouble with the challenge: "Comparison with the Inequality Operator". Two of the tests are not passing. Is anyone able to help?
Jan Shah
@JanShah
Jun 25 2017 02:30 UTC
can you post your code? @LosAngalex
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 02:30 UTC
@Manish-Giri i wrote what i understood from the pseudocode you sent me
function lookUpProfile(firstName, prop){
// Only change code below this line 
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName === lookUpProfile(firstName)) {
      name = firstName;
      if (prop === lookUpProfile(prop)) {
        property = prop;
      } else {
        property = "No such property";
      }      
    } 
  }
  return "No such contact";
// Only change code above this line
}
Alex
@LosAngalex
Jun 25 2017 02:30 UTC
How do I do the markdown so it posts correctly (new to forums..and markdown...and javascript)
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 02:30 UTC
butttt... cant defeat this challenge :(
Jan Shah
@JanShah
Jun 25 2017 02:30 UTC
``` <<use that above and below your code
@LosAngalex
Alex
@LosAngalex
Jun 25 2017 02:31 UTC
'''
CamperBot
@camperbot
Jun 25 2017 02:31 UTC
:bulb: to format code use backticks! ``` more info
Alex
@LosAngalex
Jun 25 2017 02:31 UTC

'''function testNotEqual(val) {
if (val !== 99) {
return "Not Equal";
}
return "Equal";
}

testNotEqual(99);'''

CamperBot
@camperbot
Jun 25 2017 02:31 UTC
:bulb: to format code use backticks! ``` more info
Jan Shah
@JanShah
Jun 25 2017 02:31 UTC
use backticks, not single quotes ```
Alex
@LosAngalex
Jun 25 2017 02:31 UTC

``` function testNotEqual(val) {
if (val !== 99) {
return "Not Equal";
}
return "Equal";
}

testNotEqual(99);~~~

Jan Shah
@JanShah
Jun 25 2017 02:31 UTC
close :)
aRtoo
@artoodeeto
Jun 25 2017 02:31 UTC
how do you remove a attr in a css not in a html
Alex
@LosAngalex
Jun 25 2017 02:31 UTC

```function testNotEqual(val) {
if (val !== 99) {
return "Not Equal";
}
return "Equal";
}

testNotEqual(99);```

Dude. I can't even
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 02:31 UTC
you have to leave a space
Jan Shah
@JanShah
Jun 25 2017 02:32 UTC
above and below,, jst edit it!! :smile:
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 02:32 UTC
i mean... an enter key
Jan Shah
@JanShah
Jun 25 2017 02:32 UTC
function testNotEqual(val) {
if (val !== 99) {
return "Not Equal";
}
return "Equal";
}
testNotEqual(99);
Alex
@LosAngalex
Jun 25 2017 02:32 UTC
Thank you.
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 02:33 UTC
hahaha
Jan Shah
@JanShah
Jun 25 2017 02:33 UTC
anyway. :)
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 02:33 UTC
you´re welcome
Alex
@LosAngalex
Jun 25 2017 02:33 UTC
Maybe my brain isn't on today... Anyway, the tests that aren't passing are "testNotEqual("99") should return "Equal"" and "You should use the != operator"
Thank you all for being patient... Again, I'm so new to this.
Jan Shah
@JanShah
Jun 25 2017 02:34 UTC
@LosAngalex you're returning equal whether or not the if statement is true
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 02:34 UTC
@CentropyIT could you help me with the challenge i posted previously please?
@LosAngalex dont worry...we´re all newbies
and by all i mean me
Justus
@GraniteHope
Jun 25 2017 02:35 UTC

Am doing the flattened arrays challenge and got it to pass all of my tests., yet the challenge editor says it fails every test.

```var retArr = [];
var recCount = 0;
function steamrollArray(arr) {
arr.forEach(iter);
return retArr;
}

function iter(val,key,arr){
recCount++;
if(Array.isArray(val)) val.forEach(iter);
else retArr.push(val);
}
```

Jan Shah
@JanShah
Jun 25 2017 02:35 UTC
@mauriciodeleonc I can try but I shortened my code down to something ludicrous
Alex
@LosAngalex
Jun 25 2017 02:35 UTC
I seriously didn't even know that "`" was a button on the keyboard. -- so what do I do about the code? I don't know what else I have to write or what it expects
Jan Shah
@JanShah
Jun 25 2017 02:36 UTC
@LosAngalex it should be left of the number 1 on your keyboard
abraham anak agung
@padunk
Jun 25 2017 02:36 UTC
@artoodeeto use $('.sample').removeAttr('atribute to removed');
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 02:36 UTC
dont worry
once i see it i´ll try to understand it
Alex
@LosAngalex
Jun 25 2017 02:36 UTC
@CentropyIT I figured it out now
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 02:37 UTC
to me the backstick is next to the enter key
abraham anak agung
@padunk
Jun 25 2017 02:39 UTC
@GraniteHope move your global variable inside the function steamroll, and why you make another function outside it?
Caleb Bowers
@cmbowers1
Jun 25 2017 02:39 UTC

does any one know how to solve this i need help
function myLocalScope() {
'use strict';

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

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

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

abraham anak agung
@padunk
Jun 25 2017 02:40 UTC
@cmbowers1 declare your variable inside a function and delete the console.log word
Caleb Bowers
@cmbowers1
Jun 25 2017 02:41 UTC
@padunk thx
CamperBot
@camperbot
Jun 25 2017 02:41 UTC
cmbowers1 sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 366 | @padunk |http://www.freecodecamp.com/padunk
Dan Stockham
@DanStockham
Jun 25 2017 02:41 UTC
@cmbowers1 myVar is declared inside your function which has it's own local scope. The global scope cannot access it unless through a special method.
Which is the use of closure.
Logeshwari
@lokivictoria
Jun 25 2017 02:55 UTC
Help me out guysvar myStr="\"Firstline\n\SecondLine\\rThirdLine\""; // Change this line
myStr should have encoded text with the proper escape sequences and no spacing. I could not fine any error in the coding but still showing error
abraham anak agung
@padunk
Jun 25 2017 02:57 UTC
@lokivictoria you need \\ for backslash and delete additional "\at the start and at the end
"FirstLine NEW LINE BACKSLASH SecondLine BACKSLASH CARRIAGE RETURN ThirdLine"
Logeshwari
@lokivictoria
Jun 25 2017 03:00 UTC
var myStr="Firstline\n\SecondLine\\rThirdLine";
still the same error
@padunk Thanks for your help but still the same error.
CamperBot
@camperbot
Jun 25 2017 03:01 UTC
lokivictoria sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 367 | @padunk |http://www.freecodecamp.com/padunk
abraham anak agung
@padunk
Jun 25 2017 03:01 UTC
@lokivictoriaFirstLine not Firstline and before secondline, backslash \\
Mvjarrett41
@Mvjarrett41
Jun 25 2017 03:03 UTC
hey all, im having issues with the camelCase lesson
Logeshwari
@lokivictoria
Jun 25 2017 03:04 UTC
@padunk I got it, Thank You
CamperBot
@camperbot
Jun 25 2017 03:04 UTC
lokivictoria sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:warning: lokivictoria already gave padunk points
abraham anak agung
@padunk
Jun 25 2017 03:04 UTC
@lokivictoria :+1:
Mvjarrett41
@Mvjarrett41
Jun 25 2017 03:04 UTC
im shown 3 variables to show camelCase, and i have the definitions correct. however, it shows im aparrently not using proper camelCase on declaration and assignment sections.

// Declarations
var studlyCapVar = 10;
var properCamelCase = "A String";
var titleCaseOver = 9000;

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

aRtoo
@artoodeeto
Jun 25 2017 03:04 UTC
@padunk tried bro nothing happens. its in the css file
abraham anak agung
@padunk
Jun 25 2017 03:06 UTC
@artoodeeto then try $("").css({"someting": "", "something": ""}); empty the value
aRtoo
@artoodeeto
Jun 25 2017 03:06 UTC
@padunk not that too bro. because i want to replace the "something" not the value
Logeshwari
@lokivictoria
Jun 25 2017 03:09 UTC
@Mvjarrett41 you have to change the same in Assignments.
abraham anak agung
@padunk
Jun 25 2017 03:10 UTC
@artoodeeto you could set it new with .css and set the old one to "". maybe it could work
aRtoo
@artoodeeto
Jun 25 2017 03:11 UTC
@padunk look at this. maybe itlle work but this. wait
Mvjarrett41
@Mvjarrett41
Jun 25 2017 03:12 UTC
@lokivictoria oooooohhhhhh. had me confused, i thought they were examples, thank you.
CamperBot
@camperbot
Jun 25 2017 03:12 UTC
mvjarrett41 sends brownie points to @lokivictoria :sparkles: :thumbsup: :sparkles:
:cookie: 147 | @lokivictoria |http://www.freecodecamp.com/lokivictoria
Mvjarrett41
@Mvjarrett41
Jun 25 2017 03:12 UTC
and it plainly says it in the instructions. couldnt see the words for the text.
aRtoo
@artoodeeto
Jun 25 2017 03:12 UTC
@padunk
.bubble:after  <-- but this is the problem theres :after
{
content: '';
position: absolute;
border-style: solid;
border-width: 25px 16px 0;
border-color: #FFFFFF transparent;
display: block;
width: 0;
z-index: 1;
bottom: -25px;
left: 97px; <--- i want to change the attribute to right:97px;
}

.bubble:before <-- but this is the problem theres :before
{
content: '';
position: absolute;
border-style: solid;
border-width: 26px 17px 0;
border-color: #ACABB4 transparent;
display: block;
width: 0;
z-index: 0;
bottom: -28px;
left: 96px; <--- i want to change the attribute to right:96px;
}
@padunk
i have this jquery bro.

          if(direction === 'Left'){
            $('.bubble').removeAttr("right",)
            console.log(direction);
          }else{
            $('.bubble').removeAttr("right");
            console.log(direction);
          }
abraham anak agung
@padunk
Jun 25 2017 03:15 UTC
@artoodeeto well, i never change something like that before, maybe someone at other chat room might help. sorry bro
luccifer00
@luccifer00
Jun 25 2017 03:15 UTC
function reverseString(str) {

  str = str.split(' ');

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


  str1 = str.join(" ");

return str; 

}
reverseString("hello from the other");

hi there, i am on a simple "reverse a String" challenge....

i have this, and i get an error : str[i] is not a function.

I am trying to do it step by step... i think i have the split well done, a can do a reverse in the whole arr, and i can get that array into an string again.... but i use str1, becouse i am testing on the other stuff... reversing each word...

for that i think i can use a foor loop, to enter in each array and reverse each one.... i dont know if i am on the right way but the code is wrond somewhere, or i have to change my point of view! any advice!?

aRtoo
@artoodeeto
Jun 25 2017 03:17 UTC
@padunk all good bro. maybe its enough for now. its for my quote generator. i think its too much thouhg
abraham anak agung
@padunk
Jun 25 2017 03:19 UTC
@luccifer00 you don't need loop to do it. just split it reverse and join
there is a difference if you split(" ") with split("")
luccifer00
@luccifer00
Jun 25 2017 03:21 UTC
ok ! i get at all!! thanks @padunk split("") create an array with each character.... thanks
CamperBot
@camperbot
Jun 25 2017 03:21 UTC
luccifer00 sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 368 | @padunk |http://www.freecodecamp.com/padunk
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 03:33 UTC

what????

Our myCar variable now has a property turboType with a value of "twin".

In the editor, use the Car constructor to create a new instance and assign it to myCar.

Then give myCar a nickname property with a string value.


var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 5;
};

// Only change code below this line.

var myCar;
there is no property called turboType
CallMeOrange
@EgnaroDev
Jun 25 2017 03:34 UTC
Then create one
Why do you think var myCar is there?
Ken Haduch
@khaduch
Jun 25 2017 03:36 UTC
@javelina187 :point_up: June 24, 2017 3:35 PM - well, you should give it a fair shot and see how you do. If you're totally new at any sort of programming, then there is a lot to learn. As you said, you need those skills for doing most websites, as more and more are using javascript in one form or another to make the pages dynamic. Good luck on your learning journey!
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 03:36 UTC
@MCTwoDigitZero im supposed to give "myCar a nickname property
that cant be done with push right?
CallMeOrange
@EgnaroDev
Jun 25 2017 03:37 UTC
@mauriciodeleonc Sorry Im not sure :/, Im not there yet
abraham anak agung
@padunk
Jun 25 2017 03:37 UTC
Just type it
CallMeOrange
@EgnaroDev
Jun 25 2017 03:37 UTC
var Car already exist so I thought you should create new one for myCar
@padunk Can you help me?
abraham anak agung
@padunk
Jun 25 2017 03:38 UTC
Perhaps
CallMeOrange
@EgnaroDev
Jun 25 2017 03:38 UTC
@padunk This is not about Counting Cards
:p
abraham anak agung
@padunk
Jun 25 2017 03:38 UTC
Lol...
CallMeOrange
@EgnaroDev
Jun 25 2017 03:38 UTC
Challenge Name: Using Objects for Lookups
Code: below
function phoneticLookup(val) {
  var result = "";

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

// Change this value to test
phoneticLookup("charlie");
NotKeefe
@NotKeefe
Jun 25 2017 03:38 UTC
Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
luccifer00
@luccifer00
Jun 25 2017 03:39 UTC
@padunk are u rhere??? i still with the challenge.... i have done , and i have to use filter, to eliminate the extra spaces, but , de !== operator dosent do anything!! so what can i do??
NotKeefe
@NotKeefe
Jun 25 2017 03:39 UTC
var myStr = " I am a \"double quoted\" string inside \"double quotes\".";// Change this line
help?
CallMeOrange
@EgnaroDev
Jun 25 2017 03:39 UTC
Im trying to figure out how could a parameter grab these objects
abraham anak agung
@padunk
Jun 25 2017 03:40 UTC
@MCTwoDigitZero u return empty string
CallMeOrange
@EgnaroDev
Jun 25 2017 03:40 UTC
True..
abraham anak agung
@padunk
Jun 25 2017 03:40 UTC
@luccifer00 show ur code
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 03:40 UTC

@padunk

var myCar = new Car();

i wrote that and i marked 3/4 of the checkmarks... but the last one "The property nickname of myCar should be a string. ", that i dont know how to put it in

CallMeOrange
@EgnaroDev
Jun 25 2017 03:41 UTC
Ok so I changed empty string to val, but still not able to get these object
Let me figure out this one
Diego Mayer
@Chrono79
Jun 25 2017 03:41 UTC
@NotKeefe you have a space at the start, before the I, delete it
abraham anak agung
@padunk
Jun 25 2017 03:41 UTC
@mauriciodeleonc then add it
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 03:42 UTC
...
abraham anak agung
@padunk
Jun 25 2017 03:42 UTC
This.nickname
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 03:42 UTC
that doesnt work bro
CallMeOrange
@EgnaroDev
Jun 25 2017 03:42 UTC
@padunk I got it
function phoneticLookup(val) {

var dex = {
  "alpha": "Adams",
  "bravo": "Boston",
  "charlie": "Chicago",
  "delta": "Denver",
  "echo": "Easy",
  "foxtrot": "Frank",
  "": undefined
};
  return dex[val];
}

// Change this value to test
phoneticLookup("charlie");
But I think that what Im not supposed to do..
Diego Mayer
@Chrono79
Jun 25 2017 03:43 UTC
@MCTwoDigitZero delete "": undefined, if the property doesn't exist, obj[propertyThatDoesntExist] will return undefined
CallMeOrange
@EgnaroDev
Jun 25 2017 03:43 UTC
Oh looks like I didnt need it
So just if its invalid, it will just return undefined/error
luccifer00
@luccifer00
Jun 25 2017 03:44 UTC
function reverseString(str) {
  str = str.split('');
  str = str.filter(function(val) { return val !=="";});

 str = str.reverse();  str = str.join("");

  return str;
}

reverseString("hello from earth");

@padunk , I resolve by my self, i had a join(" ") and i change it to join("")

any way.... is the proper wy to do it?? :smile:

mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 03:44 UTC
@MCTwoDigitZero you have your list "dex" with its properties... now you need to "show" or return from your list "dex" when you´re looking for a specific [val]
CallMeOrange
@EgnaroDev
Jun 25 2017 03:44 UTC
@mauriciodeleonc I already did it
I passed..
jasonrest
@jasonrest
Jun 25 2017 03:44 UTC
sorry guys took a break, but im back to it now. still stuck on this one. last thing someone told me was that the function check has its own parameters. not sure what that means or how to fix this. not passing any tests...
function destroyer(arr) {
    var args = Array.prototype.slice.call(arguments, 1);

    function check(args){
      return arguments[0].indexOf(args) === -1;
    }
      return arr.filter(check);
  }  
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
CallMeOrange
@EgnaroDev
Jun 25 2017 03:44 UTC
return dex[val]
abraham anak agung
@padunk
Jun 25 2017 03:45 UTC
@luccifer00 no, as i told , split, reverse, join that is all
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 03:45 UTC
oh yeah, didnt see it
Diego Mayer
@Chrono79
Jun 25 2017 03:45 UTC
@jasonrest use arr, not arguments[0], arguments[0] inside check is not arr
Each function has its own argument object
abraham anak agung
@padunk
Jun 25 2017 03:46 UTC
@MCTwoDigitZero :+1:
CallMeOrange
@EgnaroDev
Jun 25 2017 03:46 UTC
I was confused of this challenge because of Only edit code above/below or something
Diego Mayer
@Chrono79
Jun 25 2017 03:46 UTC
@MCTwoDigitZero that's not a problem, you could assign the value to result or whatever the var already there was named
CallMeOrange
@EgnaroDev
Jun 25 2017 03:46 UTC
Yeah..
Daniel Lim
@ddanielnp
Jun 25 2017 03:46 UTC
does the solutions to the questions that i have completed be saved when i access previous questions?
CallMeOrange
@EgnaroDev
Jun 25 2017 03:46 UTC
If Im supposed to follow that rule, I wouldn't have delete variable result and change return
jasonrest
@jasonrest
Jun 25 2017 03:47 UTC
@Chrono79 ok but i thought we were searching the first argument which is the array for the next two arguments which are the ones that follow.
Diego Mayer
@Chrono79
Jun 25 2017 03:47 UTC
exactly
jasonrest
@jasonrest
Jun 25 2017 03:47 UTC
@Chrono79 I chnaged that,now passing one out of 5.
abraham anak agung
@padunk
Jun 25 2017 03:47 UTC
@ddanielnp yes
CallMeOrange
@EgnaroDev
Jun 25 2017 03:47 UTC
@Chrono79 So say... if someone followed it then how would they do it?
luccifer00
@luccifer00
Jun 25 2017 03:47 UTC
@padunk but the code is usefull anyway. isn't?? i am gonna go back and try only with that three methods.... but i dont know what to do with the spaces....
Diego Mayer
@Chrono79
Jun 25 2017 03:47 UTC
@jasonrest your check function is wrong, the array you need to filter is arr
so the argument of check is each element of arr, don't use args as the parameter name
return args.indexOf(val) === -1;
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 03:48 UTC
not working
var myCar = new Car();
  this.nickname = "asndl";
CallMeOrange
@EgnaroDev
Jun 25 2017 03:48 UTC
Never mind I got it
function phoneticLookup(val) {
  var result = "";

 result = {
  "alpha": "Adams",
  "bravo": "Boston",
  "charlie": "Chicago",
  "delta": "Denver",
  "echo": "Easy",
  "foxtrot": "Frank",
};
  return result[val];
}

// Change this value to test
phoneticLookup("charlie");
Looks better than old one
abraham anak agung
@padunk
Jun 25 2017 03:48 UTC
@mauriciodeleonc where is other key and value?
Daniel Lim
@ddanielnp
Jun 25 2017 03:48 UTC
@padunk but i i did previous questions on another computer, i think i doesnt save in the new computer ..?
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 03:49 UTC
var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 5;
};

// Only change code below this line.

var myCar = new Car();
  this.nickname = "asndl";
abraham anak agung
@padunk
Jun 25 2017 03:49 UTC
@ddanielnp click your avatar and scroll down
jasonrest
@jasonrest
Jun 25 2017 03:49 UTC
@Chrono79 ok the way i understood it is.... there is an array inside the arr.
destroyer([1, 2, 3, 1, 2, 3], 2, 3); so the 0 index is the array that we are searching for the 1 and 2 index.
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 03:49 UTC
thats what i have
Diego Mayer
@Chrono79
Jun 25 2017 03:49 UTC
@MCTwoDigitZero you could use lookup as the object's name and do result = lookup[val];
Then you could keep the code above and below the comments as it was
CallMeOrange
@EgnaroDev
Jun 25 2017 03:50 UTC
oh
So like
luccifer00
@luccifer00
Jun 25 2017 03:50 UTC
@padunk hahah, i just delete my filter and that work perfect! so i was breaking my head becouse an " " or " " thanks!
CamperBot
@camperbot
Jun 25 2017 03:50 UTC
luccifer00 sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:warning: luccifer00 already gave padunk points
CallMeOrange
@EgnaroDev
Jun 25 2017 03:51 UTC
result = lookup[val] {
...
};
Diego Mayer
@Chrono79
Jun 25 2017 03:51 UTC
no
CallMeOrange
@EgnaroDev
Jun 25 2017 03:51 UTC
lol @mauriciodeleonc
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 03:51 UTC
thats how i have it
and it worked
Diego Mayer
@Chrono79
Jun 25 2017 03:52 UTC
function phoneticLookup(val) {
  var result = "";

 var lookup = { ... };
 result = lookup[val];

  return result;
}

// Change this value to test
phoneticLookup("charlie");
CallMeOrange
@EgnaroDev
Jun 25 2017 03:52 UTC
@Chrono79 Can you tell me how? even if you told me, I wouldn't copy it :/, I only write my own code
Oh I see
Daniel Lim
@ddanielnp
Jun 25 2017 03:52 UTC
@padunk thanks
CamperBot
@camperbot
Jun 25 2017 03:52 UTC
ddanielnp sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 369 | @padunk |http://www.freecodecamp.com/padunk
CallMeOrange
@EgnaroDev
Jun 25 2017 03:52 UTC
@Chrono79 Dont you need variable for lookup?
lookup exist like keyword?
Never mind
Diego Mayer
@Chrono79
Jun 25 2017 03:53 UTC
:+1:
CallMeOrange
@EgnaroDev
Jun 25 2017 03:53 UTC
I was pretty sure you didnt have variable keyword...
Diego Mayer
@Chrono79
Jun 25 2017 03:53 UTC
I edited it
CallMeOrange
@EgnaroDev
Jun 25 2017 03:53 UTC
yea
Diego Mayer
@Chrono79
Jun 25 2017 03:54 UTC
But I was showing you that you can do it without touching the code outside the comments
CallMeOrange
@EgnaroDev
Jun 25 2017 03:54 UTC
Is it possible?
function phoneticLookup(val) {
  var result = "";

 result = { ... };
 result = result[val];

  return result;
}

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

function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  for (var i = 0; i < str.length; i++) {
    if (str.substr(str.length - 1) == target) {
      return true;
    } else return false;
  }
  return str;
}

confirmEnding("Bastian", "n");
```
Diego Mayer
@Chrono79
Jun 25 2017 03:54 UTC
@MCTwoDigitZero it'll work, but it's a little confusing
CallMeOrange
@EgnaroDev
Jun 25 2017 03:54 UTC
Yeah you are right
Ok I'll move on, thanks @Chrono79
CamperBot
@camperbot
Jun 25 2017 03:55 UTC
mctwodigitzero sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4411 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 25 2017 03:55 UTC
@ddanielnp you don't need a loop, you don't use i there anyway
Joseph
@revisualize
Jun 25 2017 03:55 UTC
@ddanielnp If something in JS isn't true. It's false.
@ddanielnp Your loop isn't looping.
michaelcmelton
@michaelcmelton
Jun 25 2017 03:55 UTC

I'm having trouble wrapping around how to go about the Chunky Monkey challenge... Here is my code so far:

function chunkArrayInGroups(arr, size) {
  // Break it up...
  var newArr = [];
  var lim = (arr.length/size);
  var place = 0;
  for (var i=0; i<lim; i++){
  newArr.push(arr.slice(place,size));
  place +=size+1;
}
  return newArr;
}


chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4);

And it returns [[0,1,2,3],[],[]]. Any suggestions would be appreciated.

Joseph
@revisualize
Jun 25 2017 03:55 UTC
@ddanielnp And as @Chrono79 stated you don't need a loop for that lesson
Daniel Lim
@ddanielnp
Jun 25 2017 03:56 UTC
ok
and after that

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

confirmEnding("Bastian", "n");
Joseph
@revisualize
Jun 25 2017 03:57 UTC
@ddanielnp your if condition isn't taking into account that all of the tests don't have a length of 1
Daniel Lim
@ddanielnp
Jun 25 2017 03:57 UTC
how did i make it so it compares the sentence in string
jasonrest
@jasonrest
Jun 25 2017 03:57 UTC
Help me. or I will hurt myself.
function destroyer(arr) {
    var args = Array.prototype.slice.call(arguments, 1);

    function check(arr){
      return arr[0].indexOf(args) === -1;
    }
      return arr.filter(check);
  }  
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 03:57 UTC
@jasonrest HAHAha
dude
jasonrest
@jasonrest
Jun 25 2017 03:58 UTC
@mauriciodeleonc times are desperate.
been stuck on this all day.
Joseph
@revisualize
Jun 25 2017 03:58 UTC
@jasonrest That lesson alone took me too many hours.
jasonrest
@jasonrest
Jun 25 2017 03:59 UTC
I swear im not looking for the answer. just a nudge in the right direction. this one is killing me.
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 03:59 UTC
:/ and here i am stuck at constructors
Jan Shah
@JanShah
Jun 25 2017 04:01 UTC
@michaelcmelton are you returning arrays with a size of 4?
abraham anak agung
@padunk
Jun 25 2017 04:01 UTC
@mauriciodeleonc it didn't work?
Maks Ushakov
@maks-ushakov
Jun 25 2017 04:01 UTC
@jasonrest the callback of filter get single item. So your check(arr) funcrion receive single
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 04:02 UTC
@padunk nope
Joseph
@revisualize
Jun 25 2017 04:03 UTC
OMG! I have a bottle of Martinelli's Sparkling Cider at my feet... The plastic top just shot off across the room.
abraham anak agung
@padunk
Jun 25 2017 04:03 UTC
@mauriciodeleonc how you add new data to object?
CallMeOrange
@EgnaroDev
Jun 25 2017 04:03 UTC
@revisualize Why is it at your feet?
abraham anak agung
@padunk
Jun 25 2017 04:04 UTC
@revisualize rainingg cider...
jasonrest
@jasonrest
Jun 25 2017 04:04 UTC
@maks-ushakov so do i have to use a loop? sorry im lost
Joseph
@revisualize
Jun 25 2017 04:04 UTC
Because I'm sitting on my couch getting ready to join my D&D game.
CallMeOrange
@EgnaroDev
Jun 25 2017 04:04 UTC
oh.. Thought you were standing
Would be weird if you did
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 04:05 UTC
var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 5;
};

// Only change code below this line.

var myCar = new Car();
  this.nickname = "asndl";
just writing "this."
Maks Ushakov
@maks-ushakov
Jun 25 2017 04:05 UTC
@jasonrest i suggest try to use args.indexOf(arrItem)
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 04:05 UTC
thats the way you add properties right?
Joseph
@revisualize
Jun 25 2017 04:05 UTC
@mauriciodeleonc No.
abraham anak agung
@padunk
Jun 25 2017 04:05 UTC
@mauriciodeleonc no you add it with your variable name
Joseph
@revisualize
Jun 25 2017 04:06 UTC
@mauriciodeleonc myCar._____
mauriciodeleonc
@mauriciodeleonc
Jun 25 2017 04:06 UTC
...
im gonna throw myself
bye
thanks @revisualize @padunk
CamperBot
@camperbot
Jun 25 2017 04:07 UTC
mauriciodeleonc sends brownie points to @revisualize and @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 370 | @padunk |http://www.freecodecamp.com/padunk
:star2: 4252 | @revisualize |http://www.freecodecamp.com/revisualize
jasonrest
@jasonrest
Jun 25 2017 04:07 UTC
@maks-ushakov I reversed it, but that doesnt seem right.
function destroyer(arr) {
    var args = Array.prototype.slice.call(arguments, 1);

    function check(arr){
      return args.indexOf(arr[0]) === -1;
    }
      return arr.filter(check);
  }  
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
and im still failing everything
Daniel Lim
@ddanielnp
Jun 25 2017 04:08 UTC
https://www.freecodecamp.com/challenges/confirm-the-ending i still cant get it..
function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
    if (str.substr(str.length - 1) == target) {
      return true;
    } else return false;
}
michaelcmelton
@michaelcmelton
Jun 25 2017 04:08 UTC
@CentropyIT I don't know...?
Jan Shah
@JanShah
Jun 25 2017 04:09 UTC
@michaelcmelton you're very close
Maks Ushakov
@maks-ushakov
Jun 25 2017 04:09 UTC
@jasonrest My suggestion
 function check(arrItem){
      return args.indexOf(arrItem) === -1;
    }
Jan Shah
@JanShah
Jun 25 2017 04:09 UTC
just a few minor things need looking at. let me have a look at the requirements
luccifer00
@luccifer00
Jun 25 2017 04:11 UTC
i am truck on factorialize a number...... i dont know if i should to use a for loop , to get all the numbers, or the while loop, or maybe its just using simple operators..... any advice??
Jan Shah
@JanShah
Jun 25 2017 04:12 UTC
@michaelcmelton array.slice is where your problem is. first time in the loop it goes from 0 to 4 (not 4,3..) and picks them, adding them to the array, the second time rount it goes from 4 to 4 and picks nothing up, it should be going from 4 to 8 and then 8 to 12 etc
there are other minor issues but this should solve part of your problem
abraham anak agung
@padunk
Jun 25 2017 04:12 UTC
@luccifer00 it is the same. you can get it with both
luccifer00
@luccifer00
Jun 25 2017 04:14 UTC
for or while, but not only with simple operators .... right?
Jan Shah
@JanShah
Jun 25 2017 04:15 UTC
@luccifer00 i think a recursive function works best for this problem
luccifer00
@luccifer00
Jun 25 2017 04:16 UTC
recursive function i didnt know it ...
jasonrest
@jasonrest
Jun 25 2017 04:17 UTC
@maks-ushakov working on it. :/
luccifer00
@luccifer00
Jun 25 2017 04:18 UTC
function factorialize(num) {

  for (var i = 0; i<= num.length; i--){

    return num[i]*num[i];
  } 
  return num;
}
i have this code, and ithing the loop iis bad configurated.... isn't?
becouse num.length is the number of characters that the number uses.... 9 use one char 50 uses two char.... etc
BlackTiger
@BlackTigerRoar
Jun 25 2017 04:21 UTC
@luccifer00 your loop is going to end with 0 every time.
Sandip Shrestha
@saninmersion
Jun 25 2017 04:21 UTC
@luccifer00 you start from i = 0 and do i-- so what will the value of i be
Jan Shah
@JanShah
Jun 25 2017 04:21 UTC
it was hard for me too, let me link some resources
Diego Mayer
@Chrono79
Jun 25 2017 04:22 UTC
@luccifer00 if num is a number, it hasn't a length property
BlackTiger
@BlackTigerRoar
Jun 25 2017 04:22 UTC
@luccifer00 sorry I meant it'll return num[0]*num[0] every time.
there's a java version
luccifer00
@luccifer00
Jun 25 2017 04:27 UTC
thanks @BlackTigerRoar i will go to thing about it a little bit .... @CentropyIT the link speaks in other language hahah, i would like to find my own version, thanks anyway!
CamperBot
@camperbot
Jun 25 2017 04:27 UTC
luccifer00 sends brownie points to @blacktigerroar and @centropyit :sparkles: :thumbsup: :sparkles:
:cookie: 259 | @blacktigerroar |http://www.freecodecamp.com/blacktigerroar
:cookie: 409 | @centropyit |http://www.freecodecamp.com/centropyit
Eric Hasegawa
@EricHasegawa
Jun 25 2017 04:31 UTC

function titleCase(str) {

var words = str.toLowerCase().split(" ");

  for ( i=0; i < words.length; i++ ) 

  {
     var words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1);
   }
     return words.join(" ");

  }



titleCase("I'm a little tea pot");
Could someone tell me what's wrong with this?
Greg Duncan
@GregatGit
Jun 25 2017 04:32 UTC
@EricHasegawa you have a ruturn statement in a for loop - won't get past it
Eric Hasegawa
@EricHasegawa
Jun 25 2017 04:32 UTC
@GregatGit Are you sure it's in the for loop? I don't understand how it is
Greg Duncan
@GregatGit
Jun 25 2017 04:33 UTC
@EricHasegawa sorry I realise you don't know - try to write the js in easy way to read it
Eric Hasegawa
@EricHasegawa
Jun 25 2017 04:33 UTC
@GregatGit What?
Greg Duncan
@GregatGit
Jun 25 2017 04:33 UTC
@EricHasegawa you are declaring words inside the loop
Eric Hasegawa
@EricHasegawa
Jun 25 2017 04:35 UTC
@GregatGit Oh I got it, why can't I declare words in the loop? Also why when I take the var keyword away from words[i] does it work?
NotTheBest
@NotTheBest
Jun 25 2017 04:36 UTC
Can someone please explain to me the challenge "Truncate a string"? I don't really understand what they are asking to do
Swagaholik
@Swagaholik
Jun 25 2017 04:36 UTC
does anyone know why my palindrome code isnt wokring?

function palindrome(str) {
// Good luck!
str = str.split("");

var backStr = str.reverse();
if (backStr === str) {
return true;
} else if (backStr !== str){
return false;
}

}

palindrome("not a palindrome");

it seems like it should work
but it doesn't
Greg Duncan
@GregatGit
Jun 25 2017 04:38 UTC
@Swagaholik you didn't join the backstring
Swagaholik
@Swagaholik
Jun 25 2017 04:38 UTC
what does that mean @GregatGit ?
Greg Duncan
@GregatGit
Jun 25 2017 04:39 UTC
@Swagaholik two array with the same contents don't equal each other
Swagaholik
@Swagaholik
Jun 25 2017 04:40 UTC
then how would they equal each other?
is it even possible?
luccifer00
@luccifer00
Jun 25 2017 04:40 UTC
@BlackTigerRoar @Chrono79 or factorial.... i dont have to create an array right?? or yes..... if i pass the num to an array, and operate with that, and after change to a string? is isnt a numers....
Greg Duncan
@GregatGit
Jun 25 2017 04:41 UTC
@Swagaholik you can compare two strings like that but not 2 arrays
Swagaholik
@Swagaholik
Jun 25 2017 04:42 UTC
oh ok, so you're saying i should join the two strings and THEN compare them
Greg Duncan
@GregatGit
Jun 25 2017 04:42 UTC
@Swagaholik yes
Swagaholik
@Swagaholik
Jun 25 2017 04:42 UTC
alright got it, thanks
BlackTiger
@BlackTigerRoar
Jun 25 2017 04:42 UTC
@luccifer00 I used recursive for the factorial question
@luccifer00 I didn't create any array.
Swagaholik
@Swagaholik
Jun 25 2017 04:43 UTC
almost forgot, i gotta send you some points
thanks @GregatGit
CamperBot
@camperbot
Jun 25 2017 04:43 UTC
swagaholik sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 870 | @gregatgit |http://www.freecodecamp.com/gregatgit
CallMeOrange
@EgnaroDev
Jun 25 2017 04:43 UTC
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  var result = myObj.hasOwnProperty(checkProp);
  if (result===true) {
    return myObj[checkProp];
  } else {
    return "Not Found";
  }
}

checkObj("gift");
Just wanted to show you my code..
Greg Duncan
@GregatGit
Jun 25 2017 04:44 UTC
@Swagaholik
var arr1 = [0,  1];
var arr2 = [0,  1];
var str1 = 'hello';
var str2 = 'hello'
str1 === str2 // true
arr1 === arr2 // false
Swagaholik
@Swagaholik
Jun 25 2017 04:45 UTC

function palindrome(str) {
// Good luck!
str = str.split("");

var backStr = str.reverse();
backStr = backStr.join("");
str = str.join("");

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

}

palindrome("not a palindrome");

here's the new code @GregatGit
still not working tho
Diego Mayer
@Chrono79
Jun 25 2017 04:47 UTC
@MCTwoDigitZero you can get rid of result, and use myObj.hasOwnProperty(checkProp) as your if condition driectly
Greg Duncan
@GregatGit
Jun 25 2017 04:47 UTC
@Swagaholik you don't use else if - just else with no condition
Diego Mayer
@Chrono79
Jun 25 2017 04:47 UTC
@luccifer00 why are you trying to use strings there?
Swagaholik
@Swagaholik
Jun 25 2017 04:48 UTC
still no cigar @GregatGit
luccifer00
@luccifer00
Jun 25 2017 04:48 UTC
@BlackTigerRoar but recursive is on the challenges ? i dont remember right now
Jan Shah
@JanShah
Jun 25 2017 04:49 UTC
@Swagaholik your backStr and str are returning the same value
Swagaholik
@Swagaholik
Jun 25 2017 04:49 UTC
why @CentropyIT ?
luccifer00
@luccifer00
Jun 25 2017 04:49 UTC
@Chrono79 i am not trying to use string heheh, i just got an crazy idea, but i discarr bymyself..... lol... i am just thinking on diferents ways to get it
Diego Mayer
@Chrono79
Jun 25 2017 04:49 UTC
@luccifer00 overthinking warning
Jan Shah
@JanShah
Jun 25 2017 04:50 UTC
@Swagaholik idk :) Idk :)
Diego Mayer
@Chrono79
Jun 25 2017 04:50 UTC
;)
Jan Shah
@JanShah
Jun 25 2017 04:50 UTC
I corrected it but I can't just send the solution as it's frowned upon
Greg Duncan
@GregatGit
Jun 25 2017 04:50 UTC
@Swagaholik try doing it without str = str.split(""); start with var backStr
Swagaholik
@Swagaholik
Jun 25 2017 04:51 UTC
alright @GregatGit
i get "TypeError: str.reverse is not a function"
Greg Duncan
@GregatGit
Jun 25 2017 04:53 UTC
@Swagaholik var backStr = str.split('')
Swagaholik
@Swagaholik
Jun 25 2017 04:54 UTC
YES!!!!
it solves that part
but i still didn't beat the challenge
Jan Shah
@JanShah
Jun 25 2017 04:55 UTC
@Swagaholik method chaining is useful, you can do something like str.split('').reverse().join('') to get the reversed string
Greg Duncan
@GregatGit
Jun 25 2017 04:55 UTC
@Swagaholik you need to use replace() and toLowerCase on str at the start
Jan Shah
@JanShah
Jun 25 2017 04:55 UTC
assign that to a new variable
Swagaholik
@Swagaholik
Jun 25 2017 04:55 UTC
yeah i do @GregatGit
thanks @CentropyIT @GregatGit
CamperBot
@camperbot
Jun 25 2017 04:55 UTC
swagaholik sends brownie points to @centropyit and @gregatgit :sparkles: :thumbsup: :sparkles:
:warning: swagaholik already gave gregatgit points
:cookie: 411 | @centropyit |http://www.freecodecamp.com/centropyit
Greg Duncan
@GregatGit
Jun 25 2017 04:55 UTC
@Swagaholik :+1:
CallMeOrange
@EgnaroDev
Jun 25 2017 04:57 UTC
hey is this right way to do it?

var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  },
  {
    "artist": "Fergie"
  }
];
No error but looks wrong to me..
Swagaholik
@Swagaholik
Jun 25 2017 04:57 UTC
you need a comma @MCTwoDigitZero
CallMeOrange
@EgnaroDev
Jun 25 2017 04:57 UTC
Where?
Joseph
@revisualize
Jun 25 2017 04:57 UTC
Where?
Swagaholik
@Swagaholik
Jun 25 2017 04:57 UTC
at the end of "Fergie"
Joseph
@revisualize
Jun 25 2017 04:57 UTC
No.
CallMeOrange
@EgnaroDev
Jun 25 2017 04:57 UTC
@Swagaholik Only if I need more objects
Joseph
@revisualize
Jun 25 2017 04:57 UTC
That's the last property.
Swagaholik
@Swagaholik
Jun 25 2017 04:57 UTC
unless if that's the end of the object
Jan Shah
@JanShah
Jun 25 2017 04:57 UTC
@MCTwoDigitZero it looks ok
CallMeOrange
@EgnaroDev
Jun 25 2017 04:57 UTC
Yeah it is :/
Joseph
@revisualize
Jun 25 2017 04:58 UTC
That object has only 1 property.
CallMeOrange
@EgnaroDev
Jun 25 2017 04:58 UTC
@Swagaholik Yeah Its true but I was just asking if its correct
So thanks guy I will just add more objects
Joseph
@revisualize
Jun 25 2017 04:58 UTC
@MCTwoDigitZero Add more properties.
CallMeOrange
@EgnaroDev
Jun 25 2017 04:58 UTC
by properties you mean objects?
Joseph
@revisualize
Jun 25 2017 04:59 UTC
@MCTwoDigitZero If I meant objects I would have said objects.
CallMeOrange
@EgnaroDev
Jun 25 2017 04:59 UTC
Never mind I know what is properties
Jan Shah
@JanShah
Jun 25 2017 04:59 UTC
@revisualize he's adding objects to an array
CallMeOrange
@EgnaroDev
Jun 25 2017 04:59 UTC
object: properties right?
Joseph
@revisualize
Jun 25 2017 04:59 UTC
Yes.
CallMeOrange
@EgnaroDev
Jun 25 2017 04:59 UTC
Yeah Im adding more properties then objects
Jan Shah
@JanShah
Jun 25 2017 04:59 UTC
using the same properties presumably
Joseph
@revisualize
Jun 25 2017 05:00 UTC
@MCTwoDigitZero You don't need more Objects!
Geez.
Just need 1 array with two objects as elements.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:00 UTC
@revisualize Really? then I just want to add more objects :/
ARJIT MOHAN
@arjitmohan
Jun 25 2017 05:01 UTC
var myStr ="You\n\Are\\Great";
Whats worng in this?
Joseph
@revisualize
Jun 25 2017 05:01 UTC
@MCTwoDigitZero Come on.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:01 UTC
Yeah instructions said you should have at least two elements
But I want to add objects, whats wrong with it...
Joseph
@revisualize
Jun 25 2017 05:01 UTC
@MCTwoDigitZero [ { ... } , { ... } ]
@MCTwoDigitZero That's an array with two elements each element is an object.
@MCTwoDigitZero You've done that.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:02 UTC
oh so I need at least 4 properties then
Joseph
@revisualize
Jun 25 2017 05:02 UTC
@MCTwoDigitZero Maybe. I just copied the object from the instructions.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:03 UTC
@revisualize lol thats what I did last time
Just a question...
If I wanted to add more properties to a object. like this?
object: ["property"]["property"]
Joseph
@revisualize
Jun 25 2017 05:05 UTC
@MCTwoDigitZero No.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:05 UTC
never mind, like this
object: [
property,
property,
...]
Joseph
@revisualize
Jun 25 2017 05:06 UTC
@MCTwoDigitZero That's only if you what the object property to be an array.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:07 UTC
oh
object: property, property, ....?
Nope that didnt work, I will just use an array instead
Joseph
@revisualize
Jun 25 2017 05:07 UTC
var myObj = {
     "key1":  "value1",
     "key2": "value2",
     "keyArr": ["element1" , "element2" , "element3" ],
     "lastKey": "lastValue"
}
CallMeOrange
@EgnaroDev
Jun 25 2017 05:08 UTC
Yeah
Joseph
@revisualize
Jun 25 2017 05:08 UTC
@MCTwoDigitZero Show your code.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:08 UTC
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  },
  {
    "artist": ["Fergie","apl.de.ap","Dante Santiago","will.i.am"]
  }
];
Joseph
@revisualize
Jun 25 2017 05:08 UTC
@MCTwoDigitZero That isn't correct.
You're making the 'artist' key an array
Look at the above object.
Mirror that.
It shouldn't be this challenging.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:09 UTC

var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  },
  {
    "artist": [
      "Fergie",
      "apl.de.ap",
      "Dante Santiago",
      "will.i.am"]
  }
];
Like this?
Joseph
@revisualize
Jun 25 2017 05:09 UTC
NO!
CallMeOrange
@EgnaroDev
Jun 25 2017 05:10 UTC
:trollface:
Jan Shah
@JanShah
Jun 25 2017 05:10 UTC
lol
CallMeOrange
@EgnaroDev
Jun 25 2017 05:10 UTC
Sorry, Am I supposed to remove array?
Jan Shah
@JanShah
Jun 25 2017 05:11 UTC
they look identical to me
Joseph
@revisualize
Jun 25 2017 05:11 UTC

var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here
  ,
  {
     "artist": "Daft Punk",
     "title": "Homework",
     "release_year": 1997,
     "formats": [ 
       "CD",
       "Cassette",
       "LP"
     ],
     "gold": true
  }
];
CallMeOrange
@EgnaroDev
Jun 25 2017 05:11 UTC
So?
Jan Shah
@JanShah
Jun 25 2017 05:12 UTC
looks alright
Joseph
@revisualize
Jun 25 2017 05:13 UTC
@MCTwoDigitZero
myMusic should be an array
myMusic should have at least two elements
myMusic[1] should be an object
myMusic[1] should have at least 4 properties
myMusic[1] should contain an artist property which is a string
myMusic[1] should contain a title property which is a string
myMusic[1] should contain a release_year property which is a number
myMusic[1] should contain a formats property which is an array
formats should be an array of strings with at least two elements
Did you read any of that?
CallMeOrange
@EgnaroDev
Jun 25 2017 05:14 UTC
Yeah
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  },
  {
    "artist": 
      "will.i.am",
    "title": "Black Eyed Pea",
    "release_year": 2005,
    "formats": ["Look it up", "Don't be lazy"]
  }
];
artist is supposed to be string not array so..
Joseph
@revisualize
Jun 25 2017 05:15 UTC
@MCTwoDigitZero Try putting everything in line.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:15 UTC
ok
Joseph
@revisualize
Jun 25 2017 05:15 UTC
"artist": "will.i.am",
CallMeOrange
@EgnaroDev
Jun 25 2017 05:15 UTC
Everything? both list?
{
    "artist": 
      "will.i.am", "title": "Black Eyed Pea", "release_year": 2005, "formats":["Look it up", "Don't be lazy"]
  }
Joseph
@revisualize
Jun 25 2017 05:15 UTC
OMG!
CallMeOrange
@EgnaroDev
Jun 25 2017 05:16 UTC
-_-
Joseph
@revisualize
Jun 25 2017 05:16 UTC
You're not trying to mirror the object above at all.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:16 UTC
I will just change it back.... What are you asking me to?
Joseph
@revisualize
Jun 25 2017 05:16 UTC
Are you trolling me? Am I being punked?
Someone recording this chat?
CallMeOrange
@EgnaroDev
Jun 25 2017 05:17 UTC
  {
    "artist": "will.i.am",
    "title": "Black Eyed Pea",
    "release_year": 2005,
    "formats":[
      "Look it up",
      "Don't be lazy"
    ]
  }
];
@revisualize No Im not trolling..
Better?
Joseph
@revisualize
Jun 25 2017 05:17 UTC
try running it.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:17 UTC
Yeah works well
Are you telling me to look at output?
Joseph
@revisualize
Jun 25 2017 05:18 UTC
No. I'm trying to figure out if you've solved and understand the challenge.
I don't give two shits about the output.
Do you understand what you're doing.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:18 UTC
I already solved it before but I just made it looks like above object
Yes
Joseph
@revisualize
Jun 25 2017 05:18 UTC
Omg.
revisualize @revisualize leaves.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:18 UTC
Dude what are you talking about?
I understand this challenge 100% clear..
EgnaroDev @MCTwoDigitZero leaves
Jan Shah
@JanShah
Jun 25 2017 05:19 UTC
that was fun..
CallMeOrange
@EgnaroDev
Jun 25 2017 05:20 UTC
I simply followed the instructions then try to understand how it works
Joseph
@revisualize
Jun 25 2017 05:20 UTC
I'm sitting here pulling up a challenge, redoing a challenge and trying to help someone solve a challenge that they've already solved.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:20 UTC
Why would I copy another objects then submit the challenge?
@revisualize I solved it before you told me to put everything in line...
Forget it, Im done
Joseph
@revisualize
Jun 25 2017 05:21 UTC
I didn't think that solved it.
Jan Shah
@JanShah
Jun 25 2017 05:21 UTC
should I get the popcorn?
CallMeOrange
@EgnaroDev
Jun 25 2017 05:21 UTC
@CentropyIT Too late
Joseph
@revisualize
Jun 25 2017 05:21 UTC
I'm going back to my D&D game.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:22 UTC
@revisualize Sorry, we chill? :/
Jan Shah
@JanShah
Jun 25 2017 05:22 UTC
not played games in months :(
CallMeOrange
@EgnaroDev
Jun 25 2017 05:22 UTC
@CentropyIT same
@CentropyIT last time I did this, I was like "BS this" copied another objects then submitted challenge then move on..
No point in talking about it lol
Jan Shah
@JanShah
Jun 25 2017 05:25 UTC
@MCTwoDigitZero I'm still learning, last two projects before I move to the third stage but still feel like I'm 2% in
I'm happy with what I know but I also know there's a steep learning curve as you progress. this kind of stuff is actually quite basic as you move on
where I'm stuck now is procedural dungeon generation, that's a hard one so I've taken a break from that to do charts.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:28 UTC
Whats that?
Front end projects? I never heard of it
Jan Shah
@JanShah
Jun 25 2017 05:29 UTC
Data Visualisation projects
CallMeOrange
@EgnaroDev
Jun 25 2017 05:29 UTC
ah
Jan Shah
@JanShah
Jun 25 2017 05:29 UTC
and react projects. I'm on last of each and they're hard
CallMeOrange
@EgnaroDev
Jun 25 2017 05:30 UTC
I actually did Intermediate front end projects from last account
But Im redoing everything
physicalgorithm
@physicalgorithm
Jun 25 2017 05:30 UTC
What's the difference between "let" and "var"?
Jan Shah
@JanShah
Jun 25 2017 05:30 UTC
I have redone bits but the real satisfying challenges are the big ones
CallMeOrange
@EgnaroDev
Jun 25 2017 05:31 UTC
var means variable
let dunno..
Jan Shah
@JanShah
Jun 25 2017 05:32 UTC
the differences are in scope and closure
CallMeOrange
@EgnaroDev
Jun 25 2017 05:32 UTC
@CentropyIT your game of life looks amazing
physicalgorithm
@physicalgorithm
Jun 25 2017 05:32 UTC
@CentropyIT thanks
CamperBot
@camperbot
Jun 25 2017 05:32 UTC
physicalgorithm sends brownie points to @centropyit :sparkles: :thumbsup: :sparkles:
:cookie: 412 | @centropyit |http://www.freecodecamp.com/centropyit
Jan Shah
@JanShah
Jun 25 2017 05:32 UTC
thanks man, I put a lot of hours into that
CallMeOrange
@EgnaroDev
Jun 25 2017 05:32 UTC
Yeah a lot of JS code
Jan Shah
@JanShah
Jun 25 2017 05:32 UTC
gotta impress the peeps
CallMeOrange
@EgnaroDev
Jun 25 2017 05:32 UTC
Lucky, I didnt data vis before front end
:D
about @MathematicsCoding
CamperBot
@camperbot
Jun 25 2017 05:33 UTC
:cookie: 345 | @mathematicscoding |http://www.freecodecamp.com/mathematicscoding
CallMeOrange
@EgnaroDev
Jun 25 2017 05:35 UTC
@CentropyIT Have you tried Back End?
Jan Shah
@JanShah
Jun 25 2017 05:36 UTC
@MCTwoDigitZero I'm confident I'll fly through that, i've done quite a bit of database, rest api, stuff like that for work
heidisdad2
@heidisdad2
Jun 25 2017 05:36 UTC
oh man,, i am so close ```
function rot13(str) { // LBH QVQ VG!
 var split = str.split('');
  for(var i=0; i<str.length; i++){ 
 if(split[i]-65<0 || split[i]-65>26){
    split[i] = str.charCodeAt(i);
 }else if (split[i]-65<13){
   split[i] = str.charCodeAt(i)+13;
 }else {
   split[i] = str.charCodeAt(i)+13-26;
 }

 split[i] = String.fromCharCode(split[i]);

}return split.join('');
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
I am so close, must be something wrong with my if else statements but not sure what.
seems correct to me
Jan Shah
@JanShah
Jun 25 2017 05:38 UTC
@heidisdad2 you should log the input and output to see what you're getting
heidisdad2
@heidisdad2
Jun 25 2017 05:38 UTC
the last else statement isn't returning correctly
CallMeOrange
@EgnaroDev
Jun 25 2017 05:39 UTC
@heidisdad2 what is the name of that challenge?
heidisdad2
@heidisdad2
Jun 25 2017 05:40 UTC
ceasars cypher
CallMeOrange
@EgnaroDev
Jun 25 2017 05:40 UTC
Damn I will do it after JS section
heidisdad2
@heidisdad2
Jun 25 2017 05:40 UTC
@CentropyIT i know you taught me how to do the console.log, but i am not sure how to do it on this one
nathccc
@nathccc
Jun 25 2017 05:41 UTC
Hi all, I have encountered problem in "profile lookup". can I get help here? :(
I can't get the results "No such contact" correctly shown and I wonder if my else if statement went wrong. I test hiding out the "No such contact" (else if statement) and some results turns out. Please help, thanks! :)
function lookUpProfile(firstName, prop){
// Only change code below this line

  var i = 0;
  var results = "";
  while (i < contacts.length) {

    if (firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop) === true) {
      results = contacts[i][prop];
    }  

    else if (firstName !== contacts[i].firstName) {
      results = "No such contact";
    }

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

    i++;
  }

  return results;
Jan Shah
@JanShah
Jun 25 2017 05:42 UTC
@heidisdad2 the problem starts right at the beginning
Eunice Park
@eunicode
Jun 25 2017 05:42 UTC
I need some help with syntax. Can anyone spot the difference between the two sets of code? The first code works, but the second code doesn't. It's the Title Case a Sentence challenge: https://www.freecodecamp.com/challenges/title-case-a-sentence
function titleCase(str) {

var apple = str.toLowerCase();
var banana = apple.split(" ");

var cherry = banana.map(function(element) {
  return (element.charAt(0).toUpperCase() + element.slice(1));
});

return cherry.join(" ");                     

}

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

  var apple = str.toLowerCase();
  var banana = apple.split(" ");

  var cherry = banana.map(function(element) {
    return (element.charAt(0).toUpperCase + element.slice(1));
  });

  return cherry.join(" ");   

}

titleCase("I'm a little tea pot");
Jan Shah
@JanShah
Jun 25 2017 05:42 UTC
split[i]-65<0 || split[i]-65>26
split[i] is a letter not a number
@heidisdad2
just after the start of the loop, add this to see output for the for loop
console.log(i,split[i])
BlackTiger
@BlackTigerRoar
Jun 25 2017 05:44 UTC
@eunipa return (element.charAt(0).toUpperCase + element.slice(1));
@eunipa toUpperCase() , second one forgot the ()
Eunice Park
@eunicode
Jun 25 2017 05:44 UTC
@BlackTigerRoar Thank you very much!!!
CamperBot
@camperbot
Jun 25 2017 05:44 UTC
eunipa sends brownie points to @blacktigerroar :sparkles: :thumbsup: :sparkles:
:cookie: 261 | @blacktigerroar |http://www.freecodecamp.com/blacktigerroar
nathccc
@nathccc
Jun 25 2017 05:46 UTC
Hi all, I have encountered problem in "profile lookup". can I get help here? :(
I can't get the results "No such contact" correctly shown and I wonder if my else if statement went wrong. I test hiding out the "No such contact" (else if statement) and some results turns out. Please help, thanks! :)
function lookUpProfile(firstName, prop){
// Only change code below this line

  var i = 0;
  var results = "";
  while (i < contacts.length) {

    if (firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop) === true) {
      results = contacts[i][prop];
    }  

    else if (firstName !== contacts[i].firstName) {
      results = "No such contact";
    }

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

    i++;
  }

  return results;
heidisdad2
@heidisdad2
Jun 25 2017 05:46 UTC
@CentropyIT after the closing }
?
BlackTiger
@BlackTigerRoar
Jun 25 2017 05:46 UTC
@ @nathccc if this two statement are true, then it'll return the last one. else if (firstName !== contacts[i].firstName) {
results = "No such contact";
}
else if (contacts[i].hasOwnProperty(prop) === false) {
  results = "No such property";
}   
    else if (firstName !== contacts[i].firstName) {
      results = "No such contact";
    }

    else if (contacts[i].hasOwnProperty(prop) === false) {
      results = "No such property";
    }
Jan Shah
@JanShah
Jun 25 2017 05:47 UTC
@heidisdad2 just after the opening for loop
 for(var i=0; i<str.length; i++){ 
        console.log(i,split[i])
BlackTiger
@BlackTigerRoar
Jun 25 2017 05:47 UTC
@nathccc You probably over write your results value.
Jan Shah
@JanShah
Jun 25 2017 05:48 UTC
it's just after that you are evaluating them, but the eval is wrong, because you're comparing letters to numbers
heidisdad2
@heidisdad2
Jun 25 2017 05:50 UTC
@CentropyIT oh my gosh you are a genius, i added the code to change to a number```
split[i] = str.charCodeAt(i);
and it worked
CallMeOrange
@EgnaroDev
Jun 25 2017 05:51 UTC
@heidisdad2 its obviously
@CentropyIT is a bot
nathccc
@nathccc
Jun 25 2017 05:51 UTC
@BlackTigerRoar any hint of the correct form / order for the IF ELSE statement? I have tried for hours but still can't get the results. frustrated :(
heidisdad2
@heidisdad2
Jun 25 2017 05:52 UTC
@CentropyIT so i can put console.log anywhere in my code and test things
i can test any variable anywhere?
CallMeOrange
@EgnaroDev
Jun 25 2017 05:53 UTC
depends on what kind of scopes..
console.log in a for loop for example
I think it might stop for loop so you would have to put console.log outside
Jan Shah
@JanShah
Jun 25 2017 05:54 UTC
@heidisdad2 you can use it anywhere
heidisdad2
@heidisdad2
Jun 25 2017 05:55 UTC
@MCTwoDigitZero who is a bot?
BlackTiger
@BlackTigerRoar
Jun 25 2017 05:55 UTC
@nathccc Loop through if firstName == contacts[i].firstName is true, then check if contacts[i] hasOwnProperty(prop), if true, return the contacts with its prop. If not, return "No such property". If loop did not find any firstname == contacts[i].firstname, then return "No such contact"
Jan Shah
@JanShah
Jun 25 2017 05:56 UTC
@MCTwoDigitZero what?
I'm a bot?? !
CallMeOrange
@EgnaroDev
Jun 25 2017 05:56 UTC
@CentropyIT yeah??!
Jan Shah
@JanShah
Jun 25 2017 05:56 UTC
I was getting a cup of electronic tea
heidisdad2
@heidisdad2
Jun 25 2017 05:56 UTC
lol
CallMeOrange
@EgnaroDev
Jun 25 2017 05:56 UTC
You are just like @camperbot
But you are better
You are not on all time because you have to charge your body but its all right
Jan Shah
@JanShah
Jun 25 2017 05:57 UTC
it's 4:20
BlackTiger
@BlackTigerRoar
Jun 25 2017 05:57 UTC
@nathccc Try not to compare firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop) at the same time.
CallMeOrange
@EgnaroDev
Jun 25 2017 05:57 UTC
@CentropyIT lmao
Are you in east?
heidisdad2
@heidisdad2
Jun 25 2017 05:58 UTC
its 4:20? ok brb then
Jan Shah
@JanShah
Jun 25 2017 05:58 UTC
in the west, uk :)
Ryan Nelson
@iamryandnelson
Jun 25 2017 05:58 UTC
I'm trying to get my Simon game to stop when I turn it off, even if it's in the middle of sounding out the current counts. Can anyone help?
https://codepen.io/iamryandnelson/pen/BZWrmq?editors=0010
Jan Shah
@JanShah
Jun 25 2017 05:58 UTC
@iamryandnelson do you use setTimeout or setInterval?
CallMeOrange
@EgnaroDev
Jun 25 2017 05:59 UTC

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

var gloveBoxContents = myStorage.car.inside["glove box"];
Jan Shah
@JanShah
Jun 25 2017 05:59 UTC
either of them
CallMeOrange
@EgnaroDev
Jun 25 2017 05:59 UTC
Seriously.. Its was so fucking obviously
Jan Shah
@JanShah
Jun 25 2017 05:59 UTC
that
I'm from the UK?
CallMeOrange
@EgnaroDev
Jun 25 2017 05:59 UTC
I was confused whole time because its keep telling me that gloveBoxContents is not defined but I just had to add that bracket notation
Ryan Nelson
@iamryandnelson
Jun 25 2017 06:00 UTC
@CentropyIT I do. I tried setTimeout(), but it didn't work. I'm assuming setTimeout() is still the answer? Can you show me how to use it correctly?
CallMeOrange
@EgnaroDev
Jun 25 2017 06:00 UTC
This is first time I cussed
Jan Shah
@JanShah
Jun 25 2017 06:01 UTC
@iamryandnelson the timers all need to be cancelled when you want to switch off. I implemented a solution on my version. What I did, was use window.setTimout, so that I could later find the timers, loop through and cancel them all
CallMeOrange
@EgnaroDev
Jun 25 2017 06:01 UTC
@CentropyIT in UK, time is 7am
so 4:20 was a joke..
jasonrest
@jasonrest
Jun 25 2017 06:02 UTC
any idea why I would be getting an error on the var sortedArray line saying I am missing a semi colon?

function getIndexToIns(arr, num) {

  var sortedArray = arr.sort(function(a, b){return a-b});

  return sortedArray;
}

getIndexToIns([40, 60], 50);
Jan Shah
@JanShah
Jun 25 2017 06:02 UTC
@MCTwoDigitZero I was serious about 4:20, it's 'about that time', not that time exactly :)
CallMeOrange
@EgnaroDev
Jun 25 2017 06:03 UTC
lmao
Then you would have to wait for 9 hours
and around 20 minutes
SaiChand Duppala
@saichandd
Jun 25 2017 06:04 UTC
@iamryandnelson did you use clearInterval() or clearTimeout()
Ahmed Abd El Hameed
@ajvhallen
Jun 25 2017 06:05 UTC

what make this myStr is undefined ?

var myStr; "I am a \"double quoted\" string inside \"double quotes\".";

SaiChand Duppala
@saichandd
Jun 25 2017 06:05 UTC
@jasonrest semicolon after return a--b
BlackTiger
@BlackTigerRoar
Jun 25 2017 06:06 UTC
@jasonrest well, because you are missing a semi colon :)
Jan Shah
@JanShah
Jun 25 2017 06:06 UTC
@iamryandnelson
window.ttime = setTimeout(function() {...})

 var d = window.ttime; 
  for (var j=(d-d);j<(d+1);j++) {
    window.clearTimeout(j);
  }
BlackTiger
@BlackTigerRoar
Jun 25 2017 06:06 UTC
@jasonrest saichand answered.
jasonrest
@jasonrest
Jun 25 2017 06:06 UTC
@imRadioactive Thanks
CamperBot
@camperbot
Jun 25 2017 06:06 UTC
jasonrest sends brownie points to @imradioactive :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @imradioactive |http://www.freecodecamp.com/imradioactive
CallMeOrange
@EgnaroDev
Jun 25 2017 06:07 UTC
I think it will take me at least a week to reach 400 brownie points
nathccc
@nathccc
Jun 25 2017 06:07 UTC

@BlackTigerRoar

Hi, is that what you meant for the sequence?

  while (i < contacts.length) {

    if (firstName !== contacts[i].firstName) {
      results = "No such contact";
    }

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

    else if (firstName === contacts[i].firstName) {
      results = contacts[i][prop];
    }

    i++;
  }
check for the contact, then property and then return if firstName correct?
it somehow just return the index [3] of the array AND the "no such contact" result
CallMeOrange
@EgnaroDev
Jun 25 2017 06:09 UTC
ok I'm done with objects and stuff
Going to work on a for loop tomorrow
Anime to :runner:
Ryan Nelson
@iamryandnelson
Jun 25 2017 06:10 UTC
@CentropyIT So if I include this in my code (line 89):
var d = window.ttime;
for (var j=(d-d);j<(d+1);j++) {
window.clearTimeout(j);
}
and this "window.ttime =" in front of every setTimeout, it'll work?
heidisdad2
@heidisdad2
Jun 25 2017 06:10 UTC
scratchjs is awesome
BlackTiger
@BlackTigerRoar
Jun 25 2017 06:10 UTC
@nathccc nested If statement. like below:
  while (i < contacts.length ){
      if (firstName == contacts[i].firstName){
        if (contacts[i].hasOwnProperty(prop)){
          return contacts[i][prop];
        }
        else
          return "No such property";
      }
    i++;
  }

  return "No such contact";
Jan Shah
@JanShah
Jun 25 2017 06:11 UTC
@iamryandnelson I don't know about that mate, you'll need to play about with it. it might suit your needs but I haven't taken a long look at your code.
MRLSU
@MRLSU
Jun 25 2017 06:12 UTC
javascript is hard bros
and ladies
Jan Shah
@JanShah
Jun 25 2017 06:12 UTC
one other problem I did have was the setTimeout firing every time I pressed a button, even when it was in the middle of a sequence
nathccc
@nathccc
Jun 25 2017 06:12 UTC
@BlackTigerRoar I see. thanks :)
CamperBot
@camperbot
Jun 25 2017 06:12 UTC
nathccc sends brownie points to @blacktigerroar :sparkles: :thumbsup: :sparkles:
:cookie: 263 | @blacktigerroar |http://www.freecodecamp.com/blacktigerroar
Ryan Nelson
@iamryandnelson
Jun 25 2017 06:13 UTC
@CentropyIT Okay, I'll keep playing with it. Thanks for the help 😊👍🏼👍🏼👍🏼
CamperBot
@camperbot
Jun 25 2017 06:13 UTC
iamryandnelson sends brownie points to @centropyit :sparkles: :thumbsup: :sparkles:
:cookie: 413 | @centropyit |http://www.freecodecamp.com/centropyit
Jan Shah
@JanShah
Jun 25 2017 06:13 UTC
so I set another timeout that set a div to a higher z-index while a timeout was running. it's actually quite complicated to describe but all my code is commented
nathccc
@nathccc
Jun 25 2017 06:13 UTC
but i am just wondering why the "&&" wont work in this case?
BlackTiger
@BlackTigerRoar
Jun 25 2017 06:13 UTC
@nathccc You are welcome. Don't need to check if hasOwnProperty is false because if it's true, then we return contacts[i][prop]; else return "No such property"
zzy
@zzyoungy
Jun 25 2017 06:15 UTC
按照下面的顺序,并且用空格来分割:
反斜杠 制表符 退格符 回车符 换行符 并把它赋值给变量 myStr
这个怎么做
BlackTiger
@BlackTigerRoar
Jun 25 2017 06:17 UTC
@zzyoungy 你現在的程式碼貼出來看看
nathccc
@nathccc
Jun 25 2017 06:18 UTC
@BlackTigerRoar Thanks. I believed I considered it in the other way round :P
CamperBot
@camperbot
Jun 25 2017 06:18 UTC
nathccc sends brownie points to @blacktigerroar :sparkles: :thumbsup: :sparkles:
:warning: nathccc already gave blacktigerroar points
BlackTiger
@BlackTigerRoar
Jun 25 2017 06:19 UTC
@nathccc Try to adopt the concept and then do it your way , it maybe fun too. :D
jasonrest
@jasonrest
Jun 25 2017 06:22 UTC
any idea what im doing wrong here? im also getting an error. result used out of scope. but im thinking that putting the return inside the loop would stop the loop......right?
function getIndexToIns(arr, num) {
3

4

5
  //sort the arr
6
  var sortedArray = arr.sort(function(a, b){return a-b;});
7

8
  //run loop through arr items to see if "num" is more than current [i]  
9
    for (i = 0; i < arr.length; i++){
10
      if (num > i){  
11

12
  //store the new position of the num
13
        var result = sortedArray[i];
14
      }
15
    } return result;
16
}
1718
getIndexToIns([40, 60], 50);
19
BlackTiger
@BlackTigerRoar
Jun 25 2017 06:31 UTC
@jasonrest what problem is that?
Alan Alickovic
@alan2207
Jun 25 2017 06:31 UTC
@jasonrest Which algorithm challenge is it? What is the task of this function?
MRLSU
@MRLSU
Jun 25 2017 06:40 UTC
Define a variable a with var and initialize it to a value of 9.
does that mean var a = 9;?
Alan Alickovic
@alan2207
Jun 25 2017 06:41 UTC
@MRLSU yes
BlackTiger
@BlackTigerRoar
Jun 25 2017 06:41 UTC
@MRLSU Sounds right to me.
Bindu
@appygal
Jun 25 2017 06:41 UTC
@MRLSU yes. correct.
adecyber
@adecyber
Jun 25 2017 06:42 UTC
for stand in line in javascript I do not know what to do for line 15. can anyone explain what is wanted?
Stand in Line is the assignment name and I'm confused by the console log statements

function nextInLine(arr, item) {
// Your code here
arr.push(item);
var x = arr.shift();
arr.shift();
return x;
}

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

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

Christopher Blakely
@chrisbchrist
Jun 25 2017 06:45 UTC
@jasonrest You declared result within the for loop so it can't be used outside it
Jonathan Wang
@jonathanwangg
Jun 25 2017 06:45 UTC
Hey can anyone help explain how Javascript converts a String data type into an Int data type?
Alan Alickovic
@alan2207
Jun 25 2017 06:46 UTC
@adecyber dp you know what shift method does?
Bindu
@appygal
Jun 25 2017 06:46 UTC
@adecyber you don't have to change anything in line 15. I mean its just for testing so you can test against the given value first, then if you want you can change the values of parameters and test against them.
Christopher Blakely
@chrisbchrist
Jun 25 2017 06:46 UTC
@jasonrest also you will need to deal with cases where the num is greater than all values in the array
Alan Alickovic
@alan2207
Jun 25 2017 06:51 UTC
@adecyber you should call shift only once
@adecyber ```
function nextInLine(arr, item) {
// Your code here
arr.push(item);
return arr.shift();;
}
@adecyber just remove arr.shift() before return statement, and you are good
Sonu kumar singh
@singhsonukumar6
Jun 25 2017 07:04 UTC
for(var i=0; i < arrString.length ; i++){
     var j = i+1;

    if(arrString[i].length < arrString[j].length){
      if(arrString[j].length>lenWord){
        lenWord = j ;
      }else{
        lenWord+=0;
      }

    }else {
      if(arrString[i].length>lenWord){
        lenWord = i ;
      }else{
        lenWord+=0;
      }
    }


  }
mithun
@dmithun
Jun 25 2017 07:04 UTC

function palindrome(str) {
// Good luck!
var x= str.replace(/\W/g, '').toLowerCase().split('').reverse().join('');
var y =x;
if (x==y){
return true;
}
else{
return false;
}

}

palindrome("eye");

Sonu kumar singh
@singhsonukumar6
Jun 25 2017 07:04 UTC
i am getting type error arrString[j] not defined
mithun
@dmithun
Jun 25 2017 07:04 UTC
man i'm stuck in this task :(
Sonu kumar singh
@singhsonukumar6
Jun 25 2017 07:04 UTC
what is the problem with the code
hi anyone here?
Sonu kumar singh
@singhsonukumar6
Jun 25 2017 07:12 UTC

function findLongestWord(str) {
  var arrString = str.split(" ");
  var lenWord = 0;
  var y = 0;
  for(var i=0; i < (arrString.length-1) ; i++){
     var j = i+1;

    if(arrString[i].length < arrString[j].length){
      if(arrString[j].length>lenWord){
        lenWord = j ;
      }else{
        lenWord+=0;
      }

    }else {
      if(arrString[i].length>lenWord){
        lenWord = i ;
      }else{
        lenWord+=0;
      }
    }


  }
  return arrString[lenWord].length ;


 // return str.length;
}

findLongestWord("What is the average airspeed velocity of an unladen swallow");
I passed all the cases Except 2 case.
findLongestWord("What is the average airspeed velocity of an unladen swallow") should return 8 but mine is returning 7
could any one tell me where is the problem
MRLSU
@MRLSU
Jun 25 2017 07:15 UTC
Anyone help me understand the "Convert Celsius to Fahrenheit" problem?
I have
var fahrenheit = (9/5)+32;
Im a little confused on this challenge all the other ones were really easy
am i suppose to use the above function
Baibhav Gautam
@baibhavx
Jun 25 2017 07:16 UTC
Guys can you please help me test my calculator. Please try to break it and let me know when it acts weird. % in my calculator is modulus and not percentage. :)
https://codepen.io/baibhavx/full/XgaYPZ/
Sonu kumar singh
@singhsonukumar6
Jun 25 2017 07:18 UTC
@MRLSU the formula is (9/5)*C+32
create a variable c @MRLSU
MRLSU
@MRLSU
Jun 25 2017 07:20 UTC
so var = c = celius?
celsius*
or var c = celcius i mean
james umali
@indefinite0212
Jun 25 2017 07:21 UTC
I don't think he needs to create a variable c, because Celsius is already defined
MRLSU
@MRLSU
Jun 25 2017 07:21 UTC
im pretty stumped on this one im trying different things tho
james umali
@indefinite0212
Jun 25 2017 07:22 UTC
@MRLSU just assigned the formula to your fahrenheit
The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
read that again
MRLSU
@MRLSU
Jun 25 2017 07:23 UTC
so it would be more like
fahrenheit = C * 9/5 +32
Bryan Büster
@BryanBuster
Jun 25 2017 07:23 UTC
@MRLSU You want to use the Celsius (input) and make a formula that uses the input and changes it to fahrenheit
yeah but I think in that assignment it;s just called Celsius
james umali
@indefinite0212
Jun 25 2017 07:24 UTC
@MRLSU not C but celsius
MRLSU
@MRLSU
Jun 25 2017 07:24 UTC
WAIT I GOT IT
fahrenheit = "-30" * 9/5+32;
Change the inputs below to test your code
convertToF(-22);
wait no i dont
Bryan Büster
@BryanBuster
Jun 25 2017 07:24 UTC
xD
MRLSU
@MRLSU
Jun 25 2017 07:24 UTC
damnit lol
Bryan Büster
@BryanBuster
Jun 25 2017 07:24 UTC
var fahrenheit is just the formulae
Jon
@jonandrepedersen
Jun 25 2017 07:24 UTC

Which way would you recommend to adding to properties to Javascript objects. I know both works, but I'm curious to what is best practice/easier.

myDog.bark = "bow-wow";
OR
ourDog["bark"] = "bow-wow";

Bryan Büster
@BryanBuster
Jun 25 2017 07:25 UTC
what you want to fill in is the ConverToF purple numbers
@MRLSU var fahrenheit is what you have to do to celsius to get fahrenheit, if that makes sense
MRLSU
@MRLSU
Jun 25 2017 07:25 UTC
i have the var fahrenheit part
its the formula that doesnt make any sense to me
how do I set a function for celsius
Bryan Büster
@BryanBuster
Jun 25 2017 07:26 UTC
you don;t have too
you want to go from celsius to fahrenheit why would you need a formula for celsius?
you just need a number of celsius
MRLSU
@MRLSU
Jun 25 2017 07:27 UTC
yeah but I need to return multiple values
If i change the value then the others become wrong
Bryan Büster
@BryanBuster
Jun 25 2017 07:27 UTC
if 1 works all work at codeCamp
Bryan Büster
@BryanBuster
Jun 25 2017 07:27 UTC
can you show me your code?
Joseph
@revisualize
Jun 25 2017 07:27 UTC
@MRLSU You're not using the parameter
MRLSU
@MRLSU
Jun 25 2017 07:28 UTC
function convertToF(celsius) {
var fahrenheit;
this parameter?
Joseph
@revisualize
Jun 25 2017 07:28 UTC
celsius
Bryan Büster
@BryanBuster
Jun 25 2017 07:28 UTC
yes you need to adjust that one
so it changes celsius to fahrenheit
Joseph
@revisualize
Jun 25 2017 07:28 UTC
@MRLSU Read what I linked.. It explains everything.
MRLSU
@MRLSU
Jun 25 2017 07:28 UTC
var fahrenheit =convertToF(celsius)*{9/5+32};
Bryan Büster
@BryanBuster
Jun 25 2017 07:29 UTC
what is with the {}?
Joseph
@revisualize
Jun 25 2017 07:29 UTC
@MRLSU No.
MRLSU
@MRLSU
Jun 25 2017 07:29 UTC
im so lost
lol
Joseph
@revisualize
Jun 25 2017 07:29 UTC
@MRLSU Did you read what I linked?
MRLSU
@MRLSU
Jun 25 2017 07:29 UTC
Ive read the instructions multiple times
Bryan Büster
@BryanBuster
Jun 25 2017 07:29 UTC
okay Celsius is the variable you want to change to fahrenheit
so not the entire function
Joseph
@revisualize
Jun 25 2017 07:29 UTC
@BryanBuster celsius is not a variable.
Bryan Büster
@BryanBuster
Jun 25 2017 07:29 UTC
I don;t know the name of it xD
Joseph
@revisualize
Jun 25 2017 07:30 UTC
parameter
Bryan Büster
@BryanBuster
Jun 25 2017 07:30 UTC