These are chat archives for FreeCodeCamp/HelpJavaScript

2nd
Aug 2016
silver537
@silver537
Aug 02 2016 00:00
@Robel612 create another switch or if statement. checking for count.
Norvin Burrus
@ndburrus
Aug 02 2016 00:00
@Robel612 handle answer (and output) outside the switch statement.
llamatarianism
@llamatarianism
Aug 02 2016 00:00
@Robel612 whether you return "bet" or "hold" doesn't depend on card
it depends on whether count is positive or negative
your function will returncount + " Bet" if 2 <= card < 6 and count + " Hold" otherwise
so it doesn't even check what count is.
llamatarianism
@llamatarianism
Aug 02 2016 00:03
tbh
KG
@KGraceNihon
Aug 02 2016 00:03
@revisualize The sad story of every graphic designer ever (the successful ones learn to say FU fast)
llamatarianism
@llamatarianism
Aug 02 2016 00:04
I couldn't give less of a crap about what the oatmeal thinks if he punched me in the stones
Joseph
@revisualize
Aug 02 2016 00:04
@llamatarianism OH, come on.. It's funny.
silver537
@silver537
Aug 02 2016 00:05
i didnt get it.... ._.
KG
@KGraceNihon
Aug 02 2016 00:05
@revisualize it's only not funny if you're still taking $exposure in exchange for your work =)
llamatarianism
@llamatarianism
Aug 02 2016 00:05
in a vacuum it's funny
knowing that it's matt inman
I can almost feel his salt
seeping out of every pixel
Joseph
@revisualize
Aug 02 2016 00:06
@KGraceNihon I've actually been offered work for the "exposure" as a web developer.
It does happen a lot.
Peter Weinberg
@no-stack-dub-sack
Aug 02 2016 00:06
@revisualize did you take it?
KG
@KGraceNihon
Aug 02 2016 00:06
@revisualize I know, that's why I said "the sad story of every graphic designer ever" (and web devs too, of course)
@no-stack-dub-sack The definition of "professional" is "says no when they ask you to lower your price/do it for the exposure"
silver537
@silver537
Aug 02 2016 00:07
oooooh now i get it.
fuck that. wheres the money at? lol
Peter Weinberg
@no-stack-dub-sack
Aug 02 2016 00:08
@KGraceNihon well he didn't say WHEN he was offered said work, could have been early in career
when "professional" might still have been a little more ambiguous
KG
@KGraceNihon
Aug 02 2016 00:08
@no-stack-dub-sack Agreed... I'm not judging! I did my first graphic work for "referrals" HAHAHAHAH ask me how that worked out.
but I'm a fast learner =)
silver537
@silver537
Aug 02 2016 00:09
@KGraceNihon the way you added the dollar sign looked like sexposure.
hahaaha
KG
@KGraceNihon
Aug 02 2016 00:10
@silver537 Yeah, I only saw that after I hit Enter
That's probably a different cartoon ...
John Alcher
@alchermd
Aug 02 2016 00:17

Hey fellas. Just a quick jQuery question:
How do I get the value of #test ?

<div id="div1">
    <div id="test">I should appear on div2</div>
</div>

<div id="div2">
  <div id="appendHere">Appended text:</div>
</div>
// This code doesn't work
....
$("#div2").click(function() {
  $("#appendHere").append(document.getElementById("test").text()); 
})
....

What's wrong with my work?

Robel Tesfaye
@Robel612
Aug 02 2016 00:17
@silver537 @ndburrus @llamatarianism Thanks guys! I did it!
CamperBot
@camperbot
Aug 02 2016 00:17
robel612 sends brownie points to @silver537 and @ndburrus and @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1283 | @ndburrus |http://www.freecodecamp.com/ndburrus
:star2: 1097 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
:warning: robel612 already gave silver537 points
Norvin Burrus
@ndburrus
Aug 02 2016 00:18
@Robel612 nice work! :palm_tree:
Santiago Gómez
@Sperkajugglite
Aug 02 2016 00:18
@alchermd .val() ?
John Alcher
@alchermd
Aug 02 2016 00:19
Hey. I tried it and it's still not working.
http://codepen.io/chermandu/pen/vKzGJa
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 00:20
You're missing a hashtag # when calling for id @alchermd
stonefmagiecurata
@stonefmagiecurata
Aug 02 2016 00:20
@alchermd js $("#appendHere").append($("#test").text());
@alchermd you're mixing js with jquery, there is no text() method in JS
John Alcher
@alchermd
Aug 02 2016 00:21
@stonefmagiecurata I am using jQuery :D
stonefmagiecurata
@stonefmagiecurata
Aug 02 2016 00:22
@alchermd document.getElementById("test") is not jquery, and text() is jquery, the 2 won't work combined
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 00:22
He's saying $('#test').text() would work but in vanilla javascript there is no document.getElementById('test').text()
Teresa Garriot
@garriottteresa
Aug 02 2016 00:23
@Robel612 good for you! I was getting help from your post. I am still trying.
John Alcher
@alchermd
Aug 02 2016 00:23
@stonefmagiecurata ohhhh Got it. I thought getId is jquery. Sooo, I guess assigning it to a variable and then using .text() on it should work..
Marc Droz
@b1tc0de
Aug 02 2016 00:24
needing some more help but not really for a answer but to help me understand something from challenge "Selecting from many options with Switch Statements"...let me paste it...
Jacob Stewart
@JacobStewart1
Aug 02 2016 00:24
Does someone want to pair for the weather website
Marc Droz
@b1tc0de
Aug 02 2016 00:25
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case  "alpha":
     // A Statement goes here i'm just not sure how (need help)
  }
....
i just need help with the statement part...i'm not sure what goes there
Moisés Man
@moigithub
Aug 02 2016 00:26
@b1td0wn how that function is called ?? what values are passed ?
John Alcher
@alchermd
Aug 02 2016 00:26
@stonefmagiecurata @Jlipschitz Hey guys I think I'm still not getting it. So I could get the whole <div>123</div> with doc.getId. How do I get the 123 part only?
Eric Boone
@eric-boone
Aug 02 2016 00:26
This message was deleted
stonefmagiecurata
@stonefmagiecurata
Aug 02 2016 00:26
@alchermd if you assing it using jQuery then yes, it will work
Tyler Brown
@pelicanscarecrow
Aug 02 2016 00:26

// Only change code below this line

var remainder; 11 % 3= 2;

