These are chat archives for FreeCodeCamp/HelpJavaScript

19th
Mar 2016
Daniel
@N4dd
Mar 19 2016 00:04
@UnlimiWorks I think my brain is fried, I don't understand.
Maddah Anass
@unlimiworks
Mar 19 2016 00:05
@daniel-chris-lucas concat is used to merge arrays, try using push()
Daniel
@N4dd
Mar 19 2016 00:05
@UnlimiWorks Let me get this straight, I need to use the phoneticLookup("charlie") to somehow force a result from the lookup table into the result variable?
Maddah Anass
@unlimiworks
Mar 19 2016 00:06
Or you can hack through it and do return previous.concat([current])
Daniel Lucas
@daniel-chris-lucas
Mar 19 2016 00:07
@UnlimiWorks Thanks, I think you’re right, I can’t believe I didn’t notice boefre
CamperBot
@camperbot
Mar 19 2016 00:07
daniel-chris-lucas sends brownie points to @unlimiworks :sparkles: :thumbsup: :sparkles:
:warning: daniel-chris-lucas already gave unlimiworks points
Maddah Anass
@unlimiworks
Mar 19 2016 00:07
@N4dd yes, exactly. and that result would be the value of "charlie" that's in lookup
@daniel-chris-lucas You're welcome :)
Daniel
@N4dd
Mar 19 2016 00:11
@UnlimiWorks I guess I understand what it's asking for, I just don't know how to code it.
Maddah Anass
@unlimiworks
Mar 19 2016 00:13
I'll help you figure it out if I can
So do you know how to get a value from lookup ? For example, if I want the value of charlie, how do I get it ?
Remember that lookup is an object
Daniel
@N4dd
Mar 19 2016 00:13
lookup.charlie
or lookup["charlie"];
Maddah Anass
@unlimiworks
Mar 19 2016 00:16
yes, that's right. Now, if you have var variable='charlie', how can you use it to get the value ?
Daniel
@N4dd
Mar 19 2016 00:16
I suppose I could store the value of charlie into a variable like this. variable1 = lookup["charlie"]
Maddah Anass
@unlimiworks
Mar 19 2016 00:16
@N4dd Yes, and if you do that, variable1 will store the value of "charlie"
Daniel
@N4dd
Mar 19 2016 00:17
lookup[variable]
Maddah Anass
@unlimiworks
Mar 19 2016 00:18
That's right. Now how can you apply that to the exercise ?
Daniel
@N4dd
Mar 19 2016 00:18
result = lookup[phoneticLookup];
that's where I'm stuck
Maddah Anass
@unlimiworks
Mar 19 2016 00:19
You're pretty close. phoneticLookup is the name of the function, not the variable holding the value
Daniel
@N4dd
Mar 19 2016 00:20
which variable is holding the value?
Maddah Anass
@unlimiworks
Mar 19 2016 00:21
This is a piece of code you can write in free code camp's code editor :
function testFunction(argument1) {
 return argument1;
}

return function('charlie'); // This will return charlie
Daniel
@N4dd
Mar 19 2016 00:23
ugh
Chelsea Egan
@level5esper
Mar 19 2016 00:23
I'm with @N4dd ... I'm totally stuck at the same point and can't seem to get it
Daniel
@N4dd
Mar 19 2016 00:24
@level5esper I'm glad I'm not alone.
Maddah Anass
@unlimiworks
Mar 19 2016 00:24
Look at how i wrote return argument1 inside the function, not return testFunction
Daniel
@N4dd
Mar 19 2016 00:25
so val is = "charlie"
Maddah Anass
@unlimiworks
Mar 19 2016 00:25
yes, exactly
Daniel
@N4dd
Mar 19 2016 00:25
lookup[val] = result;
I feel like it's right there, but it's not going through
Chelsea Egan
@level5esper
Mar 19 2016 00:26
Do we need to add something after the lookup?
or only at the bottom?
herbertdellama
@herbertdellama
Mar 19 2016 00:27
for the "Find The Longest Word" algorithm i keep getting "Cannot read property 'length' of undefined" I think my code should work but my syntax is wrong. can someone help?
function findLongestWord(str) {
  var number = 0;
  str = str.split(" ");
  for (i=0; i<str.length-1;i++){
    if (str[i].length > str[i-1].length){
      number = str[i].length;
    }
  }
  return number;
}
Trevor Baker
@noizehack
Mar 19 2016 00:28
@herbertdellama think about what str[i-1].length is when i is 0 on the first iteration of the for loop
Daniel
@N4dd
Mar 19 2016 00:29
result = lookup[function(val)]; haha I assume this would be infinite?
I don't know how to access val
herbertdellama
@herbertdellama
Mar 19 2016 00:29
@noizehack you are quite right. ill try and fix it thanks
CamperBot
@camperbot
Mar 19 2016 00:29
herbertdellama sends brownie points to @noizehack :sparkles: :thumbsup: :sparkles:
:star: 372 | @noizehack | http://www.freecodecamp.com/noizehack
Maddah Anass
@unlimiworks
Mar 19 2016 00:30
I'll try to explain it more generally.
If I write function testFunction(argument1, argument2, argument3) { ... }, I'm defining my function. In that case,testFunction is the name of the function. argument1, argument2, argumet3are called parameters of the function.
Now, if i write testFunction('a', 'b', 'c')after that, I'm callling the function. 'a', 'b' and 'c' are called arguments of the function.
arguments are the values that will replace the parameters inside the function
Chelsea Egan
@level5esper
Mar 19 2016 00:31
right so phoneticLookup('charlie') is placing charlie as the parameter in the function
Maddah Anass
@unlimiworks
Mar 19 2016 00:31
@level5esper If you have the same problem than @N4dd , then hopefully this will explain it
Yes, exactly @level5esper . we say that 'charlie' is the argument of the function
Chelsea Egan
@level5esper
Mar 19 2016 00:33
but it doesn't seem to be accessing the lookup table? it's as if the lookup table isn't functioning?
so do I have to add a bit of code after the table to make it work?
Maddah Anass
@unlimiworks
Mar 19 2016 00:34
@level5esper Can I see your code ? You're probably not accessing it right
Harsh Khandelwal
@harsh2602
Mar 19 2016 00:34

Palindrome Check: Why does this fail at last test case?

function palindrome(str) {
var sanitizedStr = str.replace(/\W/g, '').toLowerCase();
var reverseStr = sanitizedStr.split('').reverse().join('');
return sanitizedStr === reverseStr;
}

Maddah Anass
@unlimiworks
Mar 19 2016 00:34
@harsh2602 What is the last test case ?
Harsh Khandelwal
@harsh2602
Mar 19 2016 00:36
@UnlimiWorks palindrome("0_0 (: /-\ :) 0-0") should return true.
colon bracket has turned into emoji
Chelsea Egan
@level5esper
Mar 19 2016 00:37

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

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

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

// Change this value to test