why does that not work??
Norvin Burrus
@ndburrus
Aug 02 2016 00:27
@b1td0wn the cases (value1, etc) map to the numbers (1,2, etc) :sparkles:
stonefmagiecurata
@stonefmagiecurata
Aug 02 2016 00:27
@alchermd with vanilla JS or jquery?
John Alcher
@alchermd
Aug 02 2016 00:27
@stonefmagiecurata I assigned var x = doc.getId(idname) and tried x.text() and it gave me an error
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 00:27
@JacobStewart1 i'd be willing to pair program if you're still interested
Jacob Stewart
@JacobStewart1
Aug 02 2016 00:28
@Jlipschitz sure
John Alcher
@alchermd
Aug 02 2016 00:28
@stonefmagiecurata would you mind showing me how to do both jquery and plain js?
Moisés Man
@moigithub
Aug 02 2016 00:28
u need to ASSIGN the formula/math operation to remainder variable.. javascript will do the calculation for u @pelicanscarecrow
Norvin Burrus
@ndburrus
Aug 02 2016 00:28
@pelicanscarecrow
how does this "assignment" work? 11 % 3= 2; :sparkles:
Marc Droz
@b1tc0de
Aug 02 2016 00:29
ok... thanks for the tips @ndburrus @moigithub
CamperBot
@camperbot
Aug 02 2016 00:29
b1td0wn sends brownie points to @ndburrus and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1284 | @ndburrus |http://www.freecodecamp.com/ndburrus
:star2: 1789 | @moigithub |http://www.freecodecamp.com/moigithub
Norvin Burrus
@ndburrus
Aug 02 2016 00:29
@b1td0wn you're welcome! does it make sense?
...look at the usage examples: 17 % 2 = 1
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 00:29
@alchermd document.getElementById('div').value for vanilla and $('div').text() for that one. It works better if you use id= or class=
John Alcher
@alchermd
Aug 02 2016 00:32
@Jlipschitz I'm getting undefined with .value
@Jlipschitz here's my current code
http://codepen.io/chermandu/pen/vKzGJa
stonefmagiecurata
@stonefmagiecurata
Aug 02 2016 00:33
@alchermd html nodes don't have value poperty
@alchermd js $('#id').text();
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 00:34
hmm i was referencing http://www.w3schools.com/jsref/prop_text_value.asp never actually tried @stonefmagiecurata
stonefmagiecurata
@stonefmagiecurata
Aug 02 2016 00:34
@alchermd
document.getElementById('id').textContent;
John Alcher
@alchermd
Aug 02 2016 00:35
@stonefmagiecurata @Jlipschitz goddamnit I just had a brainfart. Why on earth was I using getElementById when I could just $(#idName).text() lmao I'm embarassed.
stonefmagiecurata
@stonefmagiecurata
Aug 02 2016 00:36
@alchermd or
document.getElementById('id').childNodes[0].nodeValue;
@Jlipschitz that's on input fields, retrieve or set input value
John Alcher
@alchermd
Aug 02 2016 00:38
http://imgur.com/a/XJOjV
All I want to do is get the value of Length and then append it to the blue circle when the circle is clicked. Anyway, sorry for the trouble on this trivial stuff lmao.
Thanks a bunch!
@Jlipschitz @stonefmagiecurata
CamperBot
@camperbot
Aug 02 2016 00:38
alchermd sends brownie points to @jlipschitz and @stonefmagiecurata :sparkles: :thumbsup: :sparkles:
:cookie: 281 | @stonefmagiecurata |http://www.freecodecamp.com/stonefmagiecurata
:cookie: 151 | @jlipschitz |http://www.freecodecamp.com/jlipschitz
comaeternal
@comaeternal
Aug 02 2016 00:39
Whats the short cut to copy past your code on here?
John Alcher
@alchermd
Aug 02 2016 00:39
@comaeternal like this?
my code
comaeternal
@comaeternal
Aug 02 2016 00:39
yes
stonefmagiecurata
@stonefmagiecurata
Aug 02 2016 00:42
@alchermd with jquery it's much shorter and easier
John Alcher
@alchermd
Aug 02 2016 00:42
@comaeternal press ` four times (it's located beside 1 on your keyboard) and then press Shift Enter. Then paste your code. Then press Shift enter again. Then press ` four times before pressing enter one last time
Lauren
@LaurenDoughty
Aug 02 2016 00:42
@comaeternal help format
help format
CamperBot
@camperbot
Aug 02 2016 00:42

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

comaeternal
@comaeternal
Aug 02 2016 00:43

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

fahrenheit *= (9 / 5) += 32;

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

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

John Alcher
@alchermd
Aug 02 2016 00:43
@stonefmagiecurata indeed! I got caught up on how to traverse from parent to children that I forgot that I can target stuff directly with $("#idName")
Norvin Burrus
@ndburrus
Aug 02 2016 00:43
@codebonobo :sparkles:
  • using Shift + enter will give you additional line feeds (space) for pasting your code. also, the backticks (`) key is located to the left of the number one (#1) key.
  • further, you may find the two buttons (chat/compose & markdown - the chat/compose button alternates modes) to the right of the text entry area helpful.
  • you can also edit text after it's been entered by clicking on the three (3) dots to the right of the text entry area (it will appear when you hover to the right of the time stamp).
John Alcher
@alchermd
Aug 02 2016 00:43
@comaeternal just add four more ` at the bottom and it's done!
Norvin Burrus
@ndburrus
Aug 02 2016 00:44
@comaeternal where is celsius? :sparkles: (in the code/equation)
here: fahrenheit *= (9 / 5) += 32;
this says:
fahrenheit = fahrenheit * (9 / 5) = (9/5) + 32; ?
comaeternal
@comaeternal
Aug 02 2016 00:44
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line


    fahrenheit *= (9 / 5) += 32;

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

// Change the inputs below to test your code
convertToF(20);
It should be something like celcius * (9/5) + 32 = Fahrenheit right? Not sure
John Alcher
@alchermd
Aug 02 2016 00:47
Thanks for the help guys! I'm off to school! Good day!
Norvin Burrus
@ndburrus
Aug 02 2016 00:47
@comaeternal
The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
we can rewrite the equation/formula to: Fahrenheit is (=) Celsius times( x ) 9/5, plus (+) 32.
which is F = C * 9/5 + 32,
or F = C(9/5) + 32.
alright, so we need to convert this formula to code!
comaeternal
@comaeternal
Aug 02 2016 00:48
got you. let me try to work it in
Jan Reimer
@najre
Aug 02 2016 00:49
so this is my code and the task i need to complet is You should be using the variable playerNumber in your bracket notation // Setup var testObj = { 12: "Namath", 16: "Montana", 19: "Unitas" }; // Only change code below this line; var playerNumber = 16; // "Montana var player = testObj[16]; console.log(playerNumber);// "Montana"
so this is my code and the task i need to complet is You should be using the variable playerNumber in your bracket notation
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};
// Only change code below this line;
var playerNumber = 16;       // "Montana
var player = testObj[16];   
console.log(playerNumber);// "Montana"
locks better
so what do i have to diffrent
stonefmagiecurata
@stonefmagiecurata
Aug 02 2016 00:52
@najre guess they want you to use the variable instead the number: var player = testObj[playerNumber], but I'm not sure
Jan Reimer
@najre
Aug 02 2016 00:52
@stonefmagiecurata i will give it a try
Tyler Brown
@pelicanscarecrow
Aug 02 2016 00:53

@ndburrus @moigithub
// Only change code below this line

var remainder; 11 % 3= 2;

this code does not set the remainder to 2, it also does not use the % operator.

stonefmagiecurata
@stonefmagiecurata
Aug 02 2016 00:54
@najre lol, now I see it, there it is in your pasted text: "You should be using the variable playerNumber in your bracket notation" :D
Jan Reimer
@najre
Aug 02 2016 00:54
@stonefmagiecurata thanks that works but was my old code wrong because it workt aswell
CamperBot
@camperbot
Aug 02 2016 00:54
najre sends brownie points to @stonefmagiecurata :sparkles: :thumbsup: :sparkles:
:cookie: 282 | @stonefmagiecurata |http://www.freecodecamp.com/stonefmagiecurata
stonefmagiecurata
@stonefmagiecurata
Aug 02 2016 00:54
@najre no it wasn't wrong, just not what they asked for :)
Jan Reimer
@najre
Aug 02 2016 00:55
hahah thanks you xD
Norvin Burrus
@ndburrus
Aug 02 2016 01:01
@pelicanscarecrow
we need to correct the assignment! :sparkles:
here: "11 % 3 = 2 ;"
hint: you're doing the math manually.... assign to variable.
which one? see test case:
"The variable remainder should be initialized"
Teresa Garriot
@garriottteresa
Aug 02 2016 01:02
~~~js
var count = 0;

function cc(card) {
  // Only change code below this line
  var call = " ";
  switch(card){
      case 2:
      case 3:
    case 4:
    case 5:
    case 6:
      count ++ ;
      break;
      case 7:
      case 8:
      case 9:
      count += 0;
      break;
      case 10:
      case "J":
      case "Q":
      case "K":
      case "A":
      count --;
      break;
  }
 if (count>=0){
   call= [count, + " HOLD"];
 }
  else  {
    call = [count, + " Bet"];
  }  

  return "call";
  // 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');

2 issues 
I can't seem to figure out the right  code or keystokes to put up the background for my code
I guess I have the keystokes for the back ground....now could someone help me with my code issue.
Norvin Burrus
@ndburrus
Aug 02 2016 01:06
@garriottteresa
check logic:
The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold"
if (count>=0){?
Robel Tesfaye
@Robel612
Aug 02 2016 01:06
@garriottteresa You do not need the brackets around your value when you are assigning a value to 'call'. And count += 0; is redundant.
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 01:06
how do you do multiline formatting again?
Stephen James
@sjames1958gm
Aug 02 2016 01:08
@Jlipschitz three backquotes - shift-enter - paste - shift-enter three backquotes return
Norvin Burrus
@ndburrus
Aug 02 2016 01:09
This message was deleted
CamperBot
@camperbot
Aug 02 2016 01:09
no wiki entry for: format
Teresa Garriot
@garriottteresa
Aug 02 2016 01:09
@ndburrus ooops ;-)
Norvin Burrus
@ndburrus
Aug 02 2016 01:09
@Jlipschitz :point_up: August 1, 2016 8:42 PM
  • using Shift + enter will give you additional line feeds (space) for pasting your code. also, the backticks (`) key is located to the left of the number one (#1) key.
  • further, you may find the two buttons (chat/compose & markdown - the chat/compose button alternates modes) to the right of the text entry area helpful.
  • you can also edit text after it's been entered by clicking on the three (3) dots to the right of the text entry area (it will appear when you hover to the right of the time stamp).
  • FreeCodeCamp/camperbotPlayground
  • CamperBot
  • Free Code Camp’s CamperBot
comaeternal
@comaeternal
Aug 02 2016 01:10
This message was deleted
Norvin Burrus
@ndburrus
Aug 02 2016 01:11
@pelicanscarecrow is it resolved?
comaeternal
@comaeternal
Aug 02 2016 01:12
This message was deleted
Norvin Burrus
@ndburrus
Aug 02 2016 01:13
@garriottteresa
just use a variable to assign the result values (Bet/Hold). then return the count + the variable.
@comaeternal how are we doing?
comaeternal
@comaeternal
Aug 02 2016 01:15
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line


   fahrenheit = celcius * (9 / 5) + 32;

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

// Change the inputs below to test your code
convertToF(30);
Tyler Brown
@pelicanscarecrow
Aug 02 2016 01:16
@ndburrus No I still have not figured it out.
comaeternal
@comaeternal
Aug 02 2016 01:16
Still not getting this. hmm.
Tyler Brown
@pelicanscarecrow
Aug 02 2016 01:16
What variable would I want to place to get the job done.
Norvin Burrus
@ndburrus
Aug 02 2016 01:17
@comaeternal :sparkles:
where did the code not to be changed go?
// Only change code above this line
  if ( typeof fahrenheit !== 'undefined' ) {
    return fahrenheit;
  } else {
    return 'fahrenheit not defined';
  }
}
Stephen James
@sjames1958gm
Aug 02 2016 01:18
@comaeternal Variable names have to be exact. Check yours
comaeternal
@comaeternal
Aug 02 2016 01:19
above return fahrenheit
Stephen James
@sjames1958gm
Aug 02 2016 01:19
@pelicanscarecrow Are you working on remainder?
comaeternal
@comaeternal
Aug 02 2016 01:20
This message was deleted
CamperBot
@camperbot
Aug 02 2016 01:20
comaeternal sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2265 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Norvin Burrus
@ndburrus
Aug 02 2016 01:20
@sjames1958gm yes, remainder...
..nice catch.
Joe P
@JP50515
Aug 02 2016 01:20
can someone help me with replacing if/else chains with a switch?
Stephen James
@sjames1958gm
Aug 02 2016 01:21
@comaeternal If you are using chrome then F12 will open the devtools console and you will see errors such as undefined variables.
comaeternal
@comaeternal
Aug 02 2016 01:21
@sjames1958gm and on a Mac?
Stephen James
@sjames1958gm
Aug 02 2016 01:22
@JP50515 If you have code to post then plenty her to help
@comaeternal :(
@comaeternal Wish I had a mac.
Cmd + Opt + J
Norvin Burrus
@ndburrus
Aug 02 2016 01:22
@JP50515 can you post your code? and what lesson name is it?
Stephen James
@sjames1958gm
Aug 02 2016 01:23
@JP50515 If you so three backquotes - shift-enter - paste - shift-enter three backquotes enter then it will show cleaner in chat
Joe P
@JP50515
Aug 02 2016 01:24
yup one sec
just accidentally deleted it all :(
figured it out. Thanks anyway!
Nicholas Vorraso
@nickeyvee
Aug 02 2016 01:28

I'm stuck on my last Js challenge "Escape sequences in strings"

var myStr = "First\tLine\n\"Second\tLine\"\rThird\tLine";  // Change this line

I get the error messages "myStr should have encoded text with the proper escape sequences and no spacing." & "myStr should have two correctly escaped backslash characters \"

Any thoughts?

Norvin Burrus
@ndburrus
Aug 02 2016 01:29
@JP50515 :+1:
@nickeyvee
ok, we need to take the given string, here:
"FirstLine newline backslash SecondLine backslash carriage-return ThirdLine" (ignore the spacing) and replace the appropriate text (bold words) with the escape coding (use the Code/Output chart)...
...the error is accurate - the backslash encoding/escaping is // & there are none in the code.
Kevin Mulligan
@kmulligan
Aug 02 2016 01:29
Anyone on here finished Exact Change?
llamatarianism
@llamatarianism
Aug 02 2016 01:30
@nickeyvee you've got quotes where you should have backslashes.
This message was deleted
actually you shouldn't have tabs in there at all.
@kmulligan si
Kevin Mulligan
@kmulligan
Aug 02 2016 01:32
@llamatarianism how many lines of code did it end up being
llamatarianism
@llamatarianism
Aug 02 2016 01:32
about 60
CamperBot
@camperbot
Aug 02 2016 01:32
you need to ask about @someone!
llamatarianism
@llamatarianism
Aug 02 2016 01:32
there were a few extra blank lines in there for readability purposes though
if you remove all of those it's about 50
Nicholas Vorraso
@nickeyvee
Aug 02 2016 01:33
@llamatarianism @ndburrus i got it, i could never understand the objective of this challenge for some reason.
Teresa Garriot
@garriottteresa
Aug 02 2016 01:33
thanks to @ndburrus @Robel612
CamperBot
@camperbot
Aug 02 2016 01:33
garriottteresa sends brownie points to @ndburrus and @robel612 :sparkles: :thumbsup: :sparkles:
:cookie: 201 | @robel612 |http://www.freecodecamp.com/robel612
:star2: 1286 | @ndburrus |http://www.freecodecamp.com/ndburrus
Kevin Mulligan
@kmulligan
Aug 02 2016 01:34
@llamatarianism argh mine is double that with a bunch of console logs for debugging purposes
Norvin Burrus
@ndburrus
Aug 02 2016 01:34
@nickeyvee way to go! nice job :palm_tree:
llamatarianism
@llamatarianism
Aug 02 2016 01:34
@kmulligan roughly speaking, how are you trying to tackle it?
3jM310
@3jM310
Aug 02 2016 01:35

guys what is missing here? function update(id, prop, value) {
if (value === '') {
delete collection[id][prop];
} else if (prop !== 'tracks') {
collection[id][prop] = value;
} else {
collection[id][prop].push(value);
}

return collection;
}

Kevin Mulligan
@kmulligan
Aug 02 2016 01:35
@llamatarianism first I did a switch to take my cid and figure out how many of each I had
Kevin Hechavarria
@tohx
Aug 02 2016 01:35

// Setup
var a;
var b = 2;

// Only change code below this line
var a;
var a = 7;
var b;
var b = 7;

can anyone help me with my code
Kevin Mulligan
@kmulligan
Aug 02 2016 01:35

so

for (var i = 0; i<cid.length; i++){
    switch(cid[i][0]){
      case "PENNY":
        numPen = (cid[i][1]*100);
        console.log(numPen);
        break;

etc.

@llamatarianism
then I added them all up so I knew total cash in drawer
addMeUp[i] = cid[i][1];
    totalCID = addMeUp.reduce(function(a,b){
        return a + b;
    });
    //need to round totalcid to hundredths 
    totalCID = Math.round(100*totalCID)/100;

    console.log("totalCID: " + totalCID);

    if (isNaN(totalCID)) {
        return "Error: cid is NaN!";
        //need to learn how to throw an error and stop the process if any part of CID isNaN.
    }
    console.log("Total cash in drawer: " +totalCID);
  }
Teresa Garriot
@garriottteresa
Aug 02 2016 01:37
@ndburrus in the counting cards task why does using an array for an answer not work? Why could I not use call =[count, +" Hold"]....return call? why would it only work with return count + call having call="Hold"?..
Kevin Mulligan
@kmulligan
Aug 02 2016 01:37
@llamatarianism figured out how much change was due, gave the appropriate message for the "closed" and "insufficient funds" problems
Norvin Burrus
@ndburrus
Aug 02 2016 01:37
@tohx i think that one wants an assignment of a to b?
TechDr
@TechDr
Aug 02 2016 01:37
i can't seem to figure out how to get the tracks to update
can someone help me figure this out
Kevin Hechavarria
@tohx
Aug 02 2016 01:37

ndburrus correct. however i cant seem to do it

TechDr
@TechDr
Aug 02 2016 01:38

function updateRecords(id, prop, value) {
if (prop === "artist" || prop === "album") {
if (value !== "") {
collection[id][prop] = value;
} else {
delete collection[id][prop];
}
} else if (prop === "tracks") {
if (value !== "" && typeof collection[id].tracks === 'undefined') {
collection[id][prop].push(value);
} else if (value === "") {
delete collection[id][prop];
}
} else if (collection[id].hasOwnProperty(prop) === false) {
delete collection[id][prop];
}

return collection;

}

Norvin Burrus
@ndburrus
Aug 02 2016 01:38
@garriottteresa i do not think this [count, +" Hold"] is a valid array. the operator would invalidate the structure.
the other method works because it is a valid operation - concatenation.
TechDr
@TechDr
Aug 02 2016 01:39
its for the Record Collection challenge in the Basic Javascript problem set
Kevin Mulligan
@kmulligan
Aug 02 2016 01:39
@llamatarianism ....and then it got complicated. Because I used 3 arrays and a for loop to figure out how much of each coin/bill to give in change, and then within that a loop did an if statement so that if how much change I needed to give > than the number of bills I had, to only give what I had and recalculate how much change was due
else if (changeDue < totalCID) {
      console.log("We owe change now figure it out");
      var currValues = [100, 20, 10, 5, 1, 0.25, 0.10, 0.05, 0.01];
      var currNames = ["ONE HUNDRED", "TWENTY", "TEN", "FIVE", "ONE", "QUARTER", "DIME", "NICKEL", "PENNY"];
      var currQuant = [numHund, numTwen, numTen, numFive, numOne, numQuart, numDime, numNick, numPen];
Nicholas Vorraso
@nickeyvee
Aug 02 2016 01:39
question
is "this" == global object?
Teresa Garriot
@garriottteresa
Aug 02 2016 01:40
now that you say that... DOH!
Peter Weinberg
@no-stack-dub-sack
Aug 02 2016 01:40
question: I know the advanced algos are not required for the cert, but do you guys think what you'd learn there is invaluable for tackling the advanced front end projects or do you think I could just move on to them?
Stephen James
@sjames1958gm
Aug 02 2016 01:40
@nickeyvee No, generally in the browser window is the global object. this can be the global object, but is not always
Jacob Stewart
@JacobStewart1
Aug 02 2016 01:41
hey im working on the weather project in codepen and my api is in http and only uses https does someone know how to like change the file to https or somethign
Stephen James
@sjames1958gm
Aug 02 2016 01:41
@no-stack-dub-sack I don't think they are essential
Tyler Brown
@pelicanscarecrow
Aug 02 2016 01:41
Yes I am working on remainder.
@sjames1958gm
Nicholas Vorraso
@nickeyvee
Aug 02 2016 01:41
@sjames1958gm ah ok that makes sense
Valentyn Bilousov
@bilousov94
Aug 02 2016 01:41
why this code is not working
for( var i = 0; i < contacts.length; i++ ){
if (contacts[i].firstName === firstName){
if (contacts[i].prop){
return contacts[i][prop];
}
else {
return "No such property";
}
}
else {
return "No such contact";
}
}
profile lookup
Stephen James
@sjames1958gm
Aug 02 2016 01:42
@pelicanscarecrow Where are you now.
Valentyn Bilousov
@bilousov94
Aug 02 2016 01:42
profile lookup
Nicholas Vorraso
@nickeyvee
Aug 02 2016 01:42
@ndburrus ty
CamperBot
@camperbot
Aug 02 2016 01:42
nickeyvee sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star2: 1287 | @ndburrus |http://www.freecodecamp.com/ndburrus
Valentyn Bilousov
@bilousov94
Aug 02 2016 01:42
217
Tyler Brown
@pelicanscarecrow
Aug 02 2016 01:42

// Only change code below this line

var remainder;

Peter Weinberg
@no-stack-dub-sack
Aug 02 2016 01:42
@sjames1958gm cool, thanks, I'm anxious to get developing again, but I at least wanted to complete the intermediate algos first otherwise I knew I would be distracted from getting them done by the actual projects
CamperBot
@camperbot
Aug 02 2016 01:42
no-stack-dub-sack sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2266 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Norvin Burrus
@ndburrus
Aug 02 2016 01:43
@nickeyvee you're welcome! :+1: nice job! :sparkles:
Peter Weinberg
@no-stack-dub-sack
Aug 02 2016 01:43
which are so much more fun
Tyler Brown
@pelicanscarecrow
Aug 02 2016 01:43
I have to set remainder equal to the remainder of 11 divided by 3 using the remainder(%) operator.
Peter Weinberg
@no-stack-dub-sack
Aug 02 2016 01:43
even though the problem solving of the algos is fun too
Stephen James
@sjames1958gm
Aug 02 2016 01:43
@no-stack-dub-sack It is a good break from algorithms to build something that you created and does stuff
Peter Weinberg
@no-stack-dub-sack
Aug 02 2016 01:44
@sjames1958gm agreed, more rewarding in the end.
Valentyn Bilousov
@bilousov94
Aug 02 2016 01:44
thank you
Stephen James
@sjames1958gm
Aug 02 2016 01:44
@pelicanscarecrow So if you had to set remainder equal to 5 how would you?
Peter Weinberg
@no-stack-dub-sack
Aug 02 2016 01:44
good curriculum overall though, breaks it up nicely
Norvin Burrus
@ndburrus
Aug 02 2016 01:44
This message was deleted
Stephen James
@sjames1958gm
Aug 02 2016 01:44
@pelicanscarecrow Where set equal means assign to.
TechDr
@TechDr
Aug 02 2016 01:45
so can anyone help?
Stephen James
@sjames1958gm
Aug 02 2016 01:45
@pelicanscarecrow Where assignment is done using the single =
Tyler Brown
@pelicanscarecrow
Aug 02 2016 01:45
I thought it would be var remainder; 11 % 3 = 2 ;
but I was very wrong.
Stephen James
@sjames1958gm
Aug 02 2016 01:46
@bilousov94 Do you really want to return no such contact when if the first firstname does not match? Hint, all code does not have to go inside the loop
Minamiya_Natsuki
@yukihiratype2
Aug 02 2016 01:46
Hava a problem with 144:Escape Sequences in Strings
Stephen James
@sjames1958gm
Aug 02 2016 01:46
@pelicanscarecrow In js that is trying to assign the value two to the expression 11 % 3 which is invalid, the left side of the = shouild be variable.
Minamiya_Natsuki
@yukihiratype2
Aug 02 2016 01:47
“\n\r\\\\” doesn’t work...
Stephen James
@sjames1958gm
Aug 02 2016 01:47
@pelicanscarecrow Generally you have variable = expression, read this as assign the result to evaluating expression to variable
Norvin Burrus
@ndburrus
Aug 02 2016 01:47
@yukihiratype2
ok, we need to take the given string, here:
"FirstLine newline backslash SecondLine backslash carriage-return ThirdLine" (ignore the spacing) and replace the appropriate text (bold words) with the escape coding (use the Code/Output chart)...
Stephen James
@sjames1958gm
Aug 02 2016 01:47
@yukihiratype2 You need to copy the string given and replace the keywords with the corresponding escape sequences removing all spaces.
@pelicanscarecrow In this case remainder is the variable and 11 % 3 is the expression.
Minamiya_Natsuki
@yukihiratype2
Aug 02 2016 01:49
thx
Dana Aljirudi
@DanaJirudi
Aug 02 2016 01:50
Hi guys, can anyone help me with the "Testing Objects for Properties" challenge? I tried to solve it but couldn't..
Aiden
@AidenMead
Aug 02 2016 01:50
Anyone handy with APIs and calling them that can help me figure out exactly how that works?
Stephen James
@sjames1958gm
Aug 02 2016 01:53
@DanaJirudi Make sure you are using [] to access the property since checkProp is a variable.
Dana Aljirudi
@DanaJirudi
Aug 02 2016 01:56
@sjames1958gm So I know I have to use an if statement but I'm struggling with what to put inside it :worried:
I mean the condition
Stephen James
@sjames1958gm
Aug 02 2016 01:57
@DanaJirudi To the left they give you a function that returns true or false. ifs love conditions that return true or false.
Dana Aljirudi
@DanaJirudi
Aug 02 2016 01:57
Yeah I see
Viknesh
@vk2mars
Aug 02 2016 01:58
can someone help me with steamroller? I don't understand why this isn't working:
function steamrollArray(arr) {
  // I'm a steamroller, baby
  var finarr = [];
  for (i = 0; i < arr.length; i++) {
    if (Array.isArray(arr[i])) {
      finarr.concat(steamrollArray(arr[i]));
    } else {
      finarr.push(arr[i]);
    }
  }
  return finarr;
}
Stephen James
@sjames1958gm
Aug 02 2016 01:58
@vk2mars What is it outputing vs. what it should output
@DanaJirudi if (object has the property)
Dana Aljirudi
@DanaJirudi
Aug 02 2016 01:59
@sjames1958gm Hmmm, am I supposed to use the .hasOwnProperty inside the condition
Stephen James
@sjames1958gm
Aug 02 2016 01:59
@DanaJirudi yes
Dana Aljirudi
@DanaJirudi
Aug 02 2016 01:59
I'll try it
Michael Bomholt
@bomholtm
Aug 02 2016 02:00
i finished my local weather project a while ago... today i was working on some minor tweaks then i noticed IP Geolocation isnt working as backup geolocation anymore... https://codepen.io/bomholt/full/zqgoOe normally it has HTML Geolocation and if that isnt available or blocked it uses IP Geolocation. why did it stopped working? looks like it doesnt even get any data
Viknesh
@vk2mars
Aug 02 2016 02:00
@sjames1958gm it's just crashing the FC site but doesn't do that in the Chrome Snippets console
*Free Code Camp = FCC
Tim
@x-yz
Aug 02 2016 02:01
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName == firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
why on earth doesnt that work?
Viknesh
@vk2mars
Aug 02 2016 02:02
@x-yz use markdown to make the code easier to read ```
Tim
@x-yz
Aug 02 2016 02:02
sry
Viknesh
@vk2mars
Aug 02 2016 02:02
help markdown
CamperBot
@camperbot
Aug 02 2016 02:02
no wiki entry for: markdown
Dana Aljirudi
@DanaJirudi
Aug 02 2016 02:02
@sjames1958gm That's what I have so far for the if statement if (myObj.hasOwnProperty(checkProp)){ return "undefined"; } I know there's something wrong here
Joe P
@JP50515
Aug 02 2016 02:03
Returning Boolean Values from Functions: isLess(10,15) should return true.....is not happening....What am I missing?
function isLess(a, b) {
  // Fix this code

 return a === b;
}

// Change these values to test
isLess(10, 15);
Stephen James
@sjames1958gm
Aug 02 2016 02:03
@DanaJirudi inside the brackets return the value of the property
@JP50515 Compare the function name to the condition you are checking a vs b
@DanaJirudi After the brackets return the string that they asked for
Dana Aljirudi
@DanaJirudi
Aug 02 2016 02:04
Yeah sorry if (myObj.hasOwnProperty(checkProp)){ return checkProp; } like that?
Tim
@x-yz
Aug 02 2016 02:05
!help markdown
CamperBot
@camperbot
Aug 02 2016 02:05
no wiki entry for: markdown
Stephen James
@sjames1958gm
Aug 02 2016 02:07
@vk2mars concat returns the new array
Joe P
@JP50515
Aug 02 2016 02:07
@sjames1958gm Thanks...and wow lol
CamperBot
@camperbot
Aug 02 2016 02:07
jp50515 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2267 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 02 2016 02:08

@JP50515 You are not the first that has followed the pattern of copying the ===
The real lesson here is that you don't have to

if (condition)
  return true;
else
  return false

Even with this lesson too many are still coding this -

Joe P
@JP50515
Aug 02 2016 02:09
Yup I can definitely see that being the case
Stephen James
@sjames1958gm
Aug 02 2016 02:09
@x-yz To the right of the input box is a button with an m and down arrow it gives markdown help
caseytherocket
@caseytherocket
Aug 02 2016 02:09
hey @ndburrus
Dana Aljirudi
@DanaJirudi
Aug 02 2016 02:09
Yeaaah I kinda worked, That's what I have so far

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

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)){
return myObj[checkProp];
}
return "Change Me!";
}

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

The last condition is unchecked still..!
AFK3000
@AFK3000
Aug 02 2016 02:10
i need help with this exercise

``
var myVar = 87;

// Only change code below this line
myVar = myVar + 1;
``

caseytherocket
@caseytherocket
Aug 02 2016 02:10
I'm on the "Reverse a String" Algorithm Challenge - I seem to be having an issue with getting my .join to work
Viknesh
@vk2mars
Aug 02 2016 02:10
@sjames1958gm What do you mean?
Stephen James
@sjames1958gm
Aug 02 2016 02:10
@DanaJirudi It passes some? What do the instructions say to return if the property is not there
@caseytherocket Make sure you put "" in the join or it joins with commas
caseytherocket
@caseytherocket
Aug 02 2016 02:10

`
function reverseString(str) {
var reverseString = [];

reverseString = str.split(''); {
reverseString.reverse();
reverseString.join('');

}

return reverseString;

}

reverseString("hello");`

Stephen James
@sjames1958gm
Aug 02 2016 02:10
@caseytherocket join returns a new value
caseytherocket
@caseytherocket
Aug 02 2016 02:11

My retunr =
function reverseString(str) {
var reverseString = [];

reverseString = str.split(''); {
reverseString.reverse();
reverseString.join('');

}

return reverseString;

}

reverseString("hello");