phoneticLookup('charlie');
'''

CamperBot
@camperbot
Mar 19 2016 00:37
:bulb: to format code use backticks! ``` more info
Daniel
@N4dd
Mar 19 2016 00:37
yes @level5esper you have to add more
Benjamin Gonzalez
@xasuma
Mar 19 2016 00:37
Hey, I am on the "word Blanks" challenge from Basic Javascript , and I really have no idea what they want me to do. Can someone point me in the right direction?
Maddah Anass
@unlimiworks
Mar 19 2016 00:38
@harsh2602 your regExp gets rid of -, but not _;
Daniel
@N4dd
Mar 19 2016 00:38
We need to somehow get the parameter as the x factor inside of our lookup table.
Maddah Anass
@unlimiworks
Mar 19 2016 00:38
@level5esper try using ` instead of '
Harsh Khandelwal
@harsh2602
Mar 19 2016 00:39
does \W not cover _ ?
Maddah Anass
@unlimiworks
Mar 19 2016 00:39
@level5esper This is the initial code if I recall right ?
Chelsea Egan
@level5esper
Mar 19 2016 00:39
// Setup
function phoneticLookup(val) {
  var result = "";

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



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

// Change this value to test

phoneticLookup('charlie');
sorry, had trouble figuring it out
Maddah Anass
@unlimiworks
Mar 19 2016 00:39
@harsh2602 _ is included in \w, that's why
Daniel
@N4dd
Mar 19 2016 00:40
in the example he posted about, a is the argument for the parameter argument1
now, how to we access that argument, I have no idea.
Harsh Khandelwal
@harsh2602
Mar 19 2016 00:40
so if I write \W_ it should work? @UnlimiWorks
Daniel
@N4dd
Mar 19 2016 00:41
once we can access the "x factor" we just need to make result = lookup[x factor];
am i correct in my thinking @UnlimiWorks ?
Chelsea Egan
@level5esper
Mar 19 2016 00:42
oh my god
I figured it out
you're super close @N4dd
Harsh Khandelwal
@harsh2602
Mar 19 2016 00:42
@xasuma create a fill in the blanks type string where the blanks fill up from arguments passed..Don't draw any blank lines
Maddah Anass
@unlimiworks
Mar 19 2016 00:42
@N4dd Yes, you're almost there
Chelsea Egan
@level5esper
Mar 19 2016 00:42
thank you @UnlimiWorks !!!
CamperBot
@camperbot
Mar 19 2016 00:42
level5esper sends brownie points to @unlimiworks :sparkles: :thumbsup: :sparkles:
Maddah Anass
@unlimiworks
Mar 19 2016 00:42
@level5esper glad you're finally there :)
CamperBot
@camperbot
Mar 19 2016 00:42
:star: 367 | @unlimiworks | http://www.freecodecamp.com/unlimiworks
Chelsea Egan
@level5esper
Mar 19 2016 00:42
haha that was so frustrating
Maddah Anass
@unlimiworks
Mar 19 2016 00:43
@harsh2602 It wouldn't
@harsh2602 your new regExp is looking for \W followed by a _
@level5esper The most important thing is to understand why it didn't work, and how you got it to work
Harsh Khandelwal
@harsh2602
Mar 19 2016 00:44
@UnlimiWorks let me then go through the regex documentation
Chelsea Egan
@level5esper
Mar 19 2016 00:44
@UnlimiWorks my understanding is I had to specify what the result would be
before it would be able to return it
Daniel
@N4dd
Mar 19 2016 00:45
do i have to create a new variable = val?
Maddah Anass
@unlimiworks
Mar 19 2016 00:45
@harsh2602 You do that :) I wouldn't recommend using \W at all though, you will probably see why in the documentation
Chelsea Egan
@level5esper
Mar 19 2016 00:45
@N4dd think about what we learned in the last couple of lessons
about accessing things with brackets and dot operators
CamperBot
@camperbot
Mar 19 2016 00:46
you need to ask about @someone!
lcaptain47
@lcaptain47
Mar 19 2016 00:46

I'm having a lot of trouble with the chunky monkey algorithm.

function chunk(arr, size) {
  // Break it up.
  var finalArr=[];
  var pushVal;
  pushVal=arr.slice(0,size);
  finalArr.push(pushVal);

  for(var i=0; i<arr.length;i++){
    pushVal=arr.slice(i+size,size+size);

    if(pushVal.length<size){
      break;
    }

    finalArr.push(pushVal);

  }
  return finalArr;
}

chunk([0, 1, 2, 3, 4, 5], 2);

If I were to remove the if statement, I would get incorrect values in my final array. Like [] or repeating values like [1,2,3][4,5,6][5,6][6]. I am entirely lost at the moment. May someone help me please.

Maddah Anass
@unlimiworks
Mar 19 2016 00:47
@N4dd You just need to return the value you're looking for. You can store that in a variable, and then return that one, or you can return it directly.
Can we see your code ?
lcaptain47
@lcaptain47
Mar 19 2016 00:47
The if statement also causes problems for the other objectives by removing parts that are needed.
Daniel
@N4dd
Mar 19 2016 00:48
''
'''js
var lookup = {
"alpha": "Adams",
"beta": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank",
};
var test1 = val;
result = lookup[test1];
CamperBot
@camperbot
Mar 19 2016 00:48
:bulb: to format code use backticks! ``` more info
Daniel
@N4dd
Mar 19 2016 00:48
 var lookup = {
    "alpha": "Adams",
    "beta": "Boston",
    "charlie": "Chicago",
    "delta": "Denver",
    "echo": "Easy",
    "foxtrot": "Frank",
  };
var test1 = val;
result = lookup[test1];
Chelsea Egan
@level5esper
Mar 19 2016 00:48
@n4dd cut out the middleman!
Daniel
@N4dd
Mar 19 2016 00:49
yeah, and that didn't work
Maddah Anass
@unlimiworks
Mar 19 2016 00:49
@N4dd First off, your function needs to output something using the keyword return, are you doing that ?
Daniel
@N4dd
Mar 19 2016 00:49
var lookup = {
    "alpha": "Adams",
    "beta": "Boston",
    "charlie": "Chicago",
    "delta": "Denver",
    "echo": "Easy",
    "foxtrot": "Frank",
  };
result = lookup[val];
Maddah Anass
@unlimiworks
Mar 19 2016 00:50
@N4dd As it is, your function does all the processing, but doesn't return anything. if you want to retrieve the result, you need to return it :)
Daniel
@N4dd
Mar 19 2016 00:51
you mean return result;?
that's still there
Maddah Anass
@unlimiworks
Mar 19 2016 00:51
you can consider return as "the answer of the function"
Chelsea Egan
@level5esper
Mar 19 2016 00:51
maybe the problem is the comma after Frank?
I don'
I don't think that's supposed to be there
Daniel
@N4dd
Mar 19 2016 00:52
// Setup
function phoneticLookup(val) {
  var result = "";

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

result = lookup[val];

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

// Change this value to test
phoneticLookup("charlie");
that's the full code
demipixel
@demipixel
Mar 19 2016 00:52
Has anybody done exact change?
Maddah Anass
@unlimiworks
Mar 19 2016 00:52
@N4dd It should work...
Chelsea Egan
@level5esper
Mar 19 2016 00:52
@N4dd take the comma after frank away!
Malcolm
@noinkling
Mar 19 2016 00:52
@N4dd Yeah it should work, maybe the trailing comma like @level5esper said
Maddah Anass
@unlimiworks
Mar 19 2016 00:52
@demipixel How can I help ?
demipixel
@demipixel
Mar 19 2016 00:53
@UnlimiWorks Would you be able to proofread something for me?
Malcolm
@noinkling
Mar 19 2016 00:53
Although IIRC JS should allow a trailing comma
Maddah Anass
@unlimiworks
Mar 19 2016 00:53
Oh, yes. THe comma after frank. Good catch @level5esper :)
demipixel
@demipixel
Mar 19 2016 00:53
(pretty sure the comma after frank is allowed, btw)
(unless it's json)
Malcolm
@noinkling
Mar 19 2016 00:53
^
Daniel
@N4dd
Mar 19 2016 00:53
nope
I figured it out
I was correct all along, son of a bitch
I have beta instead of bravo
....
also needed to refresh browser
Chelsea Egan
@level5esper
Mar 19 2016 00:54
oh man hahaha
Maddah Anass
@unlimiworks
Mar 19 2016 00:54
Oh, lol
Daniel
@N4dd
Mar 19 2016 00:55
20th time I've learned that lesson, thanks @UnlimiWorks and @level5esper
CamperBot
@camperbot
Mar 19 2016 00:55
n4dd sends brownie points to @unlimiworks and @level5esper :sparkles: :thumbsup: :sparkles:
:star: 368 | @unlimiworks | http://www.freecodecamp.com/unlimiworks
:star: 220 | @level5esper | http://www.freecodecamp.com/level5esper
Chelsea Egan
@level5esper
Mar 19 2016 00:55
@N4dd I've learned proof reading is basically the most important part of coding lol
Daniel
@N4dd
Mar 19 2016 00:56
@level5esper yeah. I think i hit run tests so much it broke
Maddah Anass
@unlimiworks
Mar 19 2016 00:56
@N4dd You're welcome :)
@demipixel When something doesn't work, you even start questioning your beliefs :shipit:
demipixel
@demipixel
Mar 19 2016 00:56
haha
too true
@UnlimiWorks PMs? :smile:
Maddah Anass
@unlimiworks
Mar 19 2016 00:56
Sure thing
Daniel
@N4dd
Mar 19 2016 00:56
I'm off for the night, have a good one everybody.
Maddah Anass
@unlimiworks
Mar 19 2016 00:56
Good night @N4dd !
Harsh Khandelwal
@harsh2602
Mar 19 2016 00:58
@UnlimiWorks from the documentation I understand the mistake..I did write replace(/[\W_]/g, '') to make it work for this problem.. It works now..Thanks
CamperBot
@camperbot
Mar 19 2016 00:58
harsh2602 sends brownie points to @unlimiworks :sparkles: :thumbsup: :sparkles:
:star: 369 | @unlimiworks | http://www.freecodecamp.com/unlimiworks
Maddah Anass
@unlimiworks
Mar 19 2016 00:58
@harsh2602 Glad I helped :)
Andrew Charlebois
@andrewchar
Mar 19 2016 01:01
i am failing right now with this fibonacci numbers thing, been messing around for while but im not getting it right :( have this so far
function sumFibs(num) {

  //var prevNum = 1;
  //var currNum = 1;
  var finalNum = 0;


  var fibNum = [0,1];

  while ((fibNum.length-1) <= num) {
    fibNum.push((fibNum.length-2) + (fibNum.length-1));
    console.log(fibNum.length-1);
  } if ((fibNum.length-1) % 2 !== 0) {
    finalNum += fibNum.length-1;
  }


  //console.log(fibNum);
  return finalNum;



}

sumFibs(1);
demipixel
@demipixel
Mar 19 2016 01:01
Is it fib numbers or odd fib numbers?
Andrew Charlebois
@andrewchar
Mar 19 2016 01:02
odd
demipixel
@demipixel
Mar 19 2016 01:02
kk
Okay, so
Firstly
sumFibs(4) means the sum of all fibs less than 4
Not "4 of the odd fib numbers"
John-Michael L'Allier
@jmlallier
Mar 19 2016 01:04
Hey guys, I'm on the Caesars Cipher Algorithm challenge and am running into a problem. I've got the code almost working, but for some reason, the return is returning the last index in my array to string as a null character. :worried:
function rot13(str) { // LBH QVQ VG!
  var arr = str.split('');
  var newArr = [];
  var letter = "";
  var newStr = "";
  var newChar = 0;
  for (var i = 0; i < arr.length; i++) {
    var code = str.charCodeAt(i);

    if (code <= 77 && code >= 65) {
      newChar = code + 13;
      newArr.push(letter);
    } else if (code >= 78 && code <= 90) {
      newChar = code - 13;
      newArr.push(letter);
    } else {
      newChar = code;
      newArr.push(letter);
    }
    letter = String.fromCharCode(newChar);

  }
  newStr = newArr.join('');
  return newStr;
}

// Change the inputs below to test
rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK.");
// returns: "THE QUICK BROWN DOG JUMPED OVER THE LAZY FOX" without a period at the end.
demipixel
@demipixel
Mar 19 2016 01:05
:worried:
Andrew Charlebois
@andrewchar
Mar 19 2016 01:05
@demipixel just noticed its not doing math right
John-Michael L'Allier
@jmlallier
Mar 19 2016 01:05
And it's not the "." character giving the problem. With
rot13("SERR PBQR PNZC") ;
// returns: "FREE CODE CAM"
demipixel
@demipixel
Mar 19 2016 01:06
@jmlallier Maybe slip some console.logs in there and see what's going on?
ex, right at the start of the for-loop, log str[i] (the character) and code to make sure you're getting the P
Clay Holt
@tarwater
Mar 19 2016 01:07
var running = turnRound(c);
alert("test");
That alert call will run BEFORE running is assigned a value. This is (i'm guessing) due to turnRound() requiring a user input before the return statement is accessed. WHY??
I'm not used to languages working that way
it should sit there and wait until turnRound(); sends something back
demipixel
@demipixel
Mar 19 2016 01:08
@tarwater Nothing in javascript sits around and waits
John-Michael L'Allier
@jmlallier
Mar 19 2016 01:09
@demipixel console.log is not printing to the console :/
yelsneH
@yelsneh
Mar 19 2016 01:09
I can't wrap my head around the logic for Chunky Monkey
demipixel
@demipixel
Mar 19 2016 01:09
Did you write turnRound yourself?
yelsneH
@yelsneh
Mar 19 2016 01:09
at all
I really REALLY don't understand where to even start
demipixel
@demipixel
Mar 19 2016 01:09
@jmlallier The chrome console?
Rex Smith Jr.
@rsmith731
Mar 19 2016 01:09
where can i get some help on this exercise?
demipixel
@demipixel
Mar 19 2016 01:09
@yelsneh What's the problem
John-Michael L'Allier
@jmlallier
Mar 19 2016 01:09
@demipixel lol, guess that would make sense
yelsneH
@yelsneh
Mar 19 2016 01:09
Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.
Clay Holt
@tarwater
Mar 19 2016 01:09
@demipixel i did. it won't return anything until the user clicks on a element
demipixel
@demipixel
Mar 19 2016 01:09
@rsmith731 Which excerise?
Rex Smith Jr.
@rsmith731
Mar 19 2016 01:09
"Convert Celsius to Fahrenheit" @demipixel
demipixel
@demipixel
Mar 19 2016 01:10
@tarwater You need a callback. Something like:
turnRound(c, function(input) {
  alert('Input is ' + input);
});
@rsmith731 What's the issue?
Clay Holt
@tarwater
Mar 19 2016 01:10
i don't understand how you build games in javascript if you cant wait for user input
everything turns into an infinite loop
Rex Smith Jr.
@rsmith731
Mar 19 2016 01:10
@demipixel not sure exactly what I am doing or where to start
demipixel
@demipixel
Mar 19 2016 01:10
@tarwater Well, you can run funtions on an input. For example:
@tarwater
$('#hello').hover(function() {
  // Do something when they hover over #hello
});
@rsmith731 You read the sidebar?
Malcolm
@noinkling
Mar 19 2016 01:11
@tarwater You can wait, it's just that JS is an async language, so you need to use callbacks when you make an async call
Clay Holt
@tarwater
Mar 19 2016 01:12
that's what i tried. i have my return statement inside a .click(function())
demipixel
@demipixel
Mar 19 2016 01:12
@tarwater If I have an alert immediately after than .hover line, it will be called immediately. However, the function PASSED will not be called until you hover
Rex Smith Jr.
@rsmith731
Mar 19 2016 01:12
@demipixel yes, not really understanding, but i'm gonna try and if i get stuck are you willing to help?
demipixel
@demipixel
Mar 19 2016 01:12
@tarwater Returning inside of a .click will do nothing
Can somebody take over, I have to go to dinner? :S
@rsmith731 Yeah but din haha
Clay Holt
@tarwater
Mar 19 2016 01:12
this is mindboggling
Rex Smith Jr.
@rsmith731
Mar 19 2016 01:13
@demipixel lol ok no problem
demipixel
@demipixel
Mar 19 2016 01:13
@tarwater Like...
$(element).click(function() {
  alert('Hello');
  return 4;
});
@tarwater You CAN return 4, but .click won't do anything with it
Clay Holt
@tarwater
Mar 19 2016 01:13
yes. that's what im doing
i understand
demipixel
@demipixel
Mar 19 2016 01:13
Alright
cya guys, hopefully somebody can pick up haha
Clay Holt
@tarwater
Mar 19 2016 01:13
i want to call that function a 2nd time, but only after the return statement is reached
demipixel
@demipixel
Mar 19 2016 01:13
@tarwater What does the function do?
Clay Holt
@tarwater
Mar 19 2016 01:14
it lets the user choose where to put an 'X' on a tic tac toe board
ive used while loops and for-loops and recursion
but nothing gets executed in order
i guess i gotta read up on this asynchronous thing
demipixel
@demipixel
Mar 19 2016 01:15
Yeah
i can look it over with you in like 20min if you want
yelsneH
@yelsneh
Mar 19 2016 01:15
I don't understand how I can possibly slice arrays and keep the data I cut out
Clay Holt
@tarwater
Mar 19 2016 01:15
go to dinner, thanks
yelsneH
@yelsneh
Mar 19 2016 01:15
It's so confusing
Clay Holt
@tarwater
Mar 19 2016 01:15
i'll work it out
demipixel
@demipixel
Mar 19 2016 01:16
@yelsneh
Moisés Man
@moigithub
Mar 19 2016 01:16
function pickChoice(){
 ... do something
}
$(element).click(function() {
   pickChoice();
});
something like this probably ?
then u can call pickChoice() from other parts of ur code...as many times as u want...
Malcolm
@noinkling
Mar 19 2016 01:16
@yelsneh slice doesn't modify the original array
yelsneH
@yelsneh
Mar 19 2016 01:16
u w0t
Eduardo A. González Robles
@GonzandRobles
Mar 19 2016 01:16
How do I paste the code format here?
Malcolm
@noinkling
Mar 19 2016 01:16
If you wanted to do that you could use splice instead
demipixel
@demipixel
Mar 19 2016 01:16
@moigithub @moigithub you can also do
yelsneH
@yelsneh
Mar 19 2016 01:17
Still I think this is my ceiling as far as programming
demipixel
@demipixel
Mar 19 2016 01:17
$(element).click(pickChoice)
yelsneH
@yelsneh
Mar 19 2016 01:17
I think this kind of thing is what finishes this experiment for me
demipixel
@demipixel
Mar 19 2016 01:17
Awwew
yelsneH
@yelsneh
Mar 19 2016 01:17
I can't even functionally understand where to start
like I can'
I can't comprehend the logic required to complete this
Malcolm
@noinkling
Mar 19 2016 01:18
@yelsneh Chunky Monkey?
yelsneH
@yelsneh
Mar 19 2016 01:18
yea
I really just don't get it
Malcolm
@noinkling
Mar 19 2016 01:19
@yelsneh Take it step-by-step
First you want a new array
which will be the thing you return eventually
Then you wanna loop over the original array in steps of whatever size was provided
Andrew Charlebois
@andrewchar
Mar 19 2016 01:20
having two problems im not sure how to fix. 1. loop is not stopping when i want it to (<=num) and two its doing math weird... part of the console log is [0, 1, 1, 3, 5, 7, 9, 11, 13]
function sumFibs(num) {


  var finalNum = 0;


  var fibNum = [0,1];

  while (fibNum.length-1 <= num) {
    fibNum.push((fibNum.length-2) + (fibNum.length-1));
    console.log(fibNum);
  } if ((fibNum.length-1) % 2 !== 0) {
    finalNum += fibNum.length-1;
  }


  //console.log(fibNum);
  return finalNum;



}

sumFibs(1);
demipixel
@demipixel
Mar 19 2016 01:21
@andrewchar remeber it also logs for all the tests
Rex Smith Jr.
@rsmith731
Mar 19 2016 01:21
i need some help with the Convert Celsius to Fahrenheit exercise
demipixel
@demipixel
Mar 19 2016 01:21
Not just the one in the code
Rex Smith Jr.
@rsmith731
Mar 19 2016 01:21
i got one of them correct, but not the others
Malcolm
@noinkling
Mar 19 2016 01:21
@yelsneh On each iteration you need to get the appropriate number of elements starting from the current index using slice (the "hard" part), then push them onto your new array
NathanielPowers
@NathanielPowers
Mar 19 2016 01:22
This message was deleted
Moisés Man
@moigithub
Mar 19 2016 01:22
@andrewchar IIRC its not about how many numbers u generate (length) but how "big" the number is...
so ur condition should be..
while (lastNumberUGenerate <=num )
Andrew Charlebois
@andrewchar
Mar 19 2016 01:23
@moigithub is that not what im doing?
(fibNum.length-1 <= num)
Moisés Man
@moigithub
Mar 19 2016 01:23
nope u checking the Array legnth....
so.. if fibNum = [1,2,3,4,5,6,7,8,1000,13213]
lenght = 10
but lastNumGenerated = 13213
@andrewchar
Peter
@xor4
Mar 19 2016 01:26

@xor4
Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed.

function queue(arr, item) {
// Your code here

return item; // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Can anyone help me
I've no idea what to do here.

Moisés Man
@moigithub
Mar 19 2016 01:28
@xor4 ur function have 2 "variables" arr and item
u need to use shift and push methods
to add the item on the array.. and
extract and return the first element of the array
Peter
@xor4
Mar 19 2016 01:33
thanks @moigithub
CamperBot
@camperbot
Mar 19 2016 01:33
xor4 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 764 | @moigithub | http://www.freecodecamp.com/moigithub
Phenoix8
@Phenoix8
Mar 19 2016 01:38
does anyone know how to to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.
Mick Muzac
@mickmuzac
Mar 19 2016 01:42
Aren't you looking for simple string concatenation?
demipixel
@demipixel
Mar 19 2016 01:44
Back
Phenoix8
@Phenoix8
Mar 19 2016 01:48

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

// Your code above this line
return result;
}

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

thats the code i was given and does anyone know how to format a code
Dan Gallegos
@gallegos20
Mar 19 2016 01:50
maybe someone can help me out with this
use js <insert code here>
` jd --- `
lol oh man
Ken Haduch
@khaduch
Mar 19 2016 01:53
@emilaasa - :point_up: March 18, 2016 2:05 PM - that's great! I like regular expressions. You could probably avoid the intermediate variables but it doesn't add too much confusion in there. Glad that it worked out!
Hugo
@monkora
Mar 19 2016 02:02
Hi all
Ken Haduch
@khaduch
Mar 19 2016 02:04

@Phenoix8 - what do you think is the right thing to do with this? You need to generate a sentence, so you are going to compose this by concatenating the words that are sent into the function - they give guidelines in the text of the problem, and additionally in the test results.

Basically, you should know the concatenation operator for strings +, and the assignment operator for variables =, and they indicate using non-word characters to separate the words - something like a space. Those four words that are contained within the parentheses could be used to generate a sentence such as "the big dog ran quickly". Each of the variables in the function definition myNoun, myAdjective, etc. matches one-for-one with the values where the function is invoked, so that within the function myNoun can be used where you want to insert the word "dog", myAdjective where you want the word "big", etc. So you are creating the contents in that variable result, you just have to concatenate the words and separate by spaces, then the code is set up to return result... as they said, they'll check the result that you return and make sure that the words that they gave you to use are contained in the resulting sentence.

without actually writing the code for you, I hope that gives you some help?

Hugo
@monkora
Mar 19 2016 02:06
I'm trying to use a click event to return a function, or otherwise exit it. I'm not sure it's possible to implement, does anyone have ideas?
demipixel
@demipixel
Mar 19 2016 02:06
@monkora What do you mean?
Michael Suchorolski
@mikesuchor
Mar 19 2016 02:09

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

// Only change code below this line

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

result=table[val];

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

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

That worked but is there a better way to do it?
Hugo
@monkora
Mar 19 2016 02:09
@demipixel I have a game in function game () {}
@demipixel and I have an on/off switch. When turning on, it executes the game function. I'm trying to figure out a way to kill the game when the switch is turned off.
bitgrower
@bitgrower
Mar 19 2016 02:11
@mikesuchor -- not sure how you would make it simpler... :)
demipixel
@demipixel
Mar 19 2016 02:11
@monkora Well, what's considered "the game is on"?
Depending on the game, you might have an update function that constantly gets called
Michael Suchorolski
@mikesuchor
Mar 19 2016 02:12
@bitgrower thanks, I was messing around with it for 10 minutes, adding code throwing out code, got that to work finally
CamperBot
@camperbot
Mar 19 2016 02:12
mikesuchor sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 887 | @bitgrower | http://www.freecodecamp.com/bitgrower
Hugo
@monkora
Mar 19 2016 02:12
@mikesuchor You could skip var result = ""; and result = table[val]
@mikesuchor return table[val] would do the same thing :)
bitgrower
@bitgrower
Mar 19 2016 02:12
true ... I was thinking in terms of algorithmically ...
@mikesuchor -- that kind of object access is your FRIEND ... big time ...
When you can go to an object and just say ... "Hey, do you have a property (key) with this name? You do? Then would you please give me it's value?"
Hugo
@monkora
Mar 19 2016 02:15
@demipixel I have a flag for whether the game is on or off.
Michael Suchorolski
@mikesuchor
Mar 19 2016 02:15
yeah looks better, I was going by their notes only changing code above and below
thought it looked a little messy though
Hugo
@monkora
Mar 19 2016 02:16
@demipixel the only way I can think of is to put a bunch of checks throughout the game code. if (gameOn = false) return;
@demipixel But that seems messy
Francis
@Francis-p
Mar 19 2016 02:17
need so help guys! :smile:
function rot13(str) { // LBH QVQ VG!
  var splitStr = str.split("");
  var ciphers = [];
  for (var i = 0; i < splitStr.length; i++) {
    var atStr = splitStr[i].charCodeAt();
    if (atStr != 32) {
      if (atStr >= 65 && atStr <= 77) {
        atStr += 13;
      }
      else if (atStr >= 77 && atStr <= 90) {
        atStr -= 13;
      }
      var fromStr;
      fromStr.fromCharCode(atStr); //how to use fromCharCode()???
      ciphers.push(fromStr);
    }
    else {
      ciphers.push(atStr);
    }

  }
  return ciphers;
}
//A-65 M-77 space is 32
// Change the inputs below to test
rot13("SERR PBQR PNZCZ");
demipixel
@demipixel
Mar 19 2016 02:17
@monkora Eh, that's mostly how you do it
Although you meant == false haha
not one =
Hugo
@monkora
Mar 19 2016 02:17
@demipixel Ah yep :)
@demipixel Hmmm there must be a better way. Unless I put the check after every line of code... the game would keep running after I hit the off key
Francis
@Francis-p
Mar 19 2016 02:20
how do i use .fromCharCode() ?
bitgrower
@bitgrower
Mar 19 2016 02:20
you need to capture the return value, @Francis-p

myChar = fromCharCode(atStr)

...

Hugo
@monkora
Mar 19 2016 02:21
@Francis-p @bitgrower that won't do it.
Francis
@Francis-p
Mar 19 2016 02:21
@bitgrower roger that!
@monkora ???
Hugo
@monkora
Mar 19 2016 02:22
@Francis-p @bitgrower You need to do myChar = String.fromCharCode(atStr);
bitgrower
@bitgrower
Mar 19 2016 02:22
hahaha ... maybe not ... just off the top of my head ... I usually have to re-look these things up ...
thanks @monkora
CamperBot
@camperbot
Mar 19 2016 02:22
bitgrower sends brownie points to @monkora :sparkles: :thumbsup: :sparkles:
Francis
@Francis-p
Mar 19 2016 02:22
@monkora what is string?
CamperBot
@camperbot
Mar 19 2016 02:22
:star: 302 | @monkora | http://www.freecodecamp.com/monkora
Francis
@Francis-p
Mar 19 2016 02:22
@bitgrower no worries!
Hugo
@monkora
Mar 19 2016 02:22
@Francis-p The String object
@Francis-p fromCharCode is a property/method of the String object
Francis
@Francis-p
Mar 19 2016 02:23
@monkora so in order for it to work i need to have 2 string object?
Bryan Castleman
@castlemaninc
Mar 19 2016 02:23
How do I post code from one of the algorithm challenges?
Hugo
@monkora
Mar 19 2016 02:23
@Francis-p If you just say fromCharCode that implies it's a property of the global object.
bitgrower
@bitgrower
Mar 19 2016 02:23
  1. one line, with nothing else on it except this: ```js
  2. paste your code in
  3. one line, with nothing else on it but ```
Bryan Castleman
@castlemaninc
Mar 19 2016 02:26
My code in 'Sum All Numbers in a Range'
returns the correct answers but doesn't pass. Can you help?
var myArray = [];
function sumAll(arr) {
 var a = Math.min(arr[0],arr[1]);
 var b = Math.max(arr[0],arr[1]);

 for(i=0; i<=b-a; i++){
    myArray.push(a + i);

 }

 var total = myArray.reduce(function(a, b) {
  return a+b;
 });

  return total;
 }

sumAll([1,4]);
@bitgrower thanks
CamperBot
@camperbot
Mar 19 2016 02:26
castlemaninc sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 888 | @bitgrower | http://www.freecodecamp.com/bitgrower
Hugo
@monkora
Mar 19 2016 02:27
@castlemaninc Could you link to the challenge?
@castlemaninc Never mind I've found it
Mick Muzac
@mickmuzac
Mar 19 2016 02:27
This message was deleted
Francis
@Francis-p
Mar 19 2016 02:28
@monkora what’s wrong with my else statement?
function rot13(str) { // LBH QVQ VG!
  var splitStr = str.split("");
  var ciphers = [];
  for (var i = 0; i < splitStr.length; i++) {
    var fromStr;
    var atStr = splitStr[i].charCodeAt();
    if (atStr != 32) {
      if (atStr >= 65 && atStr <= 77) {
        atStr += 13;
      }
      else if (atStr >= 77 && atStr <= 90) {
        atStr -= 13;
      }
      fromStr = String.fromCharCode(atStr); //how to use fromCharCode()???
      ciphers.push(fromStr);
    }
    else {
      fromStr = String.formCharCode(atStr);
      ciphers.push(fromStr);
    }

  }
  return ciphers;
}
//A-65 M-77 space is 32
// Change the inputs below to test
rot13("SERR PBQR PNZCZ”);
Mick Muzac
@mickmuzac
Mar 19 2016 02:29
@Francis-p we need more details.
From the looks of it, your else only runs when atStr is 32
Francis
@Francis-p
Mar 19 2016 02:29
@mickmuzac caesars cipher
yes. i only need it to return
Mick Muzac
@mickmuzac
Mar 19 2016 02:30
Right. But what is your specific question?
Francis
@Francis-p
Mar 19 2016 02:30
typeerror: String.formCharCode is not a function
my bad
typo
rphares
@rphares
Mar 19 2016 02:31
This message was deleted
Francis
@Francis-p
Mar 19 2016 02:32
@mickmuzac @monkora @bitgrower thanks!
CamperBot
@camperbot
Mar 19 2016 02:32
francis-p sends brownie points to @mickmuzac and @monkora and @bitgrower :sparkles: :thumbsup: :sparkles:
Hugo
@monkora
Mar 19 2016 02:32
@castlemaninc Just taking a look
CamperBot
@camperbot
Mar 19 2016 02:32
:star: 303 | @monkora | http://www.freecodecamp.com/monkora
:star: 889 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 10 | @mickmuzac | http://www.freecodecamp.com/mickmuzac
Eduardo A. González Robles
@GonzandRobles
Mar 19 2016 02:38
This message was deleted
This message was deleted
Hugo
@monkora
Mar 19 2016 02:39
@castlemaninc You need myArray inside the function.
Eduardo A. González Robles
@GonzandRobles
Mar 19 2016 02:40
This message was deleted
Hugo
@monkora
Mar 19 2016 02:40
@castlemaninc Because it's outside, each successive call on the function isn't resetting it, so you end up with [1, 2, 3, 4, 1, 2, 3, 4]
Eduardo A. González Robles
@GonzandRobles
Mar 19 2016 02:40
Hi guys I still dont know what to do in this exercise
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber;       // Change this Line
var player = testObj;   // Change this Line
I need to Access Objects Properties with Variables
Hugo
@monkora
Mar 19 2016 02:41
@GonzandRobles What's the name of the exercise?
Eduardo A. González Robles
@GonzandRobles
Mar 19 2016 02:41
Accessing Objects Properties with Variables
Mick Muzac
@mickmuzac
Mar 19 2016 02:42
Assign a valid number to playerNumber then access the player by doing player[playerNumber]
Kyle Annen
@kyle-annen
Mar 19 2016 02:42
@GonzandRobles assign 12 to the playerNumber (or whatever number it wants you too. The point is retrieving a value from object using a value saved to the variable playerNumber
bitgrower
@bitgrower
Mar 19 2016 02:42
@GonzandRobles -- you may want to review the previous challenges using objects ...
Kyle Annen
@kyle-annen
Mar 19 2016 02:43
then on the next line use the playerNumber variable to call the pair
waynehall
@waynehall
Mar 19 2016 02:43
I over-engineered the mutations exercise under basic algorithm scripting. Not sure why it isn't working, but I think it has to do with nesting a for loop in a for loop. Can anyone explain why it isn't?
Hugo
@monkora
Mar 19 2016 02:43
@GonzandRobles See all of the above!
waynehall
@waynehall
Mar 19 2016 02:44

function mutation(arr) {
var tf = true;
var str1 = arr[0].toLowerCase();
var str2 = arr[1].toLowerCase();
var array1 = str1.split("");
var array2 = str2.split("");
var total = 0;
for (var i = 0; i<=array2.length; i++){
for (var o = 0; o<=array1.length; o++){
if (array1[i] == array2[o]){
total +=1;

  }
}

}
if (total >= arr[1].length){
return true;
}else {
return false;
}
}

mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);

bitgrower
@bitgrower
Mar 19 2016 02:44
@monkora -- I think the challenge is this one: Access Objects Properties with Variables
Bryan Castleman
@castlemaninc
Mar 19 2016 02:44
@monkora Okay. Sorry, I was eating dinner. Okay let me go back and see if I can understand that. I'll get back to you.
Hugo
@monkora
Mar 19 2016 02:44
@waynehall Could you repaste that with on an empty line at the beginning of your code and on an empty code at the end?
@castlemaninc Cool, let me know if you need more help
bitgrower @bitgrower probably did mutations with arrays ... but thinks it's probably possible to do it strictly with strings ..
Hugo
@monkora
Mar 19 2016 02:45
@waynehall "```"
@waynehall at beginning and "```" at end
Eduardo A. González Robles
@GonzandRobles
Mar 19 2016 02:45
Thanks to all of you
waynehall
@waynehall
Mar 19 2016 02:45