ohhh
I have to return reverseString.join('') ???
Stephen James
@sjames1958gm
Aug 02 2016 02:11
@AFK3000 The pattern on the right should be pretty clear you can replace i = i + 1 with i++, you should do the same with myVar = myVar + 1
Dana Aljirudi
@DanaJirudi
Aug 02 2016 02:11
@sjames1958gm Thanks A lot :smile: It worked
CamperBot
@camperbot
Aug 02 2016 02:11
danajirudi sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2268 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 02 2016 02:11
@caseytherocket Yes, or assign it and return the variable
@DanaJirudi :+1:
AFK3000
@AFK3000
Aug 02 2016 02:12

var myVar = 87;

// Only change code below this line
myVar = myVar + 1;

caseytherocket
@caseytherocket
Aug 02 2016 02:12
@sjames1958gm thanks!
CamperBot
@camperbot
Aug 02 2016 02:12
caseytherocket sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2269 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
AFK3000
@AFK3000
Aug 02 2016 02:12

You can easily increment or add one to a variable with the ++ operator.

i++;

is the equivalent of

i = i + 1;

Note
The entire line becomes i++;, eliminating the need for the equal sign.
Instructions

Change the code to use the ++ operator on myVar.

Tim
@x-yz
Aug 02 2016 02:12
i figured out my thing if anyone cares:
caseytherocket
@caseytherocket
Aug 02 2016 02:12
That makes a lot of sense - forgot the value was a new one
Stephen James
@sjames1958gm
Aug 02 2016 02:12
@x-yz :+1:
Tim
@x-yz
Aug 02 2016 02:12
changed if (contacts[i].firstName == firstName) to if (contacts[i][firstName] == firstName) {
AFK3000
@AFK3000
Aug 02 2016 02:13
myVar should equal 88
myVar = myVar should be changed
Use the ++ operator
Do not change code above the line
i dont get it
Stephen James
@sjames1958gm
Aug 02 2016 02:13
@AFK3000 if the code was i = i + 1 what would you change it to?
AFK3000
@AFK3000
Aug 02 2016 02:14
i++;
AndrewBeeh
@AndrewBeeh
Aug 02 2016 02:14

function convertToF(celsius) {
var fahrenheit = -30;

// Only change code below this line

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

// Change the inputs below to test your code
convertToF(30);
fahrenheit = (fahrenheit * 9/5) + 32;

Stephen James
@sjames1958gm
Aug 02 2016 02:14
@AFK3000 So if the code is myVar = myVar + 1 what should you change it to?
AFK3000
@AFK3000
Aug 02 2016 02:14
myVar++;
AndrewBeeh
@AndrewBeeh
Aug 02 2016 02:15
I'm working in Java script and i need to define the variable with multiple numbers
Stephen James
@sjames1958gm
Aug 02 2016 02:15
@AndrewBeeh The formula is on the left, inside the function use fahrenheit for F and for C
AndrewBeeh
@AndrewBeeh
Aug 02 2016 02:15
thank you
Stephen James
@sjames1958gm
Aug 02 2016 02:15
@AFK3000 And did you do that? If so it should pass
AFK3000
@AFK3000
Aug 02 2016 02:15
@sjames1958gm thx
CamperBot
@camperbot
Aug 02 2016 02:15
afk3000 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2270 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 02 2016 02:16
@AFK3000 :+1:
Norvin Burrus
@ndburrus
Aug 02 2016 02:28
@caseytherocket hey
Christian
@Neralizer
Aug 02 2016 02:30
function reverseString(str) {
  var array = str.split("");
  array.reverse();
  str = array.join();
  return str;
}

reverseString("hello");
how close am I to solving this first basic algorithm? I'm supposed to reverse hello to olleh
but I keep getting commas in between
caseytherocket
@caseytherocket
Aug 02 2016 02:31
@ndburrus my skills are improving :)
Christian
@Neralizer
Aug 02 2016 02:32
like o,l,l,e,h
instead of olleh. Is there a way to separate each letter without commas?
Rada
@Radascript
Aug 02 2016 02:34
@Neralizer inside join, put "" as well
so array.join("");
I think. Let me know if that helps or not.
Christian
@Neralizer
Aug 02 2016 02:35
you solved it. thought I was close
thanks @Radascript
CamperBot
@camperbot
Aug 02 2016 02:35
neralizer sends brownie points to @radascript :sparkles: :thumbsup: :sparkles:
:cookie: 382 | @radascript |http://www.freecodecamp.com/radascript
Rada
@Radascript
Aug 02 2016 02:36
@Neralizer yw!
Islam Ibakaev
@dagman
Aug 02 2016 02:42
what is a window analogy of mac' key combination super + shift + k?
Varun Sharma
@varun29
Aug 02 2016 02:45
is there any way we can insert any element at a particular index in between the array and elements succeding that inserted element shift one place ahead on itheir own...
Beth Qiang
@bethqiang
Aug 02 2016 02:54

so i'm doing the missing letter algorithm challenge right now. instructions: Find the missing letter in the passed letter range and return it. If all letters are present in the range, return undefined.

ex. fearNotLetter("abce") should return "d"

i know my code may not be the most efficient way to do it, but can anyone tell me why it returns undefined when it's not supposed to?

function fearNotLetter(str) {

  charCodeArray = [];

  for (var i=0; i<str.length; i++) {
    charCodeArray.push(str.charCodeAt(i));
  }

  sequentialArray = [];

  for (var j=charCodeArray[0]; j<(charCodeArray.length+charCodeArray[0]+1); j++) {
    sequentialArray.push(j);
  }

  for (var k=0; k<charCodeArray.length; k++) {
    for (var m=0; m<sequentialArray.length; m++) {
      if (charCodeArray[k]===sequentialArray[m]) {
        return undefined;
      } else {
        return String.fromCharCode(m);
      }
    }
  }
}
Ken Haduch
@khaduch
Aug 02 2016 02:54
@varun29 - maybe you're looking for the Array.splice method? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
Hai Nguyen
@learn4ever168
Aug 02 2016 02:56
hello everyone; i'm doing Seek and Destroy exercise. And trying to understand Arguments and Filter(). But I really can't understand how they work. Can anyone help me clear about them?
Varun Sharma
@varun29
Aug 02 2016 02:56
@khaduch array.splice method removes/extracts an element from the array. i want to insert an element in between the array at any given index..
Ken Haduch
@khaduch
Aug 02 2016 02:57
@varun29 - if you use a delete count of 0, then it will remove nothing and insert the new characters, according to the docs. Check the examples that they give on that documentation page.
Varun Sharma
@varun29
Aug 02 2016 02:57
@khaduch hey that sounds nice..can you explain this a bit more
Ken Haduch
@khaduch
Aug 02 2016 02:58
@varun29 - they give the example on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
var myFish = ['angel', 'clown', 'mandarin', 'surgeon'];

// removes 0 elements from index 2, and inserts 'drum'
var removed = myFish.splice(2, 0, 'drum');
// myFish is ['angel', 'clown', 'drum', 'mandarin', 'surgeon']
// removed is [], no elements removed
Varun Sharma
@varun29
Aug 02 2016 03:00
thanks @khaduch
CamperBot
@camperbot
Aug 02 2016 03:00
varun29 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1502 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Aug 02 2016 03:00
@varun29 - you're welcome...
Michael Bomholt
@bomholtm
Aug 02 2016 03:03
i have a really big problem with my local weather i use HTML geolocation and IP geolocation as backup... HTML geo only works with HTTPS... i can live with that but i figured out that IP geo isnt working anymore. it still works with HTTP. so is there a way to make IP geolocation work with HTTPS?
Nick Irvine
@irvin3
Aug 02 2016 03:08
hey guys! I'm working on the Friendly Date Ranges bonfire and am trying to think of a more efficient way to convert the month number to the month name. I don't want to use a bunch of if statement to convert it, I'm pretty sure there is a simpler way to list out what each month number represents as a string but i just cant remember what it is. Any ideas?
Varun Sharma
@varun29
Aug 02 2016 03:10
hey guys i'm getting an error of infnite loop...can anybody please explain it it to me of where there are chances of an infinite loop??
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  asdf = str.split("");
  for(i=0; i<asdf.length; i++){
    if(asdf[i] === asdf[i].toUpperCase() || asdf[i] === "_"){
      asdf.splice(i,0," ");
    }
  }
  return asdf;
}

spinalCase('thisIsSpinalTap');


Error: Potential infinite loop at line 7. To disable loop protection, write: 
// noprotect
as the first line. Beware that if you do have an infinite loop in your code this will crash your browser.
llamatarianism
@llamatarianism
Aug 02 2016 03:11
your loop ends when i >= asdf.length
but your loop also makes asdf bigger
asdf.splice(i,0," "); inserts something in, which increases asdf.length
Varun Sharma
@varun29
Aug 02 2016 03:12
@llamatarianism yeah but i<asdf.length
llamatarianism
@llamatarianism
Aug 02 2016 03:12
I believe what's causing the infinite loop
Michael Bomholt
@bomholtm
Aug 02 2016 03:12
has anyone IP Geolocation working under HTTPS?
llamatarianism
@llamatarianism
Aug 02 2016 03:12
is that " " == " ".toUpperCase()
whenever you insert in a space
the next character is also a space
and since a space is the same as an uppercase space
it inserts in another space
and it does that infinitely
Ken Haduch
@khaduch
Aug 02 2016 03:14
@bethqiang - I'm going to make a semi-educated guess that you are not checking the entire array, but hitting the first matching letter and returning undefined?
llamatarianism
@llamatarianism
Aug 02 2016 03:15
illustrated:
[ "x", "Y" ]
   ^ not the same itself uppercase, so don't insert a space.

[ "x", "Y" ]
        ^ the same as itself uppercase. insert a space.
[ "x", "Y", " " ]
             ^ insert a space.
[ "x", "Y", " ", " " ]
                  ^ insert a space.
 . . .
Beth Qiang
@bethqiang
Aug 02 2016 03:15
@khaduch - yep! i managed to figure it out, hah. that was exactly what was happening. :)
Varun Sharma
@varun29
Aug 02 2016 03:16
i've only insert the spaace when the current element is in caps or an _.and after inserting the space.the counter gets incremented moving the counter onto the next index after space
i guess @llamatarianism
llamatarianism
@llamatarianism
Aug 02 2016 03:19
no it doesn't
it moves onto the next item
which is now a space.
and it doesn't only insert the space when the current element is caps or an underscore.
it inserts a space if asdf[i] === asdf[i].toUpperCase() || asdf[i] === "_"
and if asdf[i] = " " then that condition will be true.
try it for yourself. add console.log(asdf[i]) into the loop and you'll see I'm right.
Varun Sharma
@varun29
Aug 02 2016 03:22
you mean when asdf[i] = " " then also asdf[i] === asdf[i].toUpperCase() condition gets satisfied??
llamatarianism
@llamatarianism
Aug 02 2016 03:22
yes
" ".toUpperCase() is still " "
what else would it be
Varun Sharma
@varun29
Aug 02 2016 03:23
due to which this adds another space after a space and the loop of space after space becomes infinite just like space..:)
yeah makes sense
llamatarianism
@llamatarianism
Aug 02 2016 03:24
you can solve this pretty easily by just skipping over the space.
after you insert the space, add 1 to i.
Varun Sharma
@varun29
Aug 02 2016 03:29
@llamatarianism but
when the string is thisIsSpinalTap then the loop shouldn't become infinite?
Peter Weinberg
@no-stack-dub-sack
Aug 02 2016 03:32
you guys prob dont care all that much lol, but I'm pleased to say I just officially completed the entire intermediate algo section!!!!!
Varun Sharma
@varun29
Aug 02 2016 03:32
cz while traversing the array of characters there ain't goona be already existing spaces, so it will just insert the space whenn it finds any caps and due after inserting due to i++the counter will move on to next charcter
Leo
@hkleowong
Aug 02 2016 03:32
hi i dont know what problems i have here