'''
function mutation(arr) {
var tf = true;
var str1 = arr[0].toLowerCase();
var str2 = arr[1].toLowerCase();
var array1 = str1.split("");
var array2 = str2.split("");
var total = 0;
for (var i = 0; i<=array2.length; i++){
for (var o = 0; o<=array1.length; o++){
if (array1[i] == array2[o]){
total +=1;

  }
}

}
if (total >= arr[1].length){
return true;
}else {
return false;
}
}

mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);
'''

CamperBot
@camperbot
Mar 19 2016 02:46
:bulb: to format code use backticks! ``` more info
Bryan Castleman
@castlemaninc
Mar 19 2016 02:46
@monkora I totally understand your answer, now that I look at it. I should have walked myself through it step by step. There are kids outside my window singing, so I'll just blame them. Ha ha.
Hugo
@monkora
Mar 19 2016 02:46
@waynehall Right idea! But backticks not apostrophes. (usually the left of your 1 key, under escape)
@castlemaninc no problem :)
@castlemaninc Also one suggestion
waynehall
@waynehall
Mar 19 2016 02:46

```function mutation(arr) {
var tf = true;
var str1 = arr[0].toLowerCase();
var str2 = arr[1].toLowerCase();
var array1 = str1.split("");
var array2 = str2.split("");
var total = 0;
for (var i = 0; i<=array2.length; i++){
for (var o = 0; o<=array1.length; o++){
if (array1[i] == array2[o]){
total +=1;

  }
}

}
if (total >= arr[1].length){
return true;
}else {
return false;
}
}

mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);```

Bryan Castleman
@castlemaninc
Mar 19 2016 02:46
@monkora , yes anything.
waynehall
@waynehall
Mar 19 2016 02:47
I'm bad at this :-(
Hugo
@monkora
Mar 19 2016 02:47
@waynehall Just like that, but the "```" need to be on their own lines.
waynehall
@waynehall
Mar 19 2016 02:47
function mutation(arr) {
  var tf = true;
  var str1 = arr[0].toLowerCase();
  var str2 = arr[1].toLowerCase();
  var array1 = str1.split("");
  var array2 = str2.split("");
  var total = 0;
  for (var i = 0; i<=array2.length; i++){
   for (var o = 0; o<=array1.length; o++){
     if (array1[i] == array2[o]){
        total +=1;

      }
    }
  }
  if (total >= arr[1].length){
    return true;
  }else {
    return false;
  }  
}

mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);
Hey there we go.
Hugo
@monkora
Mar 19 2016 02:48
@waynehall Huzzah!
@castlemaninc I think your for loop would be better like this
 for(var i = a; i <= b; i++){
  myArray.push(i); 
 }
@waynehall Alright, what was the issue again?
Bryan Castleman
@castlemaninc
Mar 19 2016 02:50
@monkora yes, that looks cleaner and makes more sense. Thanks for your help with my code.
CamperBot
@camperbot
Mar 19 2016 02:50
castlemaninc sends brownie points to @monkora :sparkles: :thumbsup: :sparkles:
:star: 304 | @monkora | http://www.freecodecamp.com/monkora
Hugo
@monkora
Mar 19 2016 02:50
@waynehall What's the challenge name also?
samamsam
@samsamam
Mar 19 2016 02:51
Hi Coders I am having a problem in my code it is not giving the output as expected my code below please take a look thanks
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = myPlants.type[1].list[1]; // Change this line
waynehall
@waynehall
Mar 19 2016 02:51
Think I'm supposed to use .indexOf() to look up letters and check if they are in another string. Challenge name is Mutations under basic algorithm. I over engineered it i think and i'm determined to make my solution work lol
samamsam
@samsamam
Mar 19 2016 02:51
its from Accessing Nested Arrays in JSON
waynehall
@waynehall
Mar 19 2016 02:52
but for some reason, the sample "mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]) should return true. " is the only one that isn't passing
Mick Muzac
@mickmuzac
Mar 19 2016 02:52
@samsamam Your nesting is incorrect.
waynehall
@waynehall
Mar 19 2016 02:52
I can't figure out why it isn't passing and it is making me crazy, all the others work.
Hugo
@monkora
Mar 19 2016 02:52
@waynehall Alright just give me a couple of minutes to take a look
Mick Muzac
@mickmuzac
Mar 19 2016 02:53
@samsamam Or, it looks like the nesting is correct (because it's given), but the way you're accessing the properties is wrong.
Remember, myPlants is an array, but type is not.
samamsam
@samsamam
Mar 19 2016 02:54
var secondTree = myPlants1.type.list1; tried this as well @mickmuzac
myPlants [].type.list[] @mickmuzac tried this as well
Mick Muzac
@mickmuzac
Mar 19 2016 02:55
What exactly are you trying to get?
samamsam
@samsamam
Mar 19 2016 02:55
@mickmuzac Retrieve the second tree from the variable myPlants using object dot and array bracket notation.
@mickmuzac from the topic Accessing Nested Arrays in JSON in Javascript codecamp
Mick Muzac
@mickmuzac
Mar 19 2016 02:56
Instead of just giving you the answer, let's work through this.
samamsam
@samsamam
Mar 19 2016 02:56

@mickmuzac ```
// Setup
// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

// Only change code below this line

var secondTree = myPlants[1].type.list[1]; // Change this line

```
i have this now

Mick Muzac
@mickmuzac
Mar 19 2016 02:56
@samsamam myPlants is an array, correct? How do you get the second element in that array?
Hugo
@monkora
Mar 19 2016 02:57
@waynehall Quite the work around you've made there! I would look at the String.indexOf and String.includes methods to create a more concise solution
waynehall
@waynehall
Mar 19 2016 02:57
haha
but
:-(
Hugo
@monkora
Mar 19 2016 02:57
@waynehall I'm having trouble seeing why yours doesn't work on that string though hmmmmm
samamsam
@samsamam
Mar 19 2016 02:57
myPlants[2] @mickmuzac
oh
waynehall
@waynehall
Mar 19 2016 02:58
the only thing i can think of is this: do for nested loops go concurrently?
samamsam
@samsamam
Mar 19 2016 02:58
i mean myPlants[1]
Mick Muzac
@mickmuzac
Mar 19 2016 02:58
Correct. Now you have an object that has a type property, which is a String, and a list property, which is an array.
Hugo
@monkora
Mar 19 2016 02:58
@waynehall How do you mean?
Mick Muzac
@mickmuzac
Mar 19 2016 02:58
What you want is the second tree from list, correct?
How would you get that?
Dustin
@Key-Banger
Mar 19 2016 02:59
@mickmuzac myPlants looks like an object. Similar to an array, but different.
waynehall
@waynehall
Mar 19 2016 03:00
@monkora was trying to figure out why that string in particular is giving it fits, "total" is registering 1.
samamsam
@samsamam
Mar 19 2016 03:00
myPlants1.type.list1; @mickmuzac
Mick Muzac
@mickmuzac
Mar 19 2016 03:01
That's incorrect because type is a String.
waynehall
@waynehall
Mar 19 2016 03:01
@monkora , I just can't think of anything special about that single one that would break my total count. thought maybe that since the first instance (q) is after the rest that it counts might somehow be related but nothing i can think of makes sense.
Mick Muzac
@mickmuzac
Mar 19 2016 03:01
@samsamam If you do myPlants[1].type what you get is the string "trees"
samamsam
@samsamam
Mar 19 2016 03:02
myPlants[1].list[1];
@mickmuzac
Mick Muzac
@mickmuzac
Mar 19 2016 03:02
Correct!!
samamsam
@samsamam
Mar 19 2016 03:03
@mickmuzac thanks it works
CamperBot
@camperbot
Mar 19 2016 03:03
samsamam sends brownie points to @mickmuzac :sparkles: :thumbsup: :sparkles:
:star: 11 | @mickmuzac | http://www.freecodecamp.com/mickmuzac
Mike Kennedy
@mikennedy9
Mar 19 2016 03:05
hey can anyone explain javascript multidimensional arrays to me? Here is the example I'm trying to figure out why arr[1][2]; =6 and arr[3][0[1]; = 11.. var arr = [
[1,2,3],
[4,5,6],
[7,8,9],
[[10,11,12], 13, 14]
];
arr[0]; // equals [1,2,3]
arr[1][2]; // equals 6
arr[3][0][1]; // equals 11
Mick Muzac
@mickmuzac
Mar 19 2016 03:05
@Key-Banger I missed your message. In that last example, myPlants was an array of objects.
Hugo
@monkora
Mar 19 2016 03:05
@waynehall I have the feeling your for loops are broken somehow, and working by chance on some of those others
Dayne Wright
@daynewright
Mar 19 2016 03:06
@mikennedy9 Remeber that arrays are 0 based
Mike Kennedy
@mikennedy9
Mar 19 2016 03:07
yes, @Daynewr i got that arr[0]=[1,2,3] but arr[1][2]; and arr[3]0 are confusing me
arr[3][0][1]*
waynehall
@waynehall
Mar 19 2016 03:08
@monkora That is what I'd guess as well. Like I said, it was a bit over engineered and seems fundamentally flawed but I can't think of why that single string is breaking it. I'd love to know to understand for loops a bit better.
Dustin
@Key-Banger
Mar 19 2016 03:08
@mickmuzac no worries. I think I jumped into a middle of a conversation.
Hugo
@monkora
Mar 19 2016 03:08
@waynehall for starters you have your loops set up like this
```
for(var i = 0; i <= arr.length; i++)
@waynehall you want i < arr.length not less than or equal to
@waynehall Array.length is 1 indexed, whereas arrays themselves are 0 indexed.
Dayne Wright
@daynewright
Mar 19 2016 03:10
@mikennedy9 In a multidimensional array the first number is the array you are looking at and the second is the location in that array.
Mick Muzac
@mickmuzac
Mar 19 2016 03:11
@mikennedy9 whenever you're stuck, you should try breaking down the problem into smaller sub-problems. If I did var foo = arr[1]; what would foo be?
Hugo
@monkora
Mar 19 2016 03:14
@waynehall Also if you look at your loop you see that in the if statement if (array1[i] == array2[o]){
@waynehall it should be array1[o] === array2[i]
Mike Kennedy
@mikennedy9
Mar 19 2016 03:15
@Daynewr so with arr[1][2] the [1]= ([4,5,6]) and for the [2] I would count 0=4,1=5,2=6? that makes sense but then what about arr[3][0][1]? [3] = [10,11,12] but how does the [0] and [2] come into play to make 11?
Dayne Wright
@daynewright
Mar 19 2016 03:16
@mikennedy9 because you have a nested array
Mike Kennedy
@mikennedy9
Mar 19 2016 03:17
ah so the [3] is just the position in the overall array, the [0] is the position in the nested array and the 1 is the position in the specific array?
Mick Muzac
@mickmuzac
Mar 19 2016 03:18
Yes.
It'd be easier to understand if you broke it down into 3 variable assignments.
Mike Kennedy
@mikennedy9
Mar 19 2016 03:18
brilliant. thanks @Daynewr and thanks @mickmuzac
CamperBot
@camperbot
Mar 19 2016 03:18
mikennedy9 sends brownie points to @daynewr and @mickmuzac :sparkles: :thumbsup: :sparkles:
:star: 323 | @daynewr | http://www.freecodecamp.com/daynewr
:star: 12 | @mickmuzac | http://www.freecodecamp.com/mickmuzac
Mike Kennedy
@mikennedy9
Mar 19 2016 03:19
yes, @mickmuzac I can see that now thank you
CamperBot
@camperbot
Mar 19 2016 03:19
mikennedy9 sends brownie points to @mickmuzac :sparkles: :thumbsup: :sparkles:
:warning: mikennedy9 already gave mickmuzac points
Dayne Wright
@daynewright
Mar 19 2016 03:19
no problem!
Hugo
@monkora
Mar 19 2016 03:20
@waynehall This works for zyxw... qrstu
for (var i = 0; i < array1.length; i++){
   for (var o = 0; o < array2.length; o++){
     if (array1[i] == array2[o]){
        total++;
      }
    }
  }
crakapps
@crakapps
Mar 19 2016 03:22

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

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

}

// Test your code by modifying these values
checkObj("gift");
maybe its too late for me to try but i did and im stuck until tomororw unless someoen wants to point somethingouti missed

Hugo
@monkora
Mar 19 2016 03:23
@crakapps What's not working?
@crakapps Also what is the challenge name?
cannelflow
@cannelflow
Mar 19 2016 03:24
@crakapps which exercise?
Mick Muzac
@mickmuzac
Mar 19 2016 03:24
This message was deleted
crakapps
@crakapps
Mar 19 2016 03:24
@monkora @cannelflow Testing Objects for Properties
Mick Muzac
@mickmuzac
Mar 19 2016 03:24
Disregard prior message, totally wrong
myObj.checkProp should be myObj[checkProp]
crakapps
@crakapps
Mar 19 2016 03:25
@monkora retrun nothing
cannelflow
@cannelflow
Mar 19 2016 03:25
here return myObj.checkProp; checkProp is variable so do like myObj[checkProp] rest looks good @crakapps
Hugo
@monkora
Mar 19 2016 03:26
@crakapps What they said!
crakapps
@crakapps
Mar 19 2016 03:26
ok thx
@monkora @cannelflow ok thx
cannelflow
@cannelflow
Mar 19 2016 03:26
@crakapps and you need to return "Not Found" not like return "not found";
Marek Slabicki
@thaniri
Mar 19 2016 03:34

hey, can anyone explain why this loop stops at 2 iterations and not 4?

function drop(arr, func) {

  var holder = arr;//holds arr so the loop doesnt hurt itself

  for (var i = 0; i < arr.length ; i++){//loop the length of arr
    if (!func(arr[0])){ //if arr[0] returns false in the equation
      holder.shift();//remove arr[0]
    }
  }

  return holder;
}

drop([1, 2, 3, 4], function(n) {return n > 5;});

A solution is to make var length = arr.length; and then i < length; but I dont understand why that is the case

bitgrower
@bitgrower
Mar 19 2016 03:34
because you are shifting the values off the array so the length of the array changes ... .
holder simply points to the same place as arr
if you want to make a copy of the array, use something like .slice()
Mick Muzac
@mickmuzac
Mar 19 2016 03:36
@bitgrower is exactly right. You can choose to either copy the array or save the length of the array to a variable before the for-loop.
bitgrower
@bitgrower
Mar 19 2016 03:36
(arr.length gets re-evaluated at every turn of the loop ... if you want to use a non-changing value, you need to create a variable to hold the length in ...
Marek Slabicki
@thaniri
Mar 19 2016 03:36
ah okay, second time explaining it made more sense
thanks @bitgrower @mickmuzac
CamperBot
@camperbot
Mar 19 2016 03:37
thaniri sends brownie points to @bitgrower and @mickmuzac :sparkles: :thumbsup: :sparkles:
:star: 890 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 13 | @mickmuzac | http://www.freecodecamp.com/mickmuzac
Marek Slabicki
@thaniri
Mar 19 2016 03:37
didnt know that the length would be re-evaluated
strange
i thought for loops would evaluate the # of iterations first, then execute the code within the {} until that number is reached
Mick Muzac
@mickmuzac
Mar 19 2016 03:38
For loops have to re-evaluate the condition at the end of every iteration to know whether or not it's false.
bitgrower
@bitgrower
Mar 19 2016 03:39
@thaniri -- neither did I, until I dealt with the problem in a piece of code I was working on ... welcome to the club ...
well, yes, @mickmuzac -- but you might assume it's only re-evaluating your loop variable
Mick Muzac
@mickmuzac
Mar 19 2016 03:40
that's what you can do things like this: for(; fiveTrues();) where fiveTrues returns true 5 times.
bitgrower
@bitgrower
Mar 19 2016 03:42
LOL ... what a way to write obfuscated code ...
Mick Muzac
@mickmuzac
Mar 19 2016 03:42
LOL!!
bitgrower
@bitgrower
Mar 19 2016 03:43
I like that ... I think I'll use that when i want to obfuscate some code ... will drive neophytes crazy ...
Mick Muzac
@mickmuzac
Mar 19 2016 03:43
It's funny how programming works. If I did the same with a while loop, my intentions would be as clear as day.
bitgrower
@bitgrower
Mar 19 2016 03:44

... "Hey, what does THAT do, I've never seen a code construct like that..."

...thanks for illuminating that little corner of js

Mick Muzac
@mickmuzac
Mar 19 2016 03:44
It's not just JS... C-like languages that support for loops support that syntax.
Initial and final expressions are options.
Dayne Wright
@daynewright
Mar 19 2016 03:45
So this is valid? for(; fiveTimes();)
Mick Muzac
@mickmuzac
Mar 19 2016 03:45
Yes
sic-f
@sic-f
Mar 19 2016 03:45
hi guys
how do you solve if a and b are less than zero, return undefined?
Dayne Wright
@daynewright
Mar 19 2016 03:45
How does that work exactly?
sic-f
@sic-f
Mar 19 2016 03:45
what is the code for it?
bitgrower
@bitgrower
Mar 19 2016 03:46

LOL ... stuff like that makes great fodder for interview questions ...

is this a valid c statement?

6;

Mick Muzac
@mickmuzac
Mar 19 2016 03:49
@Daynewr test it out for yourself
var count = 0;
function fiveTimes(){
    count++;
    if(count > 5) return false;
    else return true;
}

for(; fiveTimes() ;){
    console.log("Hi!");
}
Marek Slabicki
@thaniri
Mar 19 2016 03:49
if((a+b)<0){return undefined;}
Mick Muzac
@mickmuzac
Mar 19 2016 03:49
If that second expression wasn't evaluated on each iteration of the loop, then doing that would result in an infinite loop.
Marek Slabicki
@thaniri
Mar 19 2016 03:50
looking at that actually upsets me mickmuzac
Mick Muzac
@mickmuzac
Mar 19 2016 03:50
var count = 0;
function fiveTimes(){
    count++;
    if(count > 5) return false;
    else return true;
}

while(fiveTimes()){
    console.log("Hi!");
}
Is that better?
Marek Slabicki
@thaniri
Mar 19 2016 03:50
wow amazing
:P
Dayne Wright
@daynewright
Mar 19 2016 03:50
@mickmuzac crazy
Mick Muzac
@mickmuzac
Mar 19 2016 03:51
Lol. This is far from crazy...
Especially in JS land... there are some truly crazy things out there.
Marek Slabicki
@thaniri
Mar 19 2016 03:51
eh, im a coding plebian, many things take my mind for a spin
Dayne Wright
@daynewright
Mar 19 2016 03:52
It makes it hard for me to get a strong grasp on all this if there is crazy in the normal :)
bitgrower @bitgrower thinks a lot of regular js can look pretty crazy ... hahahaha
Mick Muzac
@mickmuzac
Mar 19 2016 03:52
You guys wanna see something fun. :)
Dayne Wright
@daynewright
Mar 19 2016 03:52
oh no
bitgrower @bitgrower hears all the campers' braincells creaking ...
bitgrower @bitgrower is completely up for it ...
bitgrower
@bitgrower
Mar 19 2016 03:54
bring it on !!!
Dayne Wright
@daynewright
Mar 19 2016 03:54
I get the for loop now. You set no var in the loop and the increment and test are in the function you call, right?
Mick Muzac
@mickmuzac
Mar 19 2016 03:54
var a = Math.sqrt(-1);
if(a == a){
    console.log("Yay!!!");
} 
else{
    console.log("Huh?");
}
What do you guys think will happen?
Marek Slabicki
@thaniri
Mar 19 2016 03:55
reading it, Yay!!!
however, knowing imm probably wrong
Mick Muzac
@mickmuzac
Mar 19 2016 03:55
LOL!
Marek Slabicki
@thaniri
Mar 19 2016 03:55
it probably says "my shoes are gold"
Dayne Wright
@daynewright
Mar 19 2016 03:55
ha
Mick Muzac
@mickmuzac
Mar 19 2016 03:56
It will log "Huh?"
The trick here is that the square root of -1 returns NaN (not a number), because, well, it's not a real number. In JS, the only value that is never equal to itself is NaN
Marek Slabicki
@thaniri
Mar 19 2016 03:57
and NaN cant be compared using ==
Mick Muzac
@mickmuzac
Mar 19 2016 03:57
Correct.
Marek Slabicki
@thaniri
Mar 19 2016 03:57
i've come near insanity learning that little bit
Dayne Wright
@daynewright
Mar 19 2016 03:57
yeah
bitgrower
@bitgrower
Mar 19 2016 03:57
LOL ... I learned NaN is a number ...
Mick Muzac
@mickmuzac
Mar 19 2016 03:57
Yes!
NaN is in fact of type number!!!
bitgrower
@bitgrower
Mar 19 2016 03:58
thanks to the IEEE
Marek Slabicki
@thaniri
Mar 19 2016 03:58
"What's going on here? In JavaScript, NaN has the distinction of being the only value that is not equal to itself. That means we can't find out whether a value is NaN by checking equality to NaN because the answer will always be no."
Mick Muzac
@mickmuzac
Mar 19 2016 03:59
Correct.
M. Matthews
@mmatthews1981
Mar 19 2016 03:59
It's stuff like that that makes me hate javascript some days. Today included.
Marek Slabicki
@thaniri
Mar 19 2016 03:59
only way to check NaN is Number.isNaN(NaN);
as opposed to isNaN(NaN);
Mick Muzac
@mickmuzac
Mar 19 2016 04:00
But given that NaN is of type number and it's never equal to itself, can you think of a way to check whether or not something is NaN without using isNaN?
Marek Slabicki
@thaniri
Mar 19 2016 04:00
suicide is probably a valid option here
bitgrower
@bitgrower
Mar 19 2016 04:00
for me, it was the dynamic typing ... and the so-called OOP
sure ... if ( typeof n == number) & (! NaN == NaN)
Mick Muzac
@mickmuzac
Mar 19 2016 04:01
Too easy. :(
Brainteaser... assume a is a real number . When is a + 1 == a true?
I edited what I had. The brainteaser is correct!
Marek Slabicki
@thaniri
Mar 19 2016 04:09
what should i do on Steamroller to deal with variable levels of nesting? For example if an inputted array was 5 layers deep this wouldn't solve it, however it will solve anything 4 or less layers deep
function steamroller(arr) {

  var merged = [].concat.apply([], arr);
  var merged2 = [].concat.apply([], merged);
  var merged3 = [].concat.apply([], merged2);

  return merged3;
}

steamroller([1, [2], [3, [[4]]]]);
is there a way to detect how many levels of nesting there are>?
bitgrower
@bitgrower
Mar 19 2016 04:09
use recursion ... :)
Marek Slabicki
@thaniri
Mar 19 2016 04:09
i looked at your code @bitgrower and had no idea what was happening even with comments :)
bitgrower
@bitgrower
Mar 19 2016 04:11
you just keep going until Array.isArray is false, thaniri
Jenni
@silverrain64
Mar 19 2016 04:12
help Falsy Bouncer
CamperBot
@camperbot
Mar 19 2016 04:12

:point_right: algorithm falsy bouncer [wiki]

Problem Explanation:

Remove all falsy values from an array.

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

bitgrower
@bitgrower
Mar 19 2016 04:14
@silverrain ... the secret which can save you MANY hours of hair pulling can be found on the page talking about Boolean Objects ... at least when I got around to reading that page, it stopped my hours of angst and I solved it in minutes ...
Jenni
@silverrain64
Mar 19 2016 04:15
(sigh) I'll look again...
bitgrower
@bitgrower
Mar 19 2016 04:15
...of course, I also had a great tour of learning about NaN as a result of my hours of hair pulling ...
Marek Slabicki
@thaniri
Mar 19 2016 04:15
NaN was the fun one for me too
Jenni
@silverrain64
Mar 19 2016 04:15
Well, I made a side trip into regular expressions and filtering, but it hasn't paid off yet.
bitgrower
@bitgrower
Mar 19 2016 04:15
it taught me to take those helpful hints pages a LOT more seriously .... LOL ...
Marek Slabicki
@thaniri
Mar 19 2016 04:16
the word falsy is super important
bitgrower
@bitgrower
Mar 19 2016 04:16
@silverrain64 -- you can do the challenge in about 1 line ....
Marek Slabicki
@thaniri
Mar 19 2016 04:16
you shouldnt have to look at each option
many things are considered falsy
bitgrower
@bitgrower
Mar 19 2016 04:16
^^^^^^ that
Marek Slabicki
@thaniri
Mar 19 2016 04:17
bitgrower, i dont understand how your code on steamroller doesnt break after it enters the first nest
it enters the first nest, then checks if THAT can be flattened
but in example steamroller([1, [2], [3, [[4]]]]);
[2] cant be flattened
how does it exit back to the level above
bitgrower
@bitgrower
Mar 19 2016 04:18
it returns ... like any good recursive construct ... :)
@thaniri ... can you write finding a factorial recursively ?
Mick Muzac
@mickmuzac
Mar 19 2016 04:19
@bitgrower how long have you been programming?
Marek Slabicki
@thaniri
Mar 19 2016 04:19
i have never attempted anything recursively
bitgrower
@bitgrower
Mar 19 2016 04:19
...'bout time!
there's a great page, I think it was on ibm about recursion ... let me look at my notes ...
Marek Slabicki
@thaniri
Mar 19 2016 04:20
in fact, my answer for that algorithm is gone, so i dont even remember how i finished it
bitgrower
@bitgrower
Mar 19 2016 04:20
@mickmuzac -- I dunno how to answer that ... I can tell you some of my first programs were written in fortran on punched cards, though ...
Marek Slabicki
@thaniri
Mar 19 2016 04:21
i remember for summing primes when I was googling around I found a way to do it recursively
but it wasnt my code, just something on stack overflow
Dayne Wright
@daynewright
Mar 19 2016 04:21
how long for you @mickmuzac ?
bitgrower
@bitgrower
Mar 19 2016 04:21
factorial is like the epitome of awesome recursion examples ...
not a lot of extra baggage, so you can follow what's happening relatively easily ...
Mick Muzac
@mickmuzac
Mar 19 2016 04:22
Technically, about 14 yrs now. But I also started when I was a kid.
Sorry @bitgrower. I didn't mean to be intrusive... I was curious because you definitely know your stuff.
Marek Slabicki
@thaniri
Mar 19 2016 04:23
function factorial(num)
{
    // If the number is less than 0, reject it.
    if (num < 0) {
        return -1;
    }
    // If the number is 0, its factorial is 1.
    else if (num == 0) {
        return 1;
    }
    // Otherwise, call this recursive procedure again.
    else {
        return (num * factorial(num - 1));
    }
}

var result = factorial(8);
document.write(result);

// Output: 40320
here's an example
still puts my mind through a loop
bitgrower
@bitgrower
Mar 19 2016 04:24
so .. first thing in writing recursively is to define how you're going to exit ... each time thru your recursion you have to check, first thing, whether it's time to end the recursion ...
take small numbers and work thru it, @thaniri ...
(it can be written a little bit more compactly than that ... hmmm ... not my favorite version of factorial, tbh ... hang on ..
well ... this uses a ternary operator ...
function factorialize(num) { 
  return num > 0 ? num * factorialize(num - 1) : 1;
}
factorialize(3);
basically ... if num > 0 ... then you're going to call the function again ... if not, it's going to return 1 ...
now... another "trick" for this is that it counts DOWN not up ...
Marek Slabicki
@thaniri
Mar 19 2016 04:27
im running it through pythontutor
bitgrower
@bitgrower
Mar 19 2016 04:27
good idea ...
Marek Slabicki
@thaniri
Mar 19 2016 04:28
is return value something stored like a variable?|
bitgrower
@bitgrower
Mar 19 2016 04:29
well, the return value is used in the expression num * factorialize(num -1)
Marek Slabicki
@thaniri
Mar 19 2016 04:30
from my understanding of how return works
bitgrower
@bitgrower
Mar 19 2016 04:30
so when the return value is 1, it multiplies 1 num (which would be 2) -- which returns 2, which then multiplies 2 3
Marek Slabicki
@thaniri
Mar 19 2016 04:30
no recursion should work ever
since as soon as a return is reached in a function, that function terminates
so if i do factorialize(3) and it checks if its > 0
bitgrower
@bitgrower
Mar 19 2016 04:30
factorialize is the function which is being returned from ...
Marek Slabicki
@thaniri
Mar 19 2016 04:30
it should say "well yeah the number is > 0 my job is done"
bitgrower
@bitgrower
Mar 19 2016 04:32
you know, I was doing some exercises involving closures, and there was a lot of similar mind-bending as you'll find in recursion playing with closures ...
Marek Slabicki
@thaniri
Mar 19 2016 04:32
according to python tutor though
bitgrower
@bitgrower
Mar 19 2016 04:32
...and, uh, closures are important for api stuff ...
Marek Slabicki
@thaniri
Mar 19 2016 04:32
it goes from if (num < 0)
then skips to the else statement
Mick Muzac
@mickmuzac
Mar 19 2016 04:32
It shouldn't.
Marek Slabicki
@thaniri
Mar 19 2016 04:32
then the else statement starts over again
and it keeps doing that until num = 0
bouncing between the two
bitgrower
@bitgrower
Mar 19 2016 04:33
lilke I say ... the example you pasted in is not my favorite -- it's better in terms of defensive coding ... but from pedagogy, it kinda sucks
Mick Muzac
@mickmuzac
Mar 19 2016 04:34
You think so? I think it works well to teach the concept if instead of trying to trace the recursion tree, you think about it mathematically.
bitgrower
@bitgrower
Mar 19 2016 04:35
I don't like it because the if (num < 0) can be confusing -- and it's not relevant to the pedagogical point ...
Mick Muzac
@mickmuzac
Mar 19 2016 04:35
Agreed, that line really shouldn't be there.
Marek Slabicki
@thaniri
Mar 19 2016 04:36
return num > 0 ? num * factorialize(num - 1) : 1;
var elvisLives = Math.PI > 4 ? "Yep" : "Nope";
bitgrower
@bitgrower
Mar 19 2016 04:36
LOL ...
Marek Slabicki
@thaniri
Mar 19 2016 04:36
just trying to learn the ? x:x;
bitgrower
@bitgrower
Mar 19 2016 04:36
ahhhha ...
if true else false
Andrew Charlebois
@andrewchar
Mar 19 2016 04:37
help Sum All Odd Fibonacci Numbers
CamperBot
@camperbot
Mar 19 2016 04:37

:point_right: algorithm sum all odd fibonacci numbers [wiki]

Explanation:

You will need to gather all the Fibonacci numbers and then check for the odd ones. Once you get the odd ones then you will add them all. The last number should be the number given as a parameter if it actually happens to be an off Fibonacci number.

:pencil: read more about algorithm sum all odd fibonacci numbers on the FCC Wiki

bitgrower
@bitgrower
Mar 19 2016 04:38
just a shorthand for if/else, @thaniri ...
Marek Slabicki
@thaniri
Mar 19 2016 04:38
yeah just give me a couple of hours to stare at this
it'll get there
Dayne Wright
@daynewright
Mar 19 2016 04:38
@thaniri you should see how crazy it looks when you nest ternary operations.
Marek Slabicki
@thaniri
Mar 19 2016 04:38
one day at a time @Daynewr ... one day at a time
bitgrower
@bitgrower
Mar 19 2016 04:38
LOL ... don't overwhelm the poor man ..
Mick Muzac
@mickmuzac
Mar 19 2016 04:38
Lol!
bitgrower
@bitgrower
Mar 19 2016 04:39
we don't want campers to end up with PTSD ...
Marek Slabicki
@thaniri
Mar 19 2016 04:39
just make them learn c
Mick Muzac
@mickmuzac
Mar 19 2016 04:39
Seriously. If I ever see a nested ternary in production code, I'm walking off the job.
Dayne Wright
@daynewright
Mar 19 2016 04:40
Says the man with the crazy challenges :)
Mick Muzac
@mickmuzac
Mar 19 2016 04:40
I'm like an infomercial... "BUT WAIT, THERE'S MORE!"
Marek Slabicki
@thaniri
Mar 19 2016 04:41
num multiplying by a function
num * factorialize(num - 1)
bitgrower
@bitgrower
Mar 19 2016 04:41
at least c doesn't have dynamic typing ... dynamic typing causes a lot of pain because you don't get errors from the interpreter, you get errors during runtime ... which can be a lot trickier to catch.
in c -- many things folks have trouble with would be caught by the compiler
Marek Slabicki
@thaniri
Mar 19 2016 04:42
the compiler doesnt always tell you whats wrong though
if you're 200 lines in thats pretty frustrating
whereas javascript as soon as you make a mistake or have off syntax
it lets you know
bitgrower
@bitgrower
Mar 19 2016 04:42
@thaniri -- you are not multiplying by a function, you are multiplying by what the function returns ...
Dayne Wright
@daynewright
Mar 19 2016 04:42
I have not looked at C at all… You guys have years on me.
Marek Slabicki
@thaniri
Mar 19 2016 04:42
i have < 1 year programming so dont worry
i dont even know C except looking at my friends homework
Dayne Wright
@daynewright
Mar 19 2016 04:43
@thaniri I am in at about a year or so as well.
Marek Slabicki
@thaniri
Mar 19 2016 04:43
i go to a java school™
bitgrower
@bitgrower
Mar 19 2016 04:43
yeah, but there's a lot of liberalness in the js syntax ... there's less for the interpreter to catch...
Mick Muzac
@mickmuzac
Mar 19 2016 04:43
@thaniri are you comfortable with this snippet?
function multiply(a, b){
    return a * b;
}

function add(a, b){
    return a + b;
}

function doStuff(){
    return 2 * multiply(2, 3) + add(1, 2);
}
bitgrower
@bitgrower
Mar 19 2016 04:43
...it's those mysterious places where things are returning undefined that get people caught up
Marek Slabicki
@thaniri
Mar 19 2016 04:43
the answer is almost certainly no, but i'll try
that returns 2 * 6 + 3
from how im reading it
15
bitgrower
@bitgrower
Mar 19 2016 04:44
yeah, it's not a trick question, @thaniri ...
Mick Muzac
@mickmuzac
Mar 19 2016 04:44
Exactly. The factorial function above works in exactly the same way.
Except it does what we'll call "magic" for now to support recursion.
Marek Slabicki
@thaniri
Mar 19 2016 04:45
now num * factorialize(num - 1) in factorialize(3) should be 3 x 2, returning 6
however it returns 3, then 2, then 1
as opposed to 3 * 2
2 * 1
1 * 0
bitgrower
@bitgrower
Mar 19 2016 04:46
but when it returns 1, it multiplies by 1, so your answer is still correct ... 1 2 3 == 2 * 3
blah ... 1 * 2 * 3 = 2 * 3
it stops at 1, it never multiplies by 0
this is the article I rather like on recursion, @thaniri : http://www.ibm.com/developerworks/library/l-recurs/

recursion is an important thing to learn ... and there are instances where it really IS the answer, in terms of concise expressiveness ... (like steamroller & finding factorials) ...

however, it can also be more expensive in both memory & execution -- so you don't actually see it in use as much as you might expect ...

Mick Muzac
@mickmuzac
Mar 19 2016 04:53
In all honesty... I'd recommend dropping everything until you're comfortable with recursion. It's fundamental to programming and algorithms in general.
bitgrower
@bitgrower
Mar 19 2016 04:54
yep -- it's def an important programming construct ...!!!
Marek Slabicki
@thaniri
Mar 19 2016 04:54
i think i've understood what happens when num > 0
however once num == 0
idk
how does it know to go back up
bitgrower
@bitgrower
Mar 19 2016 04:54
it will never get to 0, @thaniri ...
Marek Slabicki
@thaniri
Mar 19 2016 04:55
if factorialize(1) ... num-1 = 0
pythontutor even shows num reaching 0
bitgrower
@bitgrower
Mar 19 2016 04:55
okay ... sorry, my mistake ...
it's caught by that first if statement ...
Mick Muzac
@mickmuzac
Mar 19 2016 04:56
num = 0 is caught by the second if. The first one never evaluates to true.
That's why you can safely delete it.
bitgrower
@bitgrower
Mar 19 2016 04:56
if ( num > 0 ) {
return num * factorialize(num-1)
} else {
return 1
}
yeah, it depends on which example he's using ... :)
Mick Muzac
@mickmuzac
Mar 19 2016 04:57
Oh, never mind! I thought you were still dealing with the code here.
Marek Slabicki
@thaniri
Mar 19 2016 04:57
your example bitgrower
they both work the same way in any case
when it reaches 0 and its told to return 1
my question is why doesnt the code stop right there
and just factorialize(3); == 1
bitgrower
@bitgrower
Mar 19 2016 04:58
the secret answer is stacks ...
because it's returning from a DIFFERENT invocation of the factorialize function
Saif Ali Khan
@saifat29
Mar 19 2016 04:59

http://codepen.io/saifat29/pen/JXWjba

What's wrong with my modal boxes?

Navigating between my login and signup boxes doesn't works
Marek Slabicki
@thaniri
Mar 19 2016 05:00
seems to work fine?
try an onclick
if #loginModal is clicked
first take sign up off the screen
Saif Ali Khan
@saifat29
Mar 19 2016 05:01
no, when i click on Already a member 'Login Here' the login box disappears as expected but the signup box doesn't show up and vice-versa
Marek Slabicki
@thaniri
Mar 19 2016 05:01
then put login on to the screen
ah you're using jquery
are you toggling a css class called hide and show?
cause thats what i would think
would work
Saif Ali Khan
@saifat29
Mar 19 2016 05:02
yes, i even tried that, wait let me show
Rex Smith Jr.
@rsmith731
Mar 19 2016 05:03
can anyone help me with an exercise?
Saif Ali Khan
@saifat29
Mar 19 2016 05:05
@thaniri i used css hide show
Mick Muzac
@mickmuzac
Mar 19 2016 05:07
@thaniri does this help you visualize how factorialize is working?
//Start by calling factorialize
0. factorialize(3);

    1. return 3 * factorialize(2);
        2. return 2 * factorialize(1);
            3. return 1 * factorialize(0);

                4. return 1;

            3. return 1 * (1);
        2. return 2 * (1);
    1. return 3 * (2);

0. We finally get: 6
bitgrower
@bitgrower
Mar 19 2016 05:08
very nice, @mickmuzac
Mick Muzac
@mickmuzac
Mar 19 2016 05:08
The interpreter internally keeps track of where it was before the recursion happened, and once it finally gets an actual value, it continues returning upward.
Marek Slabicki
@thaniri
Mar 19 2016 05:08
whats interestiong @saifat29 is the only class i can observe being toggled is modal-open on the body
bitgrower
@bitgrower
Mar 19 2016 05:09
kinda like dominoes ...
Saif Ali Khan
@saifat29
Mar 19 2016 05:09
@thaniri i'm not getting
Marek Slabicki
@thaniri
Mar 19 2016 05:09
@mickmuzac i've probably been expressing myself very poorly
bitgrower
@bitgrower
Mar 19 2016 05:09
those rows of dominoes someone hits the one and it goes clickety clickety clackety click ...
Marek Slabicki
@thaniri
Mar 19 2016 05:09
i can understand it if written down on a piece of paper
demipixel
@demipixel
Mar 19 2016 05:09
Anybody done Exact Change?
Marek Slabicki
@thaniri
Mar 19 2016 05:09
in fact i actually did write it down on a piece of paper to understand it
bitgrower
@bitgrower
Mar 19 2016 05:10
@thaniri .. not at all ...
Marek Slabicki
@thaniri
Mar 19 2016 05:10
however when i look at the code, what it looks like is NOT what i think it should do
Mick Muzac
@mickmuzac
Mar 19 2016 05:10
What does it look like?
Marek Slabicki
@thaniri
Mar 19 2016 05:10
when num reaches 0
it looks like it should stop at 1
at return 1
because of the syntax
? x:x;
so the second x should be executed
however
this second x doesnt do anything other than return 1
when i look at it
Dayne Wright
@daynewright
Mar 19 2016 05:11
This helped me with recursion: https://www.youtube.com/watch?v=Mv9NEXX1VHc
Marek Slabicki
@thaniri
Mar 19 2016 05:11
the code doesn't say "multiply 1 x num"
Mick Muzac
@mickmuzac
Mar 19 2016 05:12
Ah, I have a perfect example that might make a little more sense.
Marek Slabicki
@thaniri
Mar 19 2016 05:12
i'll probably just have to sleep on it
Mick Muzac
@mickmuzac
Mar 19 2016 05:13
recursion works for that exact same reason this works:
function one(){
    return 1;
}

function two(){
    return 2 * one();
}

function doStuff(){
    return two();
}
bitgrower
@bitgrower
Mar 19 2016 05:13

@thaniri ..

"Nothing in this world can take the place of persistence. Talent will not: nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not: the world is full of educated derelicts. Persistence and determination alone are omnipotent." ... Calvin Coolidge ...

one of my favorite quotes

Mick Muzac
@mickmuzac
Mar 19 2016 05:14
don't think of recursion as just nested functions... they are executing in an entirely different context.
Dayne Wright
@daynewright
Mar 19 2016 05:14
@bitgrower I like it! :)
Marek Slabicki
@thaniri
Mar 19 2016 05:15
im sorry but dpStuff(); returns 1
Mick Muzac
@mickmuzac
Mar 19 2016 05:15
No, it returns 2.
Marek Slabicki
@thaniri
Mar 19 2016 05:16
well, recursion says to
says so*
bitgrower
@bitgrower
Mar 19 2016 05:16
I had a link to a recursion lecture from a guy at MIT or Harvard ... seem to have misplaced it ... :( ... He uses the towers of hanoi puzzle to demonstrate recursion ...
shanky
@shaanky
Mar 19 2016 05:16

// 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"
};

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

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

Can anyone tell me what i'm doing wrong

Dayne Wright
@daynewright
Mar 19 2016 05:17
I think that is the one I linked to. Maybe half way in??
Mick Muzac
@mickmuzac
Mar 19 2016 05:17
@thaniri what do you mean by recursion says so?
bitgrower
@bitgrower
Mar 19 2016 05:17
umm ... what have you changed in the code, @shaanky -- I'm missing it ...
Marek Slabicki
@thaniri
Mar 19 2016 05:17
well right now, the way i see it recursion may as well be black magic
i understand what the black magic is supposed to spit out at me
but i dont understand why its doing it
Mick Muzac
@mickmuzac
Mar 19 2016 05:18
Do you understand why my example returns 2?
shanky
@shaanky
Mar 19 2016 05:18
@bitgrower it should give the value of phoneticLookup("charlie");
Marek Slabicki
@thaniri
Mar 19 2016 05:18
yes, give me a moment to write it down
bitgrower
@bitgrower
Mar 19 2016 05:18
which challenge, @shaanky ?
shanky
@shaanky
Mar 19 2016 05:18
@bitgrower Using Objects for Lookups
Mick Muzac
@mickmuzac
Mar 19 2016 05:19
@shaanky you're not using val at all.
bitgrower
@bitgrower
Mar 19 2016 05:19
@Daynewr -- the one I had the guy is standing in a classroom with the Hanoi puzzle on his lab-bench style table ...
Marek Slabicki
@thaniri
Mar 19 2016 05:19
1. doStuff();
 2. 2 * one();
  3. one(); returns one
 2. 2 * one(1); // 2*1
Dayne Wright
@daynewright
Mar 19 2016 05:19
@bitgrower ahh..
shanky
@shaanky
Mar 19 2016 05:20
@mickmuzac so where i have to use it??
Marek Slabicki
@thaniri
Mar 19 2016 05:20
i think i've got it
Mick Muzac
@mickmuzac
Mar 19 2016 05:21
That's exactly what's going on.
bitgrower
@bitgrower
Mar 19 2016 05:21
ahhh ... here it is ... https://youtu.be/WbWb0u8bJrU
Marek Slabicki
@thaniri
Mar 19 2016 05:21
well, if i could give you guys more brownie points in a day i would
you've been more patient than you should have been :)
bitgrower
@bitgrower
Mar 19 2016 05:21
you can give brownie points every hour ...
Marek Slabicki
@thaniri
Mar 19 2016 05:21
thanks @mickmuzac @bitgrower
CamperBot
@camperbot
Mar 19 2016 05:21
thaniri sends brownie points to @mickmuzac and @bitgrower :sparkles: :thumbsup: :sparkles:
Marek Slabicki
@thaniri
Mar 19 2016 05:21
there you go
CamperBot
@camperbot
Mar 19 2016 05:21
:star: 891 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 14 | @mickmuzac | http://www.freecodecamp.com/mickmuzac
Mick Muzac
@mickmuzac
Mar 19 2016 05:21
Thanks!!
bitgrower
@bitgrower
Mar 19 2016 05:22
ditto!!!
@thaniri -- when I look at people who are starting to code ... I look for persistence ...
shanky
@shaanky
Mar 19 2016 05:22
@bitgrower and @mickmuzac please help me in that challange
bitgrower
@bitgrower
Mar 19 2016 05:22
you persisted
@shaanky you using val yet ?
Dayne Wright
@daynewright
Mar 19 2016 05:23
@bitgrower that is not the same as here? https://youtu.be/Mv9NEXX1VHc?t=5m42s
Mick Muzac
@mickmuzac
Mar 19 2016 05:23
@shaanky do you know how to use variables to access object properties?
that is a weird looking screenshot
shanky
@shaanky
Mar 19 2016 05:23
yes
Andrew Charlebois
@andrewchar
Mar 19 2016 05:23
i just broke my browser with recursion trying to do fabonacci numbers with it lol
dont try that :P
bitgrower
@bitgrower
Mar 19 2016 05:23
hmm ... well ... I dunno, if the guy snuck in the MIT courseware into his video ...
Marek Slabicki
@thaniri
Mar 19 2016 05:24
persistence is not a virtue of mine, but im working on it :)
bitgrower
@bitgrower
Mar 19 2016 05:24
@thaniri -- you're doin' good ...
Mick Muzac
@mickmuzac
Mar 19 2016 05:24
@shaanky Why don't you just access result using var?
bitgrower
@bitgrower
Mar 19 2016 05:24
and you are in there struggling until you get it ...
another one of my fav quotes ... "problems worthy of attack prove their worth by fighting back" -- Piet Hein
shanky
@shaanky
Mar 19 2016 05:26
@bitgrower this quotes for me??
bitgrower
@bitgrower
Mar 19 2016 05:27

and there's enough of the ... struggle, struggle, struggle ... "OHHHHHH, NOW I see it" ... to make the struggle worth while ...

@shaanky no ... for @thaniri

Michael Suchorolski
@mikesuchor
Mar 19 2016 05:28
having trouble with this, how would I add another array? I can't get the formatting right
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
or just an explanation of how it's laid out would be best
it's an array inside an object inside an array?
Andrew Charlebois
@andrewchar
Mar 19 2016 05:30
@bitgrower now you've got me thinking about the Stanford online cs 101 course
Mick Muzac
@mickmuzac
Mar 19 2016 05:30
myMusic is an array of objects. Each of those objects have artist, title, release_year, and formats (array) fields.
Andrew Charlebois
@andrewchar
Mar 19 2016 05:30
@bitgrower I have been debating doing it for some time now.
Mick Muzac
@mickmuzac
Mar 19 2016 05:32
I'd recommend everyone take a few fundamental CS + algorithm courses in addition to this bootcamp. Doing that will make you more knowledgeable overall and make tech interviews much easier to master.
shanky
@shaanky
Mar 19 2016 05:32
guys is there anything that motivate me towards programming???
bitgrower
@bitgrower
Mar 19 2016 05:32
awesome @mikesuchor ... thank you for describing the data sttructure you have to deal with ...
CamperBot
@camperbot
Mar 19 2016 05:32
bitgrower sends brownie points to @mikesuchor :sparkles: :thumbsup: :sparkles:
:star: 221 | @mikesuchor | http://www.freecodecamp.com/mikesuchor
bitgrower
@bitgrower
Mar 19 2016 05:33
@shaanky -- motivation comes from you ... it depends upon what you want, what you are willing to do to get coding skills ...
Mick Muzac
@mickmuzac
Mar 19 2016 05:33
@bitgrower huh? all he did was copy and paste?
Michael Suchorolski
@mikesuchor
Mar 19 2016 05:33
@mickmuzac thanks
bitgrower
@bitgrower
Mar 19 2016 05:33
and why ...
CamperBot
@camperbot
Mar 19 2016 05:33
mikesuchor sends brownie points to @mickmuzac :sparkles: :thumbsup: :sparkles:
:star: 15 | @mickmuzac | http://www.freecodecamp.com/mickmuzac
Michael Suchorolski
@mikesuchor
Mar 19 2016 05:33
on to the next
shanky
@shaanky
Mar 19 2016 05:34
@cannelflow thnx
CamperBot
@camperbot
Mar 19 2016 05:34
shaanky sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 966 | @cannelflow | http://www.freecodecamp.com/cannelflow
bitgrower
@bitgrower
Mar 19 2016 05:35
@mickmuzac -- he described what the data structure is ... which I try to encourage people to do, because a lot of mistakes come in the object challenges because they don't realize what kind of data structure they have ...
Mick Muzac
@mickmuzac
Mar 19 2016 05:35
did he?
bitgrower
@bitgrower
Mar 19 2016 05:35
so, they try to access a property in an object without recognizing that it's in an array ...
Michael Suchorolski
@mikesuchor
Mar 19 2016 05:35
other way around haha
bitgrower
@bitgrower
Mar 19 2016 05:35
I thought he did, yes ... maybe I misread someone else saying it ... shrug
Michael Suchorolski
@mikesuchor
Mar 19 2016 05:35
I asked, he answered
Mick Muzac
@mickmuzac
Mar 19 2016 05:36
Lol, it's getting late.
I described his data structure for him.
Olawale Akinseye
@brainyfarm
Mar 19 2016 05:36
:wave: everyone
bitgrower
@bitgrower
Mar 19 2016 05:36
oh ... I missed you doing that ... I just saw him say this: "it's an array inside an object inside an array?" ... oh well ... :) it happens ...
hi @brainyfarm
Andrew Charlebois
@andrewchar
Mar 19 2016 05:37
has anyone taken CS101 or CS50
Olawale Akinseye
@brainyfarm
Mar 19 2016 05:38
I am trying to take CS50 @andrewchar, I love the first few lessons I have seen.
Happy weekend @bitgrower :D
bitgrower
@bitgrower
Mar 19 2016 05:39
it's very odd -- your comment, @mickmuzac -- I SWEAR is not in my chat feed ...
Mick Muzac
@mickmuzac
Mar 19 2016 05:39
Interesting!
bitgrower
@bitgrower
Mar 19 2016 05:40
can you link to it (hover over the timestamp and click alt
Olawale Akinseye
@brainyfarm
Mar 19 2016 05:40
You programmers should start talking like real humans, you talk too smart :P
bitgrower
@bitgrower
Mar 19 2016 05:41
ahhh ... nvm ... I found it ...
bitgrower @bitgrower is currently blind in one eye ...
Mick Muzac
@mickmuzac
Mar 19 2016 05:42
Lol.
bitgrower
@bitgrower
Mar 19 2016 05:42
thanks @mickmuzac
CamperBot
@camperbot
Mar 19 2016 05:42
bitgrower sends brownie points to @mickmuzac :sparkles: :thumbsup: :sparkles:
:star: 16 | @mickmuzac | http://www.freecodecamp.com/mickmuzac
bitgrower @bitgrower thinks @mickmuzac has NOT been given his fair share of brownie point s... working hard there, @mickmuzac ... think you are brownie point deficient ... :)
Mick Muzac
@mickmuzac
Mar 19 2016 05:44
Whoa.
How do you do that?
bitgrower
@bitgrower
Mar 19 2016 05:44
"/me" ... old IRC trick ... :) (works in skype,, too)
Andrew Charlebois
@andrewchar
Mar 19 2016 05:45
@brainyfarm i see they list many languages other then JS. i only know JS. think that would be a problem?
mickmuzac @mickmuzac whoooaaaaa... I'm in the Twilight Zone!
bitgrower
@bitgrower
Mar 19 2016 05:45

has to be on the first line

/me on a second line results in ... /me

for the CS50 class ?
Andrew Charlebois
@andrewchar
Mar 19 2016 05:46
mhm
bitgrower
@bitgrower
Mar 19 2016 05:46
what good is an intro to CS class if it requires you know a bunch of languages first ... seems counter-productive
mickmuzac @mickmuzac @bitgrower so only the people I tag can see this?
Andrew Charlebois
@andrewchar
Mar 19 2016 05:46
merp.. read it wrong. it was under the "What you'll learn" heading lol
bitgrower
@bitgrower
Mar 19 2016 05:46
nah -- everyone in the chat can see it, @mickmuzac
Mick Muzac
@mickmuzac
Mar 19 2016 05:47
Fail.
:(
bitgrower
@bitgrower
Mar 19 2016 05:50
oooh ... did they close the doors on campers being able to read the curriculumdevelopment room now? I get a 404 on trying to pull up the room now ...
...or did they move it ...
Mick Muzac
@mickmuzac
Mar 19 2016 05:50
I wouldn't know.. I've only been around FCC for a few hrs now.
Andrew Charlebois
@andrewchar
Mar 19 2016 05:50
didn't know there was such a room
secret room
Josh Fisk
@JoshFisk
Mar 19 2016 05:51
@bitgrower If that was the actual name , they probably renamed it to something shorter
Mick Muzac
@mickmuzac
Mar 19 2016 05:53
You guys are awesome. I'm going to hit the hay.
bitgrower
@bitgrower
Mar 19 2016 05:53
yeah, it was ... it was in one of my tabs y'day ... today I look in my tabs and it's PINK! and the page says 404 ... and then mutters something about private repositories and such ...
Andrew Charlebois
@andrewchar
Mar 19 2016 05:54
denied i suppose
Josh Fisk
@JoshFisk
Mar 19 2016 05:54
@bitgrower Got kicked out of the cool kids club :<
bitgrower
@bitgrower
Mar 19 2016 05:55
wasn't in (hadn't joined) ... just occasionally checked out what was going on ...
Josh Fisk
@JoshFisk
Mar 19 2016 05:55
@bitgrower Maybe you were a ninja for even being in there, and didn't know it
bitgrower
@bitgrower
Mar 19 2016 05:56
I did get kicked out of another room which I had joined, and Quincy politely said something about me accidentally having joined the room ... think it was a different room ...
nahhh ...
the other room (this was some weeks ago) -- was actually far more "sensitive' than the CD room ...
Andrew Charlebois
@andrewchar
Mar 19 2016 05:57
only 8 more for intermediate algorithms woo
bitgrower
@bitgrower
Mar 19 2016 05:58
knock 'em out dude!!!
Andrew Charlebois
@andrewchar
Mar 19 2016 05:58
13 of them took me from monday to now
im a little behind on the 50 hours lol
Matthew Shaver
@RazzaFrazza
Mar 19 2016 06:07
@mickmuzac I am very weak in cs algorithm stuff. Any recommendations on online courses?
Shivam Arora
@shivamarora13
Mar 19 2016 06:15
https://www.freecodecamp.com/challenges/caesars-cipher can anyone please have a look at my code, its working properly in the console and otehrwise also, but still, tests are not getting accepted, though the answer is same as given in tests.
help caesars cipher
CamperBot
@camperbot
Mar 19 2016 06:16

:point_right: algorithm caesars cipher [wiki]

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

:checkered_flag: Problem Explanation:

  • You need to write a function, which will take 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'.

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

Markus Kiili
@Masd925
Mar 19 2016 06:36
@shivamarora13 Post the code please.
Shivam Arora
@shivamarora13
Mar 19 2016 06:39

function rot13(str) { // LBH QVQ VG!
var result = [];
var temp;
var tempPos;
var posPunc;

for(var i=0 ; i<= str.length; i++){
temp = 0;
tempPos = 0;
if(str.charCodeAt(i) < 65){
posPunc = str.charCodeAt(i);
result.push(String.fromCharCode(posPunc));
}
else{
var pos = str.charCodeAt(i);
if(pos>=78){
temp = pos + 13;
tempPos = temp - 91;
pos = 65 + tempPos;

    result.push(String.fromCharCode(pos));
  }
  else{
    result.push(String.fromCharCode(pos+13));
  }
}

}
var strFinal = result.join('');

return strFinal.trim();

}

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

@Masd925
Markus Kiili
@Masd925
Mar 19 2016 06:40
@shivamarora13 Might be a null character at the end of result string.
@shivamarora13 Yes, the result has length 15.
Vladimir Logachev
@VladimirLogachev
Mar 19 2016 06:44
/^[1]?[\(]?\d{3}?[\)]?d{7}$/
Hello world. I want to make RegEx to check phone number exactly like this: 1(777)8885522. It doesn't work. Can anyone help?
Muhammed Shafi
@shafimpk
Mar 19 2016 06:44
need help in word blanks section in javascript!!
I have no idea what to do
Markus Kiili
@Masd925
Mar 19 2016 06:44
@shivamarora13 Should it be i< str.length
Shivam Arora
@shivamarora13
Mar 19 2016 06:49
@Masd925 Man done!
Thanks a lot! @Masd925
CamperBot
@camperbot
Mar 19 2016 06:49
shivamarora13 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1190 | @masd925 | http://www.freecodecamp.com/masd925
Michael Suchorolski
@mikesuchor
Mar 19 2016 06:49
what's word blanks
rphares
@rphares
Mar 19 2016 06:50
the challenge, @mikesuchor ?
all you need to do is build a sentence
you can do so by concatenating all the parameters, and be sure to concatenate in some non-word characters (i suggest spaces) in between each one
Vladimir Logachev
@VladimirLogachev
Mar 19 2016 06:50
 /^[1]?[\(]?\d{3}?[\)]?d{7}$/
Hello world. I want to make RegEx to check phone number exactly like this: 1(777)8885522. It doesn't work. Can anyone help?
rphares
@rphares
Mar 19 2016 06:51
make sure to store it in the thing you will return :blush:
Michael Suchorolski
@mikesuchor
Mar 19 2016 06:52
yeah looking at it now
Jonathan Mitchell
@Vanhealen
Mar 19 2016 06:52
lolol
Michael Suchorolski
@mikesuchor
Mar 19 2016 07:01
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi"
},
};
how do I access the 2548? collection.2548 is giving me an error
uriznik
@uriznik
Mar 19 2016 07:03
@vl-doit you don't need any of the square brackets and you're missing a \ in front of the last d
Vladimir Logachev
@VladimirLogachev
Mar 19 2016 07:04
@uriznik 1 minute, I'll try (backslashes disappear because of countless editing)

@uriznik that worked with the target number! but also selects these wrong numbers:

1555)5555555
555)5555555
(5555555555

How to make our RegExp more strong?

/^1?\(?\d{3}?\)?\d{7}$/
uriznik
@uriznik
Mar 19 2016 07:13
@vl-doit is this for the validate US telephone numbers algo?
Vladimir Logachev
@VladimirLogachev
Mar 19 2016 07:14
yea. I've deleted two ? and now I have
/^1?\(\d{3}\)?\d{7}$/
only one number left wrong:
(5555555555
Bil
@thebiltheory
Mar 19 2016 07:15
Hello World
CamperBot
@camperbot
Mar 19 2016 07:15

welcome to FreeCodeCamp @thebiltheory!

Vladimir Logachev
@VladimirLogachev
Mar 19 2016 07:15
@thebiltheory yep!
uriznik
@uriznik
Mar 19 2016 07:16
@vl-doit you can use a branch like /(\(123\)|123)/ which would match (123) or 123
Bil
@thebiltheory
Mar 19 2016 07:16
Does anyone mind helping me
Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed.
function queue(arr, item) {
  arr.push(item);
  arr.shift();

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
uriznik
@uriznik
Mar 19 2016 07:21
@thebiltheory '... then return the element that was removed' - how would you get that element?
Vladimir Logachev
@VladimirLogachev
Mar 19 2016 07:22
@uriznik I'll try. But I've already solved and now will let it be more accurate
Bil
@thebiltheory
Mar 19 2016 07:23
@uriznik Thinking ...
@uriznik There you go ... Return arr.shift(item);
@uriznik Thanks a lot man!
Spartano
@Spartano
Mar 19 2016 07:25
how can i test if an letter is equal to an RegExp? if("A" == /\W/g) ?
@Spartano
@Spartano Ah do you want a boolean return
?
Spartano
@Spartano
Mar 19 2016 07:27
yes
that should cover your cases