var Car = function() {
// this is a private variable
var speed = 10;

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

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

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

var Bike = function() {

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

// these are public methods
this.getGear = function() {

};

this.setGear = function() {

};
};

var myCar = new Car();

var myBike = new Bike();

in the 'Make Object Properties Private' exercise
Varun Sharma
@varun29
Aug 02 2016 03:33
@no-stack-dub-sack how many days did it take to complete the intermediate section
4
silver537
@silver537
Aug 02 2016 03:33
@no-stack-dub-sack all you need now are the intermediate and advanced projects, and bamn, you're are certified!
Leo
@hkleowong
Aug 02 2016 03:34
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {

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

  // these are public methods
  this.getGear = function() {

  };

  this.setGear = function() {

  };
};

var myCar = new Car();

var myBike = new Bike();
Peter Weinberg
@no-stack-dub-sack
Aug 02 2016 03:35
@varun29 about 8 or 9, it's been 10 days since I started, but I didn't code every single day
@silver537 I know, I'm pretty pumped!
@silver537 I'm really looking forward to these projects, although I know my wife isn't lol
silver537
@silver537
Aug 02 2016 03:36
cause the computer is gonna take most of your attention? lol
Peter Weinberg
@no-stack-dub-sack
Aug 02 2016 03:36
@silver537 also, I've completed the intermediate projects already. Just advanced left!
exactly haha, but she understands
silver537
@silver537
Aug 02 2016 03:37
damn. i havn't started the projects yet. havn't even finished the portfolio one. xD
AlexanderNelson
@AlexanderNelson
Aug 02 2016 03:38
ReferenceError: a is not defined

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch(val){
case a:
answer = ("apple");
break;
case b:
answer = ("bird");
break;
case c:
answer = ("cat");
break;
default:
answer =("stuff");
}

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

// Change this value to test
switchOfStuff(a);

Peter Weinberg
@no-stack-dub-sack
Aug 02 2016 03:38
@silver537 they're a lot of fun, worth the effort. I mean, I don't know how much experience you have, are you new to programming like I am or just new to front end?
llamatarianism
@llamatarianism
Aug 02 2016 03:38
@varun29 the next character will be a space.
so it'll insert another space.
then the next character will also be a space.
and so on forever
silver537
@silver537
Aug 02 2016 03:39
@no-stack-dub-sack i've mostly focused on javascript more than html or css. but once im done going over and rewriting the intermediate algorithm section, im gonna get more practice with html and css. then ill do the projects.
Varun Sharma
@varun29
Aug 02 2016 03:41
@llamatarianism can we have a talk personally, if its convinient/
llamatarianism
@llamatarianism
Aug 02 2016 03:42
@varun29 sure
Greg Duncan
@GregatGit
Aug 02 2016 03:48
@AlexanderNelson switchOfStuff('a'); not switchOfStuff(a);
AlexanderNelson
@AlexanderNelson
Aug 02 2016 03:51
@GregatGit im getting the same result. i dont understand why it passed on that last lesson and not this one
Greg Duncan
@GregatGit
Aug 02 2016 03:53
so are you passing in "a" or a - big difference
@AlexanderNelson I think your cases should be case 'a' not case a
Defeds
@defeds
Aug 02 2016 03:55

function truncateString(str, num) {
  // Clear out that junk in your trunk
  // Turning the string into an array on every space so i can count length of each word
  var splitting = str.split(" ");
  // Looping over the amount of words in splitting
  for(var i = 0; i < splitting.length; i++) {
    // If the current word is greater then the number parameter
    if(splitting[i].length > num) {
      //return the current word + ...
     return splitting[i] + "...";
      // If the strings length is <= 3
    } else if(str <= 3) {
      // Unsure what's suppose to return here?
      return splitting.join(" ");
    }
  }
  return splitting.join(" ");
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Hey guys, pretty confused on what i'm really suppose to do in 'Truncate a string'? Am i on the right path somewhat?
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 03:57
i'm actually on the same one now T_T
AlexanderNelson
@AlexanderNelson
Aug 02 2016 03:57
@GregatGit i realized i had deleted those after i pasted. i ts working now:) thanks
CamperBot
@camperbot
Aug 02 2016 03:57
alexandernelson sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 719 | @gregatgit |http://www.freecodecamp.com/gregatgit
Greg Duncan
@GregatGit
Aug 02 2016 03:58
@AlexanderNelson :+1:
Defeds
@defeds
Aug 02 2016 03:58
@Jlipschitz is whats being asked also confusing for you?
AlexanderNelson
@AlexanderNelson
Aug 02 2016 03:59
how is everyone posting the console image?
Tilak Raj
@trdhiman
Aug 02 2016 03:59
Dear @dmduelist thanks.......
CamperBot
@camperbot
Aug 02 2016 03:59
trdhiman sends brownie points to @dmduelist :sparkles: :thumbsup: :sparkles:
:cookie: 329 | @dmduelist |http://www.freecodecamp.com/dmduelist
Defeds
@defeds
Aug 02 2016 03:59
@AlexanderNelson ``` then shift enter and post code between
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 03:59
i've gotten 5 but can't get the last one @defeds .. it's confusing at first with the wording
Defeds
@defeds
Aug 02 2016 04:00
@Jlipschitz have you implemented the .split prototype? i'm not sure where i'd use it in this exercise tbh
i mean
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 04:01
how come you used split?
Defeds
@defeds
Aug 02 2016 04:01
slice
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 04:01
i skipped slice lol and used substring
AlexanderNelson
@AlexanderNelson
Aug 02 2016 04:01
var test
Peter Weinberg
@no-stack-dub-sack
Aug 02 2016 04:02
@silver537 re-writing the intermediate algo section? Are you just re-writing it in all ES6 as part of your discipline as we were discussing last night?
Defeds
@defeds
Aug 02 2016 04:02
@Jlipschitz i think i completely messed up, i was iterating through each word in a string, testing if one of the words were greater then num
Tilak Raj
@trdhiman
Aug 02 2016 04:02
@dmduelist , why ,return"No such contact " , outside for loop ????
silver537
@silver537
Aug 02 2016 04:02
@no-stack-dub-sack yes!
Defeds
@defeds
Aug 02 2016 04:02
@Jlipschitz it's just asking for if the whole string is > number, right? :laughing:
llamatarianism
@llamatarianism
Aug 02 2016 04:02
@trdhiman so that you check all the contacts before saying there are none that have the right first name
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 04:02
you start from the beginning of the string so no need to split and rejoin
llamatarianism
@llamatarianism
Aug 02 2016 04:02
if you return "no such contact" the first time you go through the loop
Peter Weinberg
@no-stack-dub-sack
Aug 02 2016 04:03
@silver537 gotcha, cool, nice effort
llamatarianism
@llamatarianism
Aug 02 2016 04:03
then you only check 1 contact
Defeds
@defeds
Aug 02 2016 04:03
@Jlipschitz That makes a lot more sense lol thanks
CamperBot
@camperbot
Aug 02 2016 04:03
defeds sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:cookie: 152 | @jlipschitz |http://www.freecodecamp.com/jlipschitz
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 04:03
i need help as well.. would you mind if I posted my code?
Defeds
@defeds
Aug 02 2016 04:04
lets see it
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 04:04
but in terms of pseudo
```js
//return from beginning of string
//figure out where to end

//add '...' when necessary or omit when string is same length

Nick Neuman
@neecholaus
Aug 02 2016 04:04
This message was deleted
`
hey can someone tell me why this isnt working? its the chunky monkey algorithm exercise. it will divide up most of the inputs properly but sometimes it will only return like 3 sub arrays when it should do 4 or 5 etc. Im not really sure where i went wrong.
function chunkArrayInGroups(arr, size) {
    newArr = [];

    for (i = 0; i < arr.length; i++) {
        newArr.push(arr.slice(0, size));
        for (j = 0; j < size; j++) {
            arr.shift();
        }
    } return newArr;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2)
Defeds
@defeds
Aug 02 2016 04:05
@Jlipschitz what's the problem tho, like what are you not achieving
Varun Sharma
@varun29
Aug 02 2016 04:06
@llamatarianism thanks
CamperBot
@camperbot
Aug 02 2016 04:06
varun29 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1098 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 04:06
the .length + 2 one @defeds
well just finished it but i'm pretty sure i didn't do it right
Defeds
@defeds
Aug 02 2016 04:08
@Jlipschitz haha, i mean if you understand it i guess that works
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 04:08
because i ended doing another case that if num > str.length .. to just subtract 2 and return the whole string
bitgrower
@bitgrower
Aug 02 2016 04:08
@neecholaus you are altering the size of the array ... and each loop the arr.length is re-evaluated .. you need to save off the length into a variable that you use for the loop test
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 04:09
@defeds finish so we can discuss it haha
Defeds
@defeds
Aug 02 2016 04:11
@Jlipschitz we'll see if thats soon, i still don'y get this num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string.
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 04:11
@defeds use either slice or substring.. they both work the same
Defeds
@defeds
Aug 02 2016 04:12
i mean i dont even understand what thats asking hey
bitgrower
@bitgrower
Aug 02 2016 04:12
which challenge you working on @defeds ?
Defeds
@defeds
Aug 02 2016 04:12
@bitgrower Truncate a string
ZZPot
@ZZPot
Aug 02 2016 04:12
loaded script doesn't execute
mangalita
@mangalita
Aug 02 2016 04:12
escaping Sequences in string this what they want me to do FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
ZZPot
@ZZPot
Aug 02 2016 04:13
using jsonp
<script type="text/javascript" src="http://api.forismatic.com/api/1.0/?method=getQuote&key=123456&format=jsonp&lang=en&jsonp=alert"></script>
it returns correct data, but it doesn't execute it
test
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 04:18
@defeds i think more or less since you are told to add three dots to the end of a string from the start.. it's saying disregard that when num <= 3. only add to the end of the num you are given and not the string length as a whole
bitgrower
@bitgrower
Aug 02 2016 04:19
@defeds why are you splitting it up into an array of strings ?!?
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 04:19
he's changed his approach since then @bitgrower
Defeds
@defeds
Aug 02 2016 04:19
@Jlipschitz Yeah think i've finally got it, so essentially from where the string is > num slice it from there and and ... so lets say num is 3 and i have the str of elephant it would = ele...
bitgrower
@bitgrower
Aug 02 2016 04:20
ahhh ... okay ...
Defeds
@defeds
Aug 02 2016 04:20
@bitgrower Yeah i thought it was asking individually haha
bitgrower
@bitgrower
Aug 02 2016 04:20
@defeds can you post your current code ?
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 04:20
yes that's correct @defeds .. right on!
Cal-culator
@Cal-culator
Aug 02 2016 04:20
Help Caesars Cipher
CamperBot
@camperbot
Aug 02 2016 04:20

:point_right: algorithm caesars cipher [wiki]

Algorithm Caesars Cipher

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

:checkered_flag: Problem Explanation:

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

Relevant Links

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

bitgrower
@bitgrower
Aug 02 2016 04:21
and yes...reading the instructions is important on truncate a string ...
Defeds
@defeds
Aug 02 2016 04:22
@bitgrower instructions were the confusing part, wasnt making 100% sense as to what it wanted, but finally clicked, now time to figure out how to use splice to figure out where to begin and end
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 04:22
it's a bit confusing at frist though
don't splice use slice @defeds
bitgrower
@bitgrower
Aug 02 2016 04:23
well, it probably would work better to use slice ... :)
LOL ...
snap
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 04:23
i'm a poet
Defeds
@defeds
Aug 02 2016 04:23
:| i typo'd
too much brain frying haha
cheers though
Tilak Raj
@trdhiman
Aug 02 2016 04:24
@llamatarianism thanks for clarification....
CamperBot
@camperbot
Aug 02 2016 04:24
trdhiman sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1099 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Jamie Lipschitz
@Jlipschitz
Aug 02 2016 04:24
no worries mine was too. just fixed my code and now i'm satisfied with answer
chaitanya ashtekar
@chaitanyaashtekar
Aug 02 2016 04:26
anyone finished with tic tac toe ?
Darth Skywalker
@adityaparab
Aug 02 2016 04:32
#europe .country {
    border:none;
}

#titanic{
    float:none;
}
chaitanya ashtekar
@chaitanyaashtekar
Aug 02 2016 04:34
@adityaparab gm
Darth Skywalker
@adityaparab
Aug 02 2016 04:34
@chaitanyaashtekar : GM mate!
chaitanya ashtekar
@chaitanyaashtekar
Aug 02 2016 04:35
:smile:
NixonRichard
@NixonRichard
Aug 02 2016 04:50
hello
bitgrower
@bitgrower
Aug 02 2016 04:50
hello!
NixonRichard
@NixonRichard
Aug 02 2016 04:50
anyone see what s wrong with my code ?

//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){ //the code start 
// Only change code below this line
if ( firstName == contacts.firstName && prop == contacts.property){
  return contacts[prop]; //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.
}
  else if ( firstName != contacts.firstName){
    return "No such contact";//If firstName does not correspond to any contacts then return "No such contact"
  }
  else if ( prop != contacts.property){
    return "No such property";//If prop does not correspond to any valid properties then return "No such property"
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
challenge Profile Lookup
bitgrower
@bitgrower
Aug 02 2016 04:52
okay, for one thing -- see those brackets? That means the data structure is an array ... an array of objects...so a for loop might come in handy ...
help profile lookup
CamperBot
@camperbot
Aug 02 2016 04:52

:point_right: challenge profile lookup [wiki]

Challenge Profile Lookup

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

:checkered_flag: Problem Explanation:

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

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

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

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

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

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

bitgrower
@bitgrower
Aug 02 2016 04:52
See? It says so right there: "We have an array of objects representing different people in our contacts lists."
NixonRichard
@NixonRichard
Aug 02 2016 04:56
This message was deleted
Ya
bitgrower
@bitgrower
Aug 02 2016 04:59
So ... programming is really detail-oriented ... I often read the requirements for a problem multiple times ... and I'll usually find things I need to clarify in my mind ... however ... it helps to break things down this way ...
  1. What have I been given ? Be able to describe it in terms of the datastructure
  2. What is wanted of me from the data I'm getting
  3. how do I get the information in the data structure to the output desired ...
Benjamin Kwok
@bkkwok
Aug 02 2016 05:04
he gave u a good hint, first figure out how to access each property, once you're able to do that, you can use a for loop to iterate through each object in the array. combine this with if statements and you're set
bcrosby6181
@bcrosby6181
Aug 02 2016 05:07
use a for in loop to iterate over an object
Bar Akiva
@Gitity
Aug 02 2016 05:11
Hello! Where can I get feedback on lesson solution code?
bitgrower
@bitgrower
Aug 02 2016 05:11
here's the place!
or are you talking about reviewing the solution ?
Bar Akiva
@Gitity
Aug 02 2016 05:11
Yes
bitgrower
@bitgrower
Aug 02 2016 05:11
something that already works ?
Bar Akiva
@Gitity
Aug 02 2016 05:11
yeah
but works dirty :(
bitgrower
@bitgrower
Aug 02 2016 05:12
what do you mean by works dirty ?
Bar Akiva
@Gitity
Aug 02 2016 05:12
looks too messy
bitgrower
@bitgrower
Aug 02 2016 05:12
which challenge it is ?
Profile lookup
NixonRichard
@NixonRichard
Aug 02 2016 05:13
lmao
张登泽
@dictatorone
Aug 02 2016 05:13

function sumAll(arr) {
var myArray = [];
for (var i = Math.min(arr);i <= Math.max(arr);i++){
myArray.push(i);
}
return myArray.reduce(function(a,b){
return a+b;
});
}

sumAll([1, 4]);

bitgrower
@bitgrower
Aug 02 2016 05:13
thank you @Masd925
CamperBot
@camperbot
Aug 02 2016 05:13
bitgrower sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2213 | @masd925 |http://www.freecodecamp.com/masd925
张登泽
@dictatorone
Aug 02 2016 05:14
what's wrong with my alogorithm?thank you
Bar Akiva
@Gitity
Aug 02 2016 05:14
thank you @Masd925
CamperBot
@camperbot
Aug 02 2016 05:14
gitity sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2214 | @masd925 |http://www.freecodecamp.com/masd925
bitgrower
@bitgrower
Aug 02 2016 05:14
This message was deleted
Bar Akiva
@Gitity
Aug 02 2016 05:15
Code review is kind of dead right no
now*
Have you looked at my solution?
bitgrower
@bitgrower
Aug 02 2016 05:17
that's definitely one of the more unusual solutions I've seen ...
NixonRichard
@NixonRichard
Aug 02 2016 05:18
the most *
:smile:
Bar Akiva
@Gitity
Aug 02 2016 05:19
Its bad isnt it?
I can take it
NixonRichard
@NixonRichard
Aug 02 2016 05:19
like u r using a rifle to kills an ant
:smile:
Bar Akiva
@Gitity
Aug 02 2016 05:20
In what way?
bitgrower
@bitgrower
Aug 02 2016 05:20
@Gitity you need a loop to loop thru each of the objects in the array ... for each item you do a few checks ...
if it passes a check, then you do something ....
well, for one, you don't need to assign so many variables ...
let me make the one suggestion which is that you can get hints in the FCC wiki, like this ...
help profile lookup
CamperBot
@camperbot
Aug 02 2016 05:21

:point_right: challenge profile lookup [wiki]

Challenge Profile Lookup

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

:checkered_flag: Problem Explanation:

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

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

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

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

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

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

NixonRichard
@NixonRichard
Aug 02 2016 05:21

Hint: 1

Use a for loop to cycle through the contact list
Hint: 2

Use a nested if statement to first check if the firstName matches, and then checks if the prop matches
Hint: 3

Leave your return "No such contact" out of the for loop as a final catch-all

CamperBot
@camperbot
Aug 02 2016 05:21
Set a bonfire to talk about with bonfire name
bitgrower
@bitgrower
Aug 02 2016 05:21
now, if you click on the bottom link, it will give you hints ... you might see if those hints help you ...
NixonRichard
@NixonRichard
Aug 02 2016 05:21
@Gitity look at this
and a fully functioning solution
@bitgrower
bitgrower
@bitgrower
Aug 02 2016 05:22
you can ALSO look at other campers solutions who ahve them and make them public ... by just going to their fcc profile and clicking on "view solution" for the particular challenge
NixonRichard
@NixonRichard
Aug 02 2016 05:22
 for (var i = contacts[0];i < contacts.length; i++ ){
is this the right loop ?
Bar Akiva
@Gitity
Aug 02 2016 05:22
I can VIEW SOLUTIONS from other peoples profiles?!
bitgrower
@bitgrower
Aug 02 2016 05:23
if they have 'em, and their stuff is public (mos t are)
Bar Akiva
@Gitity
Aug 02 2016 05:23
holy shitballs this is a ridiculously amazing feature
Benjamin Kwok
@bkkwok
Aug 02 2016 05:23
contacts[0] is an object, you want i = 0, because it marks the beginning of the array in which your objects are situated
NixonRichard
@NixonRichard
Aug 02 2016 05:24
Okay
Bar Akiva
@Gitity
Aug 02 2016 05:24
How do you enter another persons solutions?
Benjamin Kwok
@bkkwok
Aug 02 2016 05:25
within your for loop , you can use 'i' like this contacts[i]
bitgrower
@bitgrower
Aug 02 2016 05:25
NO ... I'm not gonna make it that easy on you ... :)
typing it out helps to drill it into your brain ...
NixonRichard
@NixonRichard
Aug 02 2016 05:26
Oh yeh
Bar Akiva
@Gitity
Aug 02 2016 05:26
Found it
now I know all of your secrets!
bitgrower
@bitgrower
Aug 02 2016 05:26
hah! No you don't ... you just think you do !
Bar Akiva
@Gitity
Aug 02 2016 05:26
thanks @NixonRichard @bkkwok @bitgrower
CamperBot
@camperbot
Aug 02 2016 05:26
gitity sends brownie points to @nixonrichard and @bkkwok and @bitgrower :sparkles: :thumbsup: :sparkles:
:cookie: 212 | @nixonrichard |http://www.freecodecamp.com/nixonrichard
:cookie: 120 | @bkkwok |http://www.freecodecamp.com/bkkwok
:star2: 1164 | @bitgrower |http://www.freecodecamp.com/bitgrower
NixonRichard
@NixonRichard
Aug 02 2016 05:27
What s u guyz IQ s scores ?
ZZPot
@ZZPot
Aug 02 2016 05:27
minus 78
Benjamin Kwok
@bkkwok
Aug 02 2016 05:27
0
bitgrower
@bitgrower
Aug 02 2016 05:27
IQ scores are irrelevant for adults ...
Benjamin Kwok
@bkkwok
Aug 02 2016 05:27
lolol
bitgrower
@bitgrower
Aug 02 2016 05:27
they are not defined ...
Bar Akiva
@Gitity
Aug 02 2016 05:28
mine is 10+= yourIQ;
ZZPot
@ZZPot
Aug 02 2016 05:28
my IQ get scored every friday
Benjamin Kwok
@bkkwok
Aug 02 2016 05:28
its yourIQ += 10
lOL
bitgrower
@bitgrower
Aug 02 2016 05:28
I think mine decreases every time I listen to one of the presidential candidates ... :)
Bar Akiva
@Gitity
Aug 02 2016 05:28
lol?
ZZPot
@ZZPot
Aug 02 2016 05:28
@Gitity so if mine is 250 that means that your is just 9?
Bar Akiva
@Gitity
Aug 02 2016 05:29
be careful there - politics in chat rooms is never a good idea
bitgrower
@bitgrower
Aug 02 2016 05:29
in fact I'm sure of it ... it increases the amount of cortisol
ZZPot
@ZZPot
Aug 02 2016 05:29
oh wait
NixonRichard
@NixonRichard
Aug 02 2016 05:29
Im listening
ZZPot
@ZZPot
Aug 02 2016 05:29
your's is 4
bitgrower
@bitgrower
Aug 02 2016 05:30
hahahahahahahahahaha ... the wonderful thing about most of these chat rooms is the large number of folks who aren't in the US in them ... especially this time of night ... and if MY overseas friends are any indication, their choice seems to be rather one-sided ...
ZZPot
@ZZPot
Aug 02 2016 05:31
@bitgrower what did you mean?
I have -78 IQ so please tell again
bitgrower
@bitgrower
Aug 02 2016 05:31
did hell freeze over ?
ZZPot
@ZZPot
Aug 02 2016 05:32
a little
bitgrower
@bitgrower
Aug 02 2016 05:32
oh you said your IQ, that's not your brain temp :) sorry
ZZPot
@ZZPot
Aug 02 2016 05:32
it's ok for me, I don't like hot weather
Bar Akiva
@Gitity
Aug 02 2016 05:32
are there any "exemplary" code campers I can learn from their profile solutions?
besides bitgrower ofc :)
ZZPot
@ZZPot
Aug 02 2016 05:33
@Gitity ctrl+U
张登泽
@dictatorone
Aug 02 2016 05:33

function sumAll(arr) {
var myArray = [];
for (var i = Math.min(arr);i <= Math.max(arr);i++){
myArray.push(i);
}
return myArray.reduce(function(a,b){
return a+b;
});
}

sumAll([1, 4]);

NixonRichard
@NixonRichard
Aug 02 2016 05:34
hmm
DJ
@qualitymanifest
Aug 02 2016 05:34
@dictatorone myArray is unnecessary, as is the .reduce
NixonRichard
@NixonRichard
Aug 02 2016 05:34
my brain freezed
Bar Akiva
@Gitity
Aug 02 2016 05:35
@ZZPot none of the chat members profiles are on the code of the page
Darth Skywalker
@adityaparab
Aug 02 2016 05:35

@dictatorone : It won't work that way. Math.min(arr) and Math.max(arr) will be NaN.

You need to use Math.min.apply(null, arr) and Math.max.apply(null, arr) instead

ZZPot
@ZZPot
Aug 02 2016 05:35
@Gitity you need an example of good code, right?
DJ
@qualitymanifest
Aug 02 2016 05:35
@dictatorone also Math.min(arr) and Math.max(arr) won't work without using es6 spread operator
Bar Akiva
@Gitity
Aug 02 2016 05:35
even if they I still need a way to figure out who solved my kind of challenges
NixonRichard
@NixonRichard
Aug 02 2016 05:35
bam bam bam
DJ
@qualitymanifest
Aug 02 2016 05:35
(or what @adityaparab said, for an es5 way of doing it)
Bar Akiva
@Gitity
Aug 02 2016 05:36
@ZZPot I meant I needed exemplary FCC users to learn from their lesson solutions
NixonRichard
@NixonRichard
Aug 02 2016 05:36
Anyone watched the movie Capitalism : A love story ?
DJ
@qualitymanifest
Aug 02 2016 05:36
@Gitity there should be solution examples in the wiki
ZZPot
@ZZPot
Aug 02 2016 05:36
@Gitity why? tasks are elementary
NixonRichard
@NixonRichard
Aug 02 2016 05:37
It s Michael Moore
Bar Akiva
@Gitity
Aug 02 2016 05:37
@ZZPot might as well learn from the best i figure
anyhow ill check the wiki
ZZPot
@ZZPot
Aug 02 2016 05:38
I don't think that you should learn brom best.
do as you can
bitgrower
@bitgrower
Aug 02 2016 05:38

Anyone watched the movie Capitalism : A love story ?

not yet ... is it worthwhile? I think it's avail to me via Amazon Prime ...

NixonRichard
@NixonRichard
Aug 02 2016 05:39
I guess
not sure about ur American s slang talks but i think it s great
ZZPot
@ZZPot
Aug 02 2016 05:40
Tp
for mine bung whole
NixonRichard
@NixonRichard
Aug 02 2016 05:40
why ?
all of them r bungs ?
ZZPot
@ZZPot
Aug 02 2016 05:41
are you threatening me?
NixonRichard
@NixonRichard
Aug 02 2016 05:41
no im just asking im not sure about anything
i dont know if i can trust the informations in the movie
ZZPot
@ZZPot
Aug 02 2016 05:41
sure you can
movie is real
like spiderman or king-kong
张登泽
@dictatorone
Aug 02 2016 05:42
So,the
it
NixonRichard
@NixonRichard
Aug 02 2016 05:42
but it s not movie it s documentary like
Rico042002
@rico042002
Aug 02 2016 05:43
Javascript is no joke. What's weird is it's so powerful, but its more work without seeing how much your learning. I see why people say suggesting JS as a first language is stupid
ZZPot
@ZZPot
Aug 02 2016 05:43
think with your own head
@rico042002 ?
张登泽
@dictatorone
Aug 02 2016 05:43
it does not work@Aditya Parab
NixonRichard
@NixonRichard
Aug 02 2016 05:44
i dont know cuz im have never experienced capitalism
bitgrower
@bitgrower
Aug 02 2016 05:44
Moore tends to go overboard .. like what did you have a problem with ... ?
Rico042002
@rico042002
Aug 02 2016 05:44
I tried to learn JS without knowing anything about HTML or CSS In the beginning
ZZPot
@ZZPot
Aug 02 2016 05:44
@rico042002 have ever look at the code of pages that you visiting?
Rico042002
@rico042002
Aug 02 2016 05:44
Yep. I know JS is very important!!!
ZZPot
@ZZPot
Aug 02 2016 05:44
it's not binary files like .exe
bitgrower
@bitgrower
Aug 02 2016 05:44
where are you from @NixonRichard
ZZPot
@ZZPot
Aug 02 2016 05:45
just press ctrl+U
张登泽
@dictatorone
Aug 02 2016 05:45
@qualitymanifest what is that mean unnecessary
NixonRichard
@NixonRichard
Aug 02 2016 05:45
VietNam Lol @bitgrower
Darth Skywalker
@adityaparab
Aug 02 2016 05:46

@dictatorone : It does mate. Your addition code is problematic.
If you do a console.log(myArray) you will see correct values.

You need to pass 2nd argument to the .reduce method

return myArray.reduce(function(a,b){
    return a+b;
},0);  <<<<<<< Pass 0 to initialize previous value
bitgrower
@bitgrower
Aug 02 2016 05:46
@dictatorone it means not needed
NixonRichard
@NixonRichard
Aug 02 2016 05:47
@bitgrower Can u getany ideas ?
bitgrower
@bitgrower
Aug 02 2016 05:49
about what @NixonRichard ?
CamperBot
@camperbot
Aug 02 2016 05:49
:cookie: 212 | @nixonrichard |http://www.freecodecamp.com/nixonrichard
Markus Kiili
@Masd925
Aug 02 2016 05:50
@adityaparab For summing numbers in an array, the second argument of reduce is optional.
bitgrower
@bitgrower
Aug 02 2016 05:50
that's because I said "about" ... incidentally ... the @camperbot parser can seem kinda silly at times ...
DJ
@qualitymanifest
Aug 02 2016 05:53
@dictatorone it means that you are doing things that you don't need to. you don't need to put the numbers into an array and then reduce them. you can just add the numbers to a variable as you loop. but first, you have to fix your loop conditions
NixonRichard
@NixonRichard
Aug 02 2016 05:53
@bitgrower about the documentary is it true or false as u r a native American ? depend on u if u find it s uncomfort to answer i may ask someone else :smile: but gladly if u can give me some ideas to bright my mind :smile:
Reginald Holt
@Reggiereg83
Aug 02 2016 05:54

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

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

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

Very confused can someone help me?
NixonRichard
@NixonRichard
Aug 02 2016 05:54
@Reggiereg83 easy my friend
:smile:
Reginald Holt
@Reggiereg83
Aug 02 2016 05:55
lol
NixonRichard
@NixonRichard
Aug 02 2016 05:55
fahrenheit = 1 + 1 +1
like that
// Only change code below this line
// Only change code above this line
between them
i gotta go to sleep Cya
Reginald Holt
@Reggiereg83
Aug 02 2016 05:56
ok thanks ill keep trying
Giang Le
@gianghl1983
Aug 02 2016 05:56

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

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

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

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

I got stuck at phoneticLookup("") should equal undefined
You should not use case, switch, or if statements
please help me out :D!
NixonRichard
@NixonRichard
Aug 02 2016 05:56
@gianghl1983 Viet Nam :smile:
Giang Le
@gianghl1983
Aug 02 2016 05:57
@NixonRichard u too :D?
NixonRichard
@NixonRichard
Aug 02 2016 05:57
Yes
Jim Zhang
@dividez
Aug 02 2016 05:57
hello
NixonRichard
@NixonRichard
Aug 02 2016 05:57
:v
Giang Le
@gianghl1983
Aug 02 2016 05:57
hehe, nice to meet you! You are also learning to code from scratch?
Darth Skywalker
@adityaparab
Aug 02 2016 05:58

To Find sum of all number in a range, you don't even need an array, If you know Math well :P

Just use arithmetic progression n(n-1)/2 :D

NixonRichard
@NixonRichard
Aug 02 2016 05:58
@gianghl1983 yeah
But i know the solution for ur problem
:smile:
Giang Le
@gianghl1983
Aug 02 2016 05:59
@NixonRichard great, show me buddy!
Darth Skywalker
@adityaparab
Aug 02 2016 05:59
like
var arr = [1, 6];

var min = Math.min.apply(null, arr);
var max = Math.max.apply(null, arr);

var total = (max*(max-1)/2) - (min*(min-1)/2);
NixonRichard
@NixonRichard
Aug 02 2016 05:59
Sure wait a minute
Giang Le
@gianghl1983
Aug 02 2016 06:00
I am on work now (1PM), please PM me if possible
btw, my Skype = gianghl1983 @NixonRichard . See you soon!
NixonRichard
@NixonRichard
Aug 02 2016 06:00
Sure i will :smile:
bitgrower
@bitgrower
Aug 02 2016 06:03

@bitgrower about the documentary is it true or false as u r a native American ? depend on u if u find it s uncomfort to answer i may ask someone else :smile: but gladly if u can give me some ideas to bright my mind

Capitalism has its problems ... I haven't watched Moore's documentary -- I know he goes overboard. Moore is actually a capitalist :)

NixonRichard
@NixonRichard
Aug 02 2016 06:03
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line



  result = {
    "alpha":"Adams",
    "bravo":"Boston",
    "charlie":"Chicago",
    "delta":"Denver",
    "echo":"Easy",
    "foxtrot":"Frank"


  };
  result = result[val];

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

// Change this value to test
phoneticLookup("charlie");
@gianghl1983
Here
abdelghani95
@abdelghani95
Aug 02 2016 06:03
hi
bitgrower
@bitgrower
Aug 02 2016 06:03
anyway ... time for me to retire ... see ya all t'morrow
NixonRichard
@NixonRichard
Aug 02 2016 06:04
U have no answer ? @bitgrower
bitgrower
@bitgrower
Aug 02 2016 06:05
I haven't seen the movie, so how could I give you an answer ?
NixonRichard
@NixonRichard
Aug 02 2016 06:05
Hey watch it then if u want it always depend on u :smile:
i added u too a private room
do u agree with that ?
Helmi Previanto Firmansyah
@helmiprevianto
Aug 02 2016 06:15
hello
Markus Kiili
@Masd925
Aug 02 2016 06:18
@helmiprevianto Hi.
Rico042002
@rico042002
Aug 02 2016 06:20
Im midways through the Javascript Lessons. Anybody have any suggested books or blog's? I know about Eloquent Javascript, Im gonna start reading that later tonight
Markus Kiili
@Masd925
Aug 02 2016 06:21
@rico042002 I like "Speaking javascript" more, but many people like Eloquent.
Darth Skywalker
@adityaparab
Aug 02 2016 06:22
Michelle L.
@Lucywaa
Aug 02 2016 06:23
Hello!!! I just started learning JS and im trying to do a login using MEAN stack, but somehow I can't find information about how to get the data from mongo db :c anyone here has some useful link? :3 <3
Darth Skywalker
@adityaparab
Aug 02 2016 06:24
@Lucywaa : Look up mongoose
Do you have any code that you're stuck at?
Helmi Previanto Firmansyah
@helmiprevianto
Aug 02 2016 06:25
dumb question here...
how to write code here, on gitter so it can appear like code editor on freecodecamp?
Mark Todd
@Knochenmark
Aug 02 2016 06:25
@NixonRichard i think you shouldnt assign your lookup object to result
@NixonRichard not wrong, since you overwrite it, but not a good practice
Rico042002
@rico042002
Aug 02 2016 06:26
@adityaparab thanks
CamperBot
@camperbot
Aug 02 2016 06:26
rico042002 sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 445 | @adityaparab |http://www.freecodecamp.com/adityaparab
Rico042002
@rico042002
Aug 02 2016 06:26
@Masd925 thank you
CamperBot
@camperbot
Aug 02 2016 06:26
rico042002 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2215 | @masd925 |http://www.freecodecamp.com/masd925
huangtianyu3077
@huangtianyu3077
Aug 02 2016 06:26
@rico042002 I like this -Professional JavaScript for Web
Darth Skywalker
@adityaparab
Aug 02 2016 06:27
function phoneticLookup(val) {
  return {
    "alpha":"Adams",
    "bravo":"Boston",
    "charlie":"Chicago",
    "delta":"Denver",
    "echo":"Easy",
    "foxtrot":"Frank"
  }[val];
}

// Change this value to test
phoneticLookup("charlie");
Mark Todd
@Knochenmark
Aug 02 2016 06:27
@rico042002 Javascript the Good Parts - Douglas Crockford
Darth Skywalker
@adityaparab
Aug 02 2016 06:27
@Knochenmark : Yes, that is also a good book
Mark Todd
@Knochenmark
Aug 02 2016 06:28
@rico042002 When you are more advanced. Javascript Patterns - Stoyan Stefanov
Rico042002
@rico042002
Aug 02 2016 06:32
@Knochenmark Cant wait, I was stuck in the "research phase" for 3 years
Now Im about to dedicate 3 years to pure coding everyday!
r2d2
@UsamaHameed
Aug 02 2016 06:33
JS is so messy. :/
Helmi Previanto Firmansyah
@helmiprevianto
Aug 02 2016 06:33

I got stuck in this challenge

function nextInLine(arr, item) {
// Your code here
testArr.push(item);
arr = testArr.shift();
return arr; // 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 cant pass the "nextInLine ([5,6,7,8,9],1) should return 5"

r2d2
@UsamaHameed
Aug 02 2016 06:33
Is there any guide to learn about how the code executes, the event loop, the stack and the cross origin shiz?
Mark Todd
@Knochenmark
Aug 02 2016 06:35
@UsamaHameed most of the things you mentioned, you can follow using the dev tools in your browser
r2d2
@UsamaHameed
Aug 02 2016 06:36
Well one can but I want to know what are the best practices, why do I get the cross origin errors etc
@adityaparab what was that star wars website?
Darth Skywalker
@adityaparab
Aug 02 2016 06:39
kisscartoon.me
You will find almost all cartoons there
@UsamaHameed
r2d2
@UsamaHameed
Aug 02 2016 06:39
Starting the first season of the clone wars
Darth Skywalker
@adityaparab
Aug 02 2016 06:39
Sweet!
If I may suggest, first watch the movie Start Wars Clone Wars (2008)
that's where it all begins
r2d2
@UsamaHameed
Aug 02 2016 06:42
I have watched the movies.
Darth Skywalker
@adityaparab
Aug 02 2016 06:45
It's different
It's an animated movie
Prequel to The Clone Wars Series
r2d2
@UsamaHameed
Aug 02 2016 06:49
Oh.
Mark Todd
@Knochenmark
Aug 02 2016 06:51
theres no native Date format that supports full month names or?
kirbyedy
@kirbyedy
Aug 02 2016 06:53
really ?
Aayush Sharma
@techdiary
Aug 02 2016 06:54

trying to run server.js locally, i have followed this procedure:

  1. create a empty dir, did npm init
  2. wrote the code in server.js
  3. did npm install http

    Still getting error!

var http = require('http');

http.createServer(function(request,response) {
     /* body... */ 
     response.writeHead(200, {'Content-Type': 'text/plain'})
     response.write('Hello World');
     response.end();
}).listen(8888);

Please help me in nodeJs

It's working now, I thought running node server.js also runs watch command

Ivan Aganin
@criativ
Aug 02 2016 07:04
HELP - Arguments Optional --- kind of get the idea of closures... but how to do the rest of the function? :/
CamperBot
@camperbot
Aug 02 2016 07:04
no wiki entry for: - arguments optional --- kind of get the idea of closures but how to do the rest of the function
amir
@aizen3
Aug 02 2016 07:04
Understanding Uninitialized Variables
i cant solve this challenge guys
they ask me to do that
a should be defined and have a value of 6
b should be defined and have a value of 15
c should not contain undefined and should have a value of "I am a String!"
Markus Kiili
@Masd925
Aug 02 2016 07:13
@criativ Simplest way is to make two checks for one and two valid arguments. Then return either the sum or a function that you construct or make with .bind().
JS functions return undefined automatically if no explicit return is made, so you can forget returning undefined.
Ivan Aganin
@criativ
Aug 02 2016 07:14
This is hard....... I mean the concept. To grasp the idea will take me A LOT....
I see the solution code and it is much more difficult then me initial thoughts were
But i do get the idea
Markus Kiili
@Masd925
Aug 02 2016 07:17
It is quite simple, because the function you construct and return, remembers the arguments[0] of the addTogether function (stored in a variable perhaps), because of closure.
@criativ What solution code are you talking about?
Ivan Aganin
@criativ
Aug 02 2016 07:20
about this one ->
CamperBot
@camperbot
Aug 02 2016 07:20
you need to ask about @someone!
Ivan Aganin
@criativ
Aug 02 2016 07:20
function addTogether() {

  var checkNum = function(num) {
    if (typeof num !== 'number') {
      return undefined;
    } else
      return num;
  };

  if (arguments.length > 1) {
    var a = checkNum(arguments[0]);
    var b = checkNum(arguments[1]);
    if (a === undefined || b === undefined) {
      return undefined;
    } else {
      return a + b;
    }
  } else {
    var c = arguments[0];
      if (checkNum(c)) {
        return function(arg2) {
        if (c === undefined || checkNum(arg2) === undefined) {
          return undefined;
        } else {
                return c + arg2;
        }
      };
    }
  }
}

addTogether(2,3);
It's one of the CLEAREST explanations
Markus Kiili
@Masd925
Aug 02 2016 07:22
@criativ It is much better to just do positive checks and avoid all the undefined business.
Ivan Aganin
@criativ
Aug 02 2016 07:22
It's not my solution
I would do a bit different, but it would take me a LOT of time...
Markus Kiili
@Masd925
Aug 02 2016 07:23
Like this:
function addTogether() {
  if (arguments.length===2 && typeof(arguments[0])==='number' && typeof(arguments[1])==='number') return ???
  if (arguments.length===1 && typeof(arguments[0])==='number') return ???
}
Ivan Aganin
@criativ
Aug 02 2016 07:23
I don't even know if I am going to NEED this in my entire life! :)
I look at this code that I gave - it is a MESS...
so much unneeded things here
Markus Kiili
@Masd925
Aug 02 2016 07:26
Using bind, the solution is as simple as this:
function addTogether() {
  if (arguments.length===2 && typeof(arguments[0])==='number' && typeof(arguments[1])==='number') return arguments[0] +  arguments[1];
  if (arguments.length===1 && typeof(arguments[0])==='number') return addTogether.bind(null, arguments[0]);
}
If you construct the function that is returned, you need few more lines.
kriskros09
@kriskros09
Aug 02 2016 07:27
What would the answer to this be ?

Assign the value 7 to variable a.

Assign the contents of a to variable b.

Ivan Aganin
@criativ
Aug 02 2016 07:29
@Masd925 don't know what "bind" is
That's exactly my point - when I do these exercises - I have NO full knowledge of commands of things that I MAY or MAY NOT need.....
I would prefer, that in the example they would give me 10-20 links to commands that COULD help me solve this, instead - you I am left in the dark
Is there a point to this?
Markus Kiili
@Masd925
Aug 02 2016 07:31
Normal way is to construct the function like this:
function addTogether() {
  if (arguments.length===2 && typeof(arguments[0])==='number' && typeof(arguments[1])==='number') return arguments[0] +  arguments[1];
  var arg = arguments[0];
  if (arguments.length===1 && typeof(arguments[0])==='number') {
    return function (a) {
      if (typeof a ==='number') return arg+a;
    };
  }
}
Ivan Aganin
@criativ
Aug 02 2016 07:32
Now I look at it and see that I used "arguments" couple months back, but by now - I already forgot they exist....
Markus Kiili
@Masd925
Aug 02 2016 07:32
This exercise aims to teach closure and responding to variable number of arguments, I think.
Ivan Aganin
@criativ
Aug 02 2016 07:32
why not reference to that???
no... they just leave you with a stick in a dark
f that
Markus Kiili
@Masd925
Aug 02 2016 07:33
It is hard to learn programming by just doing exercises.
You need some other material too, like books or something.
Ivan Aganin
@criativ
Aug 02 2016 07:35
That's what I said - why not reference to "arguments" or "bind" - whatever that is....
anyways....
Markus Kiili
@Masd925
Aug 02 2016 07:35
Bind is just some advanced way of solving it. Normal way is to construct the function and return it.
Ivan Aganin
@criativ
Aug 02 2016 07:36
I'll end this discussion, this has no value to it. I will continue learning.
Aayush Sharma
@techdiary
Aug 02 2016 07:37
In nodeJS if I'm running server locally on port:8800
and whenever i stop it with Ctr + Z i have to change port number?
or else it shows Error! Can anyone tell me why?
Ariel Moctezuma
@KyleMoctezuma
Aug 02 2016 07:38

can someone help me i cant seem to get my a and b variable to equal
// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7;
var b = 7;
var a = b;

Picshulo
@Picshulo
Aug 02 2016 07:39

Hello guys, i'm quite stuck on "Return Largest Numbers in Arrays".

function largestOfFour(arr) {
  var maxArray = [];
  for(var i = 0; i < arr.length; i++){
    for(var j = 0; j < arr[i].length; j++){
      var maxValue;
    }
  }
}

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

This is my code, but i don't know how to get highest number of each array into "maxValue".

r2d2
@UsamaHameed
Aug 02 2016 07:39
@aizen3 there?
Aayush Sharma
@techdiary
Aug 02 2016 07:39
@KyleMoctezuma are you checking equality or assigning number ?
amir
@aizen3
Aug 02 2016 07:40
@UsamaHameed yes bro
Ariel Moctezuma
@KyleMoctezuma
Aug 02 2016 07:40
@techdiary assiging
Markus Kiili
@Masd925
Aug 02 2016 07:41
@Picshulo Initialize maxValue for each subarray to 0 or -Infinity, and then compare it to subarray element. After j loop, assign maxValue to arr[i], or push it to maxArray.
r2d2
@UsamaHameed
Aug 02 2016 07:41
Do you need some help? @aizen3
amir
@aizen3
Aug 02 2016 07:42
yes in js
Aayush Sharma
@techdiary
Aug 02 2016 07:42

@KyleMoctezuma

a =2;

why are you assigning b a new value?

amir
@aizen3
Aug 02 2016 07:43
@UsamaHameed this is the fifth challenge in js (Understanding Uninitialized Variables)
komorebi
@komorebi-san
Aug 02 2016 07:43
Hi
amir
@aizen3
Aug 02 2016 07:43
i dont know how to do it i tried but didn't work
komorebi
@komorebi-san
Aug 02 2016 07:44

// Setup
var testObj = {
"hat": "ballcap",
"shirt": "jersey",
"shoes": "cleats"
};

// Only change code below this lin
var hatValue = testObj.prop1; // Change this line
var shirtValue = testObj.prop2; // Change this line

Why am i getting undefined for the hatValue and shirtValue ?

Ariel Moctezuma
@KyleMoctezuma
Aug 02 2016 07:44
its the 2nd challenge for js
komorebi
@komorebi-san
Aug 02 2016 07:44
anyone knows?
r2d2
@UsamaHameed
Aug 02 2016 07:44
@aizen3 Paste your formatted code here
Ariel Moctezuma
@KyleMoctezuma
Aug 02 2016 07:44
@techdiary its the way the challeng was set up
amir
@aizen3
Aug 02 2016 07:45

// Initialize these three variables
var a;
var b;
var c;

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

komorebi
@komorebi-san
Aug 02 2016 07:45
ah nvm
got it
Aayush Sharma
@techdiary
Aug 02 2016 07:45
@yeongren was pop1 and prop2 right atrribute?
@KyleMoctezuma can you tell me chalange number?
Markus Kiili
@Masd925
Aug 02 2016 07:46
@techdiary There are no challenge numbers, only names.
r2d2
@UsamaHameed
Aug 02 2016 07:46
@aizen3 you need to initialize a, b and c such that the resulting values become the ones given in the left side panel after the bottom three statements run.
Aayush Sharma
@techdiary
Aug 02 2016 07:47
Ok, name? :D
Ariel Moctezuma
@KyleMoctezuma
Aug 02 2016 07:47
@techdiary Storing Values with the Assignment Operator
r2d2
@UsamaHameed
Aug 02 2016 07:48
@aizen3 Like if they want you to return 4 for the value of a, you would initialize a to 3 because the code adds 1 its self.
Picshulo
@Picshulo
Aug 02 2016 07:49

@Masd925 I know you trying to help me, but my english sucks so sorry about it

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

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

I tried this, but it's getting the last number of each subarray then

r2d2
@UsamaHameed
Aug 02 2016 07:49
This message was deleted
Markus Kiili
@Masd925
Aug 02 2016 07:49
@Picshulo You are not initializing maxValue for each subarray. You initialize it for each subarray element.
mengshaofeng
@mengshaofeng
Aug 02 2016 07:50

function lookUp(firstName, prop){
// Only change code below this line

for(var i=0;i<contacts.length;i++){
firstName=contacts[i];
for(var j=0;j<firstName.length;j++){
prop=firstName[j];
}
}
if(!firstName)contacts="No such contact";
else if(!prop)contacts="No such property";
return contacts;
// Only change code above this line
}
mylogical is right or not?!help me please~my english is suck....

Aayush Sharma
@techdiary
Aug 02 2016 07:50
@KyleMoctezuma
you are declaring again with var
and the question is to have b same value as a
a =7;
b = a;
Markus Kiili
@Masd925
Aug 02 2016 07:50
@mengshaofeng Don't overwrite the function parameter firstName.
Picshulo
@Picshulo
Aug 02 2016 07:51
@Masd925 I see! i have to initialize it before second for loop.. Thank you, now it works :)
CamperBot
@camperbot
Aug 02 2016 07:51
picshulo sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2216 | @masd925 |http://www.freecodecamp.com/masd925
Ariel Moctezuma
@KyleMoctezuma
Aug 02 2016 07:51
yeah i just cant get a and b to eqaul
amir
@aizen3
Aug 02 2016 07:51
@UsamaHameed finally thnx bro
CamperBot
@camperbot
Aug 02 2016 07:51
aizen3 sends brownie points to @usamahameed :sparkles: :thumbsup: :sparkles:
:cookie: 384 | @usamahameed |http://www.freecodecamp.com/usamahameed
r2d2
@UsamaHameed
Aug 02 2016 07:52
:+1: @aizen3
Zauri3645
@Zauri3645
Aug 02 2016 07:56
@KyleMoctezuma did you get it correct?
Kalyan_Ar
@Kalyan-Ar
Aug 02 2016 08:06
hi people
need help with maps api
Suzan Dpor
@kitty1
Aug 02 2016 08:12
hi everyone,can anybody help me with "Testing Objects for Properties" challange the 176challenge please??

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

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

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

Alexander Domikov
@AlexanderDom
Aug 02 2016 08:19
@marhyorh , no no ^^ i was searching on wrong attribute for second step, i tryied to find elements based on class, but i used names in html...
Anna
@Anntol
Aug 02 2016 08:39
@kitty1 What error do you have? besides checks for ===true is pointless - you can check if (myObj.hasOwnProperty(checkProp)){
Bhatti3bro
@Bhatti3bro
Aug 02 2016 08:41
im stuck in this too :(

function checkObj(checkProp) {
// Your Code Here

if (myObj.hasOwnProperty(checkProp)) {
return myObj.checkProp;
} else {
return "Not Found";
}}

am i doing something wrong?
Anna
@Anntol
Aug 02 2016 08:41
@kitty1 @Bhatti3bro checkProp is variable - you should use bracket notation instead of dot
Puvendran Pillay
@puven12
Aug 02 2016 08:42
i have a question if i use return where does the value goes?
r2d2
@UsamaHameed
Aug 02 2016 08:42
@Anntol @kitty1 you can use dot notation too for vars
NixonRichard
@NixonRichard
Aug 02 2016 08:42
example ? @puven12
Puvendran Pillay
@puven12
Aug 02 2016 08:42
does it console.log or document.write
var cat = 'kitty';
return cat;
NixonRichard
@NixonRichard
Aug 02 2016 08:43
it prints "kitty"
@puven12
Puvendran Pillay
@puven12
Aug 02 2016 08:44
@NixonRichard to where to the console?
NixonRichard
@NixonRichard
Aug 02 2016 08:44
no ideas out of my permission
Hello guyz
What s wrong with my code ?
//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 ( firstName == contacts[i][0] && prop == contacts[i][prop]){
   return contacts[i][prop];
  }
  else if ( firstName != contacts[i][0] ) {
    return "No such contact";

  }
  return "No such property";
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Puvendran Pillay
@puven12
Aug 02 2016 08:45
@NixonRichard thanks anyways
CamperBot
@camperbot
Aug 02 2016 08:45
puven12 sends brownie points to @nixonrichard :sparkles: :thumbsup: :sparkles:
:cookie: 213 | @nixonrichard |http://www.freecodecamp.com/nixonrichard
Puvendran Pillay
@puven12
Aug 02 2016 08:45
ok
NixonRichard
@NixonRichard
Aug 02 2016 08:45
challenge profile lookup
UtkarshShukla7
@UtkarshShukla7
Aug 02 2016 08:45
@puven12 if its not inside a function I don't think you can use return statement
Anna
@Anntol
Aug 02 2016 08:45
@UsamaHameed myObj.checkProp is undefined - please post your working version with dot notation