These are chat archives for FreeCodeCamp/HelpJavaScript

10th
Jan 2017
Abubakar Gabdo
@Atiku2039
Jan 10 2017 00:00

SOS

var count = 0;

function cc(card) {
// Only change code below this line

return "Change Me";
// Only change code above this line
}

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

Michael Pimentel Jr
@mtpjr88
Jan 10 2017 00:00
I need help hiding a div element when page loads and then revealing it on click
Pieter Stokkink
@forkerino
Jan 10 2017 00:00
@Atiku2039 I think you forgot to write code.
Dylan Hsiao
@greedylan
Jan 10 2017 00:00
@forkerino I see. Thanks for the hint !!
CamperBot
@camperbot
Jan 10 2017 00:00
greedylan sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 587 | @forkerino |http://www.freecodecamp.com/forkerino
Abubakar Gabdo
@Atiku2039
Jan 10 2017 00:00
@forkerino how to go about it
Pieter Stokkink
@forkerino
Jan 10 2017 00:00
@JLuboff I would've guessed you'd be further along.
aroojmumtaz
@aroojmumtaz
Jan 10 2017 00:01
can someone please help me wth the golfscore challenge
Mrdaniels3
@Mrdaniels3
Jan 10 2017 00:01
Looking for help with Global Scope and Functions.
Nathan Classen
@NathanHayez
Jan 10 2017 00:01
@forkerino Why would return cause the loop to stop? Isn't a loop suppose to run until its condition ends it?
Evan W
@Dirtier
Jan 10 2017 00:01
The pomodoro was kind of annoying at first
@NathanHayez Because return exits out of the entire function
@NathanHayez If you want to just stop a loop you can use break
Nick McCord
@Thrillxlordz
Jan 10 2017 00:02
@HeebieGeeBee I think i figured it out, and im not sure how to fix it. Because i made newArr a global variable, it remembers each answer. So my newArr will keep getting longer for each test that the computer puts it through
Pieter Stokkink
@forkerino
Jan 10 2017 00:02
@Atiku2039 First you want to increment or decrement the count based on the card that is passed in. Then you want to return a message based on the value of count. So you will need two different logical parts. You have learned about some different options before.
Ramone
@RamoneQR
Jan 10 2017 00:03
@JLuboff You are almost done! Wow! How long did it take you to get that far?
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 00:03
yeah seems to solve the arr issue too @Thrillxlordz
Pieter Stokkink
@forkerino
Jan 10 2017 00:03
@NathanHayez Yes, what @Dirtier said. If the function encounters a return it stops doing everything and returns the value.
Mrdaniels3
@Mrdaniels3
Jan 10 2017 00:04
Global Scope and Functions

```var myGlobal = 10;// Declare your variable here
oopsGlobal();

function fun1() {
oopsGlobal=5; // Assign 5 to oopsGlobal Here

}

console.log();`` looking for help

HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 00:04
oh but now it doesnt pass @Thrillxlordz or give the right results
Ramone
@RamoneQR
Jan 10 2017 00:04
@camilosilvac No problem!
Nick McCord
@Thrillxlordz
Jan 10 2017 00:05
@HeebieGeeBee yeah, problem is that I tried to make a recursive function, so if it isnt global, it gets reset each run through
Mrdaniels3
@Mrdaniels3
Jan 10 2017 00:05

var myGlobal = 10;// Declare your variable here
oopsGlobal();

function fun1() {
oopsGlobal=5; // Assign 5 to oopsGlobal Here

}

console.log();

HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 00:05
yup
Nick McCord
@Thrillxlordz
Jan 10 2017 00:06
@HeebieGeeBee I figured out a work around xD this replaces the 'return newArr'
var x = newArr;
  newArr = [];
  return x;
Mrdaniels3
@Mrdaniels3
Jan 10 2017 00:06
Global Scope and Functions
var myGlobal = 10;// Declare your variable here oopsGlobal(); function fun1() { oopsGlobal=5; // Assign 5 to oopsGlobal Here}console.log(); looking for help please
Julia
@medusabeast
Jan 10 2017 00:09

working on switch statements, can someone point me in the right direction pls?


function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line 
  switch (val)
  {
    case 1:
      console.log("alpha");
      break;
    case 2:
      console.log("beta");
      break;
    case 3:
      console.log("gamma");
      break;
    case 4:
      console.log("delta");

  }


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

// Change this value to test
caseInSwitch(2);

DO NOT GIVE AWAY ANSWER!!! Just point out errors, TY!

HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 00:09
console.log does nothing
Evan W
@Dirtier
Jan 10 2017 00:09
pretty sure in that one you are supposed to set answer based on the cases
not console.log
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 00:09
@medusabeast
it just logs whatever to the console
Evan W
@Dirtier
Jan 10 2017 00:10
@medusabeast so instead of console.log-ing anything, you want the cases to manipulate var answer at the top, and then return that answer at the end of the function
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 00:10
and thats not how switch case works either
Evan W
@Dirtier
Jan 10 2017 00:12
also, you don't need that many semi-colons :P haha, especially if all those statements are on separate lines
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 00:12
@Thrillxlordz cool if that works
Evan W
@Dirtier
Jan 10 2017 00:12
you only need semi-colons when you have multiple expressions on the same line
Pieter Stokkink
@forkerino
Jan 10 2017 00:12
@Thrillxlordz You can use recursion, you just need to make sure that the result that gets returned from the recursioncall is correctly added to the result of the function calling itself.
Julia
@medusabeast
Jan 10 2017 00:13
@HeebieGeeBee @Dirtier thank you both, will check on that..so console.log not necessary & wrong switch is switch even necessary?
CamperBot
@camperbot
Jan 10 2017 00:13
:cookie: 263 | @dirtier |http://www.freecodecamp.com/dirtier
:cookie: 498 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
medusabeast sends brownie points to @heebiegeebee and @dirtier :sparkles: :thumbsup: :sparkles:
Evan W
@Dirtier
Jan 10 2017 00:13
@medusabeast yes that is the perfect scenario for a switch statement
Tony
@FreakishLancer
Jan 10 2017 00:13
Hello. I am a bit stuck on the Check for Palindromes challenge. How do I find out how to remove underscores in a string? I have tried the "\W" but it does not seem to detect underscores (_).
Evan W
@Dirtier
Jan 10 2017 00:14
You use switch statements instead of a bunch of if statements or a really long if-else
tobywynne-mellor
@tobywynne-mellor
Jan 10 2017 00:14
Hi I'm on Escape Sequences in Strings in Javascript. Can anyone help?
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 00:14
@medusabeast console.log is just if you want to see what something it from your script in the console, the switch part is right, its just the case statements need more
Evan W
@Dirtier
Jan 10 2017 00:14
@tobywynne-mellor yea
The case part is fine
He is switching based on the parameter 'val'
If val == 1, then answer = 'alpha'
Pieter Stokkink
@forkerino
Jan 10 2017 00:15
@FreakishLancer You can use \W (or) _ in the same regex. Do you remember the operator for 'or'?
Tony
@FreakishLancer
Jan 10 2017 00:16
@forkerino , yes. I will try that. Thank you.
CamperBot
@camperbot
Jan 10 2017 00:16
freakishlancer sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 588 | @forkerino |http://www.freecodecamp.com/forkerino
tobywynne-mellor
@tobywynne-mellor
Jan 10 2017 00:16

@Dirtier thank you! ok so I have to produce this:

FirstLine
\SecondLine\
ThirdLine

var myStr = "FirstLine" \n \"SecondLine"\ \r "ThirdLine";

What am I doing wrong?

CamperBot
@camperbot
Jan 10 2017 00:16
tobywynne-mellor sends brownie points to @dirtier :sparkles: :thumbsup: :sparkles:
:cookie: 264 | @dirtier |http://www.freecodecamp.com/dirtier
Evan W
@Dirtier
Jan 10 2017 00:17
just put the \n inside the string
without all the "
like myStr = "FirstLine\n SecondLine\nThirdLine"
tobywynne-mellor
@tobywynne-mellor
Jan 10 2017 00:18
I have to have a backslash on either side of the secondline
Adam Hadley
@badam96
Jan 10 2017 00:18
I'm on Golf Code and I don't see how my code is wrong

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

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

Evan W
@Dirtier
Jan 10 2017 00:19
@tobywynne-mellor Ohhh ok then escape the backslash
with another backslash
like this \
woops, \ x2
Pieter Stokkink
@forkerino
Jan 10 2017 00:20
@badam96 Check the spelling of the things you return; also: your else block needs some brackets.
tobywynne-mellor
@tobywynne-mellor
Jan 10 2017 00:20
@Dirtier ok thanks man
CamperBot
@camperbot
Jan 10 2017 00:20
tobywynne-mellor sends brownie points to @dirtier :sparkles: :thumbsup: :sparkles:
:warning: tobywynne-mellor already gave dirtier points
Eugene Han
@eugenehan7
Jan 10 2017 00:20
Thanks @ArielLeslie
CamperBot
@camperbot
Jan 10 2017 00:20
eugenehan7 sends brownie points to @arielleslie :sparkles: :thumbsup: :sparkles:
:star2: 2571 | @arielleslie |http://www.freecodecamp.com/arielleslie
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:20
Good evening ladies and gentlemen - I have a quick questions.
@ikliptic
I have a question I am working on the test "Check for Palindromes" - I seem to have written the code and it recognizes when I have a proper true statement but when it is false it does nothing - I am not sure why it is not working.
Evan W
@Dirtier
Jan 10 2017 00:21
post it
Pieter Stokkink
@forkerino
Jan 10 2017 00:21
code please!
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:21

```function palindrome(str) {
// Good luck!

var theStart = str.toLowerCase().replace(/[^a-z0-9]/g + "");
var reverseStr = theStart.split().reverse().join();
return reverseStr === theStart;
}

palindrome("eye", "2A33a2", "2A3 3a2", "2_A33#A2", "racecar", "RaceCar", "race CAR");```

Evan W
@Dirtier
Jan 10 2017 00:22
lol btw all you need to do for this one is make them both lowercase then compare the reversed version to the normal one
or uppercase
Don't think you even need the regexp
Pieter Stokkink
@forkerino
Jan 10 2017 00:22

@Dirtier from the instructions:

You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes.

HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 00:22
the regex is to remove the symbols
Evan W
@Dirtier
Jan 10 2017 00:22
ahhh ok
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:22
You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes.
Pieter Stokkink
@forkerino
Jan 10 2017 00:23
@ikliptic the problem is the replace function.
Evan W
@Dirtier
Jan 10 2017 00:23
what is the +?
Pieter Stokkink
@forkerino
Jan 10 2017 00:23
You need two arguments there. (not separated by a +)
Evan W
@Dirtier
Jan 10 2017 00:23
It should be a comma
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 00:24
but how does he get a return true though
obviously that needs changing
jus wondering how its even returning true
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:25
I added the plus sign to add - no space where character has been removed
Pieter Stokkink
@forkerino
Jan 10 2017 00:25
@HeebieGeeBee because "" === ""
Tony
@FreakishLancer
Jan 10 2017 00:25
Check the syntax for replace() in the link provided.
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 00:25
yeah but how does he get one
oh does he just mean in the tests
so im guessing the tests without symbols
Stephen James
@sjames1958gm
Jan 10 2017 00:26
@ikliptic you need parameters in your split / join
Tony
@FreakishLancer
Jan 10 2017 00:26
What I am wondering is how you are even getting the thing to run when you are putting in all those arguments in that function to test.
Evan W
@Dirtier
Jan 10 2017 00:26
@ikliptic were saying the + sign wont do that
it's .replace(/[^a-z0-9]/g, "")
chedli
@chedlii
Jan 10 2017 00:26
can any one try this ?

function mutation(arr) {
var one = arr[0] ;
var two = arr1;

var arrayTwo = two.split("");

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

var k = one.indexOf(arrayTwo[i],0);

if (k === -1) { break; }

return false ;

}

return true;
}

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

Capture.PNG
Tony
@FreakishLancer
Jan 10 2017 00:27
By the way, @ikliptic , you are supposed to check for all non-alphanumeric characters, not the opposite, in the replace().
Stephen James
@sjames1958gm
Jan 10 2017 00:28
@chedlii the break will exit the for loop so it will return true if the letter is invalid then return false otherwise
Nick McCord
@Thrillxlordz
Jan 10 2017 00:28
For the problem 'Everything Be True' I dont even know what is being asked
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:28
@FreakishLancer i thought the replace I created ignores all characters orther than within the paramaters listed/
Pieter Stokkink
@forkerino
Jan 10 2017 00:28
@FreakishLancer tomato tomato
@ikliptic you're fine with that regex.
Evan W
@Dirtier
Jan 10 2017 00:29
it does
yours basically says replace anything that isnt a-z or 0-9 with ""
Tony
@FreakishLancer
Jan 10 2017 00:29
Hm, I see. My fault. Disregard. =]
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:29
ok guys here is what I am ending up with - all Palindromes are showing true and the ones that are not Palindromes are suppose to show false - but are not giving a false
@Dirtier correct
William Reed
@reforma
Jan 10 2017 00:30
is anyone able to help with a basic react problem - i am getting an error saying react.render is not a function - i have all my code on git hub if anyone would be kindenough to have a look
Pieter Stokkink
@forkerino
Jan 10 2017 00:30
@reforma let's see
Evan W
@Dirtier
Jan 10 2017 00:30
@reforma I can
thats the link
Evan W
@Dirtier
Jan 10 2017 00:31
@ikliptic your join
.join('') instead of .join()
William Reed
@reforma
Jan 10 2017 00:31
im just trying to render somthing really basic that i can build up on
Tony
@FreakishLancer
Jan 10 2017 00:31
@Dirtier I had the quotes on the split("") instead.
William Reed
@reforma
Jan 10 2017 00:32
so at the moment its just a div with some text
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:32
@Dirtier I just tried that - no change in final results
Evan W
@Dirtier
Jan 10 2017 00:32
@ikliptic ok let me just copy it over, post it again please.
William Reed
@reforma
Jan 10 2017 00:32
thank you both @forkerino and @Dirtier
CamperBot
@camperbot
Jan 10 2017 00:32
reforma sends brownie points to @forkerino and @dirtier :sparkles: :thumbsup: :sparkles:
:cookie: 589 | @forkerino |http://www.freecodecamp.com/forkerino
:cookie: 265 | @dirtier |http://www.freecodecamp.com/dirtier
Evan W
@Dirtier
Jan 10 2017 00:32
@reforma what am I supposed to be looking at?
William Reed
@reforma
Jan 10 2017 00:33
sorry its the reacttooling.html file
Adel
@AdelMahjoub
Jan 10 2017 00:33
@reforma you are not importing ReactDOM
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:33
function palindrome(str) {
// Good luck!
var theStart = str.toLowerCase().replace(/[^a-z0-9]/g + "");
var reverseStr = theStart.split().reverse().join();
return reverseStr === theStart;
}
palindrome("eye", "2A33a2", "2A3 3a2", "2_A33#A2", "racecar", "RaceCar", "race CAR");
William Reed
@reforma
Jan 10 2017 00:33
no i was following a tutorial on zenva and there is no importing of react dom
Richard Gottleber
@rgottleber
Jan 10 2017 00:34
@khaduch not sure if you are still around .. but here is a link, it’s a different problem I’m having now lol
http://codepen.io/rgottleber/pen/ZLbRGp it gives me TypeError: undefined is not an object (evaluating 'this.props')
Adel
@AdelMahjoub
Jan 10 2017 00:34
@reforma then there is no rendering
miner_paul
@aeselden92
Jan 10 2017 00:34
insterting escape keys confuse me :(
Tony
@FreakishLancer
Jan 10 2017 00:34
@ikliptic , what you can do is temporarily replace "reverseStr === theStart" with "theStart" or "reverseStr" to see if you are reversing/formatting the strings correctly.
Albert L. C.
@sirus3020
Jan 10 2017 00:34

guys. am I using this right?

val[i][0].toUpperCase();

Pieter Stokkink
@forkerino
Jan 10 2017 00:35
@reforma I think you need ReactDOM.render.
chedli
@chedlii
Jan 10 2017 00:35
azz.PNG
any one has an idea ?
Adel
@AdelMahjoub
Jan 10 2017 00:35
@reforma maybe you should send to zenva to update their tutorials
William Reed
@reforma
Jan 10 2017 00:35
@forkerino i tried adding var react =require(react-dom); var react2 = require(react);
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:35
@FreakishLancer seems that did not change the results
Evan W
@Dirtier
Jan 10 2017 00:36
lol
require is for node
William Reed
@reforma
Jan 10 2017 00:36
then the error i got was that react.createelement is not a function
Evan W
@Dirtier
Jan 10 2017 00:36
that wont do anything if you aren't using node.js
Tony
@FreakishLancer
Jan 10 2017 00:36
@ikliptic I am not talking about the results. Rather, the console above the results will show whether the strings are the same or not if they are palindromes. You can also plug in the strings in the wrong results into the function at the bottom of your code to show it in the console.
mikaelaf
@mikaelaf
Jan 10 2017 00:37
hey can anyone help me with making object properties that are private vs. public?
jv775
@jv775
Jan 10 2017 00:37
Hello, can some one help me please? I am stuck in this problem: Word Blanks.
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:37
Console still displays true
Manish Giri
@Manish-Giri
Jan 10 2017 00:37
@mikaelaf what's the problem
Adel
@AdelMahjoub
Jan 10 2017 00:37
@reforma install nodeJS, and follow the official ReactJS docs
mikaelaf
@mikaelaf
Jan 10 2017 00:38
@Manish-Giri this is the assignment
William Reed
@reforma
Jan 10 2017 00:38
can i install node with npm install --save node.js
and this is my code:
Pieter Stokkink
@forkerino
Jan 10 2017 00:38
@reforma You might want to do the alpha version of the React challenges for FCC: http://hysterical-amusement.surge.sh/
Evan W
@Dirtier
Jan 10 2017 00:38
npm is node
jv775
@jv775
Jan 10 2017 00:38
function wordBlanks (myNoun, myAdjective, myVerb, myAdverb){
Evan W
@Dirtier
Jan 10 2017 00:39
npm install --save is a node command bra
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:39
correct me if I am wrong - but once a return is asked and a query is found true - it is true - but if not true it "should" automatically output false = am I correct in this thinking?
William Reed
@reforma
Jan 10 2017 00:39
ok so if i have installed things with npm i have node already
Evan W
@Dirtier
Jan 10 2017 00:39
Yes
William Reed
@reforma
Jan 10 2017 00:39
ok so my require syntax should work
Evan W
@Dirtier
Jan 10 2017 00:39
Depends if you set it all up right
mikaelaf
@mikaelaf
Jan 10 2017 00:39
var myCar = new Car();

var Bike = function(){
  var gear = 1;
  this.setGear=function(){
    //what do i put here?//
  };

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

};

var myBike = new Bike();
Francois van Leersum
@Blockshot12
Jan 10 2017 00:39
@jv775 What’s the problem?
Tony
@FreakishLancer
Jan 10 2017 00:40
@ikliptic once a function has reached a point where it will return a value, once it returns that value, it will jump out of the function.
jv775
@jv775
Jan 10 2017 00:40
Hi Francois,
Evan W
@Dirtier
Jan 10 2017 00:40
did you set up your packages file correctly?
did you npm init?
jv775
@jv775
Jan 10 2017 00:40
I am stuck in wordBlanks
Manish Giri
@Manish-Giri
Jan 10 2017 00:40

@mikaelaf see the example?

 this.accelerate = function(change) {
    speed += change;
  };

here, an argument change is passed in to accelerate, according to which the speed increases

Evan W
@Dirtier
Jan 10 2017 00:41
Also, I see you're mixing local links with hotlinks
Tony
@FreakishLancer
Jan 10 2017 00:41
@ikliptic if you are asking whether it could output false, then yes.
Adel
@AdelMahjoub
Jan 10 2017 00:41
@reforma which course you purchased on zenva
Evan W
@Dirtier
Jan 10 2017 00:41
You can't do that without using a localhost
Manish Giri
@Manish-Giri
Jan 10 2017 00:41

yours would be similar

this.setGear=function(){
    //what do i put here?//
  };

@mikaelaf
pass in an argument, and set gear equal to that value

Evan W
@Dirtier
Jan 10 2017 00:41
Your firewall wont let you for security reasons
Pieter Stokkink
@forkerino
Jan 10 2017 00:41
@ikliptic Like a few other people have pointed out above, your .join and .split functions need an argument (where to split/with what to join).
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:42
@FreakishLancer then why is it showing True statements and for those that are False - it is not recognizing them as false?
Suzanne Atkinson
@AdventureBear
Jan 10 2017 00:42
anyone here good at scraping?
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:42
aaaaah
William Reed
@reforma
Jan 10 2017 00:42
@AdelMahjoub it was the react course
Tony
@FreakishLancer
Jan 10 2017 00:42
@ikliptic So I did the challenge a different way, but based on your method, it seems what you are doing wrong is that you may not be removing symbols/reversing the strings correctly.
mikaelaf
@mikaelaf
Jan 10 2017 00:42
@Manish-Giri i see what you're getting at, and i was trying to do that earlier, but i dont understand what how i'm supposed to be setting the gear
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:42
ok well it is drawing the array from above it is it now?
Evan W
@Dirtier
Jan 10 2017 00:42
@reforma None of that will work even with Node if you aren't using a localhost.
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:42
not
mikaelaf
@mikaelaf
Jan 10 2017 00:42
like do i want it to increase by 1 until it hits 7?
Francois van Leersum
@Blockshot12
Jan 10 2017 00:43
@jv775 Can you be more specific?
Manish Giri
@Manish-Giri
Jan 10 2017 00:43
@mikaelaf gear = your_argument_here
that's all
William Reed
@reforma
Jan 10 2017 00:43
@Dirtier sorry i dont follow you
Adel
@AdelMahjoub
Jan 10 2017 00:43
@reforma yes but they sell 3 React courses, just want to check the one you follow,
Tony
@FreakishLancer
Jan 10 2017 00:43
@ikliptic Did you replace the "+" in your replace function with a comma? The replace function accepts two parameters.
Evan W
@Dirtier
Jan 10 2017 00:43
@reforma You are mixing local links, meaning you are linking locally to files you downloaded
With links that are hosted on servers
Francois van Leersum
@Blockshot12
Jan 10 2017 00:43
@jv775 Do you have code?
William Reed
@reforma
Jan 10 2017 00:44
@AdelMahjoub Build Web Apps with React JS and Flux
Tony
@FreakishLancer
Jan 10 2017 00:44
@ikliptic , also, check the documentation for String.prototype.split(), specifically on how to reverse a string.
Evan W
@Dirtier
Jan 10 2017 00:44
Your browser wont let you do this, so even if everything is working 100% right, you wont be able to see anything you're doing with React
You need a server.js file
And to use something like Express.js to setup a localhost
mikaelaf
@mikaelaf
Jan 10 2017 00:44
@Manish-Giri ok that did work but i dont understand why at all??
Evan W
@Dirtier
Jan 10 2017 00:44
@reforma Or if you have a Mac, you can setup a quick server
by typing this into your command prompt python -m SimpleHTTPServer 8000
Manish Giri
@Manish-Giri
Jan 10 2017 00:45
@mikaelaf what don't you understand?
William Reed
@reforma
Jan 10 2017 00:45
@Dirtier no mac sorry
Evan W
@Dirtier
Jan 10 2017 00:45
Ok then you're going to need Express
jv775
@jv775
Jan 10 2017 00:45

@Blockshot12

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
wordBanks("dog","big","ran","quickly");

mikaelaf
@mikaelaf
Jan 10 2017 00:46
like i literally did this:
this.setGear=function(blah){
    gear = blah;
  };
jv775
@jv775
Jan 10 2017 00:46
@Blockshot12 Could you please help?
Pieter Stokkink
@forkerino
Jan 10 2017 00:46
@Dirtier I think you're going a bit too fast for @reforma. It's a lot of information to take in from scratch.
mikaelaf
@mikaelaf
Jan 10 2017 00:46
@Manish-Giri and it worked, but i dont understand what i did
Evan W
@Dirtier
Jan 10 2017 00:46
npm install express
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:46
@FreakishLancer that is how I came up with the replace string - it is also what I used in a previous test and it worked fine - the only thing differently this time is the + "" that was added......I did however replace the "+" with "," and the console and test result remain the same.
Evan W
@Dirtier
Jan 10 2017 00:46
@forkerino Yes, but without it, nothing he's doing will ever work.
So it may not even be your React code
Trust me I had these same problems when I started with React
jv775
@jv775
Jan 10 2017 00:47
Could some one please help me with this problem?
Francois van Leersum
@Blockshot12
Jan 10 2017 00:47
@jv775
function wordBlanks(myNoun, myAdjective, myVerb,myAdverb){
  var result = "";
  //your code below this line
  result += “Some string including the 4 variables!”;
  //your code above this line
  return result;
}
miner_paul
@aeselden92
Jan 10 2017 00:47
What is the proper format for inserting escape keys?
William Reed
@reforma
Jan 10 2017 00:47
@Dirtier - i have the course files that are used as the example and i have set mine up just like the course files which i have saved in my folder and the course files work
this is why im so confussed
Pieter Stokkink
@forkerino
Jan 10 2017 00:47
@Dirtier True, so let's point him to some resources which will help him learn these things, because a chatroom isn't really a good place to learn npm/node/express
miner_paul
@aeselden92
Jan 10 2017 00:47
var myStr;
"FirstLine\n\SecondLine\\rThirdLine";
this is woefully wrong apperently
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:47
@FreakishLancer however when I change the code and add '' to it - the previosuly true statements are showing nolonger working
theStart.split('').reverse().join('')
Julia
@medusabeast
Jan 10 2017 00:47
stumped still..not sure what to do with statement I know its missing but idek..
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line 
  switch (val)
  {
    case 1: 
       caseInSwitch ("alpha");
    break;
    case 2: 
      caseInSwitch ("beta");
    break;
    case 3: 
      caseInSwitch ("gamma");
    break;
    case 4:
      caseInSwitch ("delta");
  }


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

// Change this value to test
caseInSwitch(2);
Manish Giri
@Manish-Giri
Jan 10 2017 00:48
@mikaelaf so in plain english, it's like saying, okay, I want to set my gear value to blah, and when you call the function, like myCar.setGear(10); it sets gear to 10.
jv775
@jv775
Jan 10 2017 00:48
@Blockshot12 yes, that's the problem
Pieter Stokkink
@forkerino
Jan 10 2017 00:48
@ikliptic post your current code please
Julia
@medusabeast
Jan 10 2017 00:48
@forkerino thank you for your approach to learning properly!
CamperBot
@camperbot
Jan 10 2017 00:48
medusabeast sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 590 | @forkerino |http://www.freecodecamp.com/forkerino
Julia
@medusabeast
Jan 10 2017 00:48
HI @Manish-Giri
Pieter Stokkink
@forkerino
Jan 10 2017 00:48
@medusabeast :+1:
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:49
@forkerino here you go
Tony
@FreakishLancer
Jan 10 2017 00:49
@ikliptic Okay, so to properly see what you are doing wrong, you have to test a string in the palindrome function, like say "_eye". Just put a return theStart or return reverseStr in your function and see what the console gives you.
mikaelaf
@mikaelaf
Jan 10 2017 00:49
ok, thanks @Manish-Giri :smile:
CamperBot
@camperbot
Jan 10 2017 00:49
mikaelaf sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3671 | @manish-giri |http://www.freecodecamp.com/manish-giri
jv775
@jv775
Jan 10 2017 00:49
@Blockshot12 I am really lost, after trying everything I really don't know what to do
Evan W
@Dirtier
Jan 10 2017 00:49
@reforma Ok well you're welcome to PM me if you want, but if I was you I would start with the basic tutorial on the React site
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:49
'''
function palindrome(str) {
// Good luck!
var theStart = str.toLowerCase().replace(/[^a-z0-9]/g + "");
var reverseStr = theStart.split().reverse().join();
return reverseStr === theStart;
}
palindrome("eye", "2A33a2", "2A3 3a2", "2_A33#A2", "racecar", "RaceCar", "race CAR");
'''
CamperBot
@camperbot
Jan 10 2017 00:49
:bulb: to format code use backticks! ``` more info
Pieter Stokkink
@forkerino
Jan 10 2017 00:49
@reforma there are some introductory exercises on node/npm/express in the backend part.
Evan W
@Dirtier
Jan 10 2017 00:49
@reforma It will go through and teach you how to get it all set up
William Reed
@reforma
Jan 10 2017 00:50
ok thank you both i will have a look
Evan W
@Dirtier
Jan 10 2017 00:50
Personally I wouldnt even start with React
If you're just getting into frameworks and learning to use node
Francois van Leersum
@Blockshot12
Jan 10 2017 00:50
@jv775 give me an example of what you tried?
Manish Giri
@Manish-Giri
Jan 10 2017 00:50
@mikaelaf welcome
jv775
@jv775
Jan 10 2017 00:51
@Blockshot12 Thank you so much, I am going to try to use the += operator (I didn't use this operator). Again thanks
Joseph
@revisualize
Jan 10 2017 00:51
@ikliptic What are you trying to do?
CamperBot
@camperbot
Jan 10 2017 00:51
jv775 sends brownie points to @blockshot12 :sparkles: :thumbsup: :sparkles:
:cookie: 305 | @blockshot12 |http://www.freecodecamp.com/blockshot12
Pieter Stokkink
@forkerino
Jan 10 2017 00:51
@ikliptic here are some comments:
function palindrome(str) {
// Good luck!
var theStart = str.toLowerCase().replace(/[^a-z0-9]/g + ""); // use , instead of +
var reverseStr = theStart.split().reverse().join(); // use "" inside your split/join
return reverseStr === theStart;
}
palindrome("eye", "2A33a2", "2A3 3a2", "2_A33#A2", "racecar", "RaceCar", "race CAR"); // just pass in one string, it will only take the first.
Evan W
@Dirtier
Jan 10 2017 00:51
@reforma React is a bit overkill. Try Vue, I lovveeeeeee it. Much easier to learn for beginners, and you can use it on codepen
Tony
@FreakishLancer
Jan 10 2017 00:52

@ikliptic Is that the code you have currently?

replace(/\w|_/g, "");

You could also use this in your replace.

William Reed
@reforma
Jan 10 2017 00:52
@Dirtier ok i will give it a try
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:53
function palindrome(str) {
  // Good luck!
  var theStart = str.toLowerCase().replace(/[^a-z0-9]/g + "");
  var reverseStr = theStart.split().reverse().join();
  return reverseStr === theStart;
}
palindrome("eye", "2A3*3a2", "2A3  3a2", "2_A3*3#A2", "racecar", "RaceCar", "race CAR");
Thank you
Adam
@adamakers
Jan 10 2017 00:53
Can someone help me understand this pen?
http://codepen.io/MrAdam/pen/rjOoPe?editors=1010
Is this asynchronous JS?
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:53
no comma - @forkerino trying your solution now
Evan W
@Dirtier
Jan 10 2017 00:53
Built this with Vue awhile back http://codepen.io/Dirtier/pen/rrgYrB
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:54
@forkerino your solution worked :)
Tony
@FreakishLancer
Jan 10 2017 00:54
I guess it's just easier to see the solution when you see it with a visual aid.
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:54
I still am unsure as to why the "" are needed within the split and join
Evan W
@Dirtier
Jan 10 2017 00:55
being split into strings
Pieter Stokkink
@forkerino
Jan 10 2017 00:55
@ikliptic it was a reworking of your solution. :)
you need the "", because you need to tell split where to split and join with what to join. So with an empty string, it splits at every character, and joins without putting anything in between.
Manish Giri
@Manish-Giri
Jan 10 2017 00:55
@ikliptic think of it like using scissors to cut paper, to cut it in half, you'd need to start at the center right? can't just start cutting at the top.
Evan W
@Dirtier
Jan 10 2017 00:55
and with split, you have to give the character to split it at
Like '' just means split at every single character. ' ' means split at the white spaces
Adel
@AdelMahjoub
Jan 10 2017 00:56
@reforma the course is outdated, at least you did not loose that much, next time don't purchase when the site don't provide the date and at least some of the course content
Evan W
@Dirtier
Jan 10 2017 00:56
.join('') means to join all characters. .join('/') means to join them all with /
Tony
@FreakishLancer
Jan 10 2017 00:57
This is what the documentation says: "If separator is an empty string, str is converted to an array of characters."
That should make it easier to understand, yes?
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:57
now that makes much more sense now - I assumed it was joining each individual array"word/string"
Pieter Stokkink
@forkerino
Jan 10 2017 00:57
@adamakers strictly speaking, it is. Your code is waiting for the input before executing the callback.
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:57
I have a lot to learn about javascript
@forkerino thank you
CamperBot
@camperbot
Jan 10 2017 00:58
ikliptic sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 591 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jan 10 2017 00:58
@ikliptic :+1:
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:58
@Dirtier thank you
CamperBot
@camperbot
Jan 10 2017 00:58
ikliptic sends brownie points to @dirtier :sparkles: :thumbsup: :sparkles:
:cookie: 266 | @dirtier |http://www.freecodecamp.com/dirtier
Evan W
@Dirtier
Jan 10 2017 00:58
.split(" ") is very useful. Its how you get an array of words
rather than letters
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:58
@FreakishLancer thank you
CamperBot
@camperbot
Jan 10 2017 00:58
ikliptic sends brownie points to @freakishlancer :sparkles: :thumbsup: :sparkles:
:cookie: 241 | @freakishlancer |http://www.freecodecamp.com/freakishlancer
Adam
@adamakers
Jan 10 2017 00:59
@forkerino I guess I was expecting the code to pause until the function finshed with the event
Julia
@medusabeast
Jan 10 2017 00:59
finally got it [:
Adrian T. Fisher
@ikliptic
Jan 10 2017 00:59
I see that now - you guys have been very very helful.
Albert L. C.
@sirus3020
Jan 10 2017 00:59

I have a question with looping.

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

will y go back to 0 after it finishes its loop? or it retains its value?

Pieter Stokkink
@forkerino
Jan 10 2017 00:59
@adamakers Nope, just the part inside the eventlistener
Julia
@medusabeast
Jan 10 2017 01:00
got a few q's on switch statements, any takers?
Pieter Stokkink
@forkerino
Jan 10 2017 01:00
@adamakers If you run code after your eventlistener, it will be run before your click.
Adam
@adamakers
Jan 10 2017 01:00
@forkerino thats very good to know now. I struggled with that bug for awhile. Thanks!
CamperBot
@camperbot
Jan 10 2017 01:00
adamakers sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 592 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jan 10 2017 01:01
@sirus3020 It will go back to 0 as often as needed
so str.length times
mitron6
@mitron6
Jan 10 2017 01:01
@sirus3020 On the inner look, y starts at zero for each different i
Evan W
@Dirtier
Jan 10 2017 01:01
@adamakers if you want to practice with async, take a look at Promises
Albert L. C.
@sirus3020
Jan 10 2017 01:01
alright thanks! @forkerino @mitron6
CamperBot
@camperbot
Jan 10 2017 01:01
sirus3020 sends brownie points to @forkerino and @mitron6 :sparkles: :thumbsup: :sparkles:
:cookie: 593 | @forkerino |http://www.freecodecamp.com/forkerino
:cookie: 440 | @mitron6 |http://www.freecodecamp.com/mitron6
Adam
@adamakers
Jan 10 2017 01:02
@Dirtier yea, I need to try to understand those again. I couldnt get it the first time around
Evan W
@Dirtier
Jan 10 2017 01:02
They're tricky, but sooooo worth it.
most often used with APIs, but you can use them for just about anything
Pieter Stokkink
@forkerino
Jan 10 2017 01:03
@Dirtier Any tips on resources/exercises for Promises?
I mean, I understand them conceptually, but need practice.
Evan W
@Dirtier
Jan 10 2017 01:04
I use the You Dont Know JS series
Adam
@adamakers
Jan 10 2017 01:04
@Dirtier yea, I want to work on APIs some more. I just need to finish the last 2 advanced projects. Im almost done with the tic-tac-toe
Evan W
@Dirtier
Jan 10 2017 01:04
YDK JS ES6 and Beyond goes pretty in-depth into Promises
liamllorin1
@liamllorin1
Jan 10 2017 01:05
Guys I have been having trouble with this algorithm challenge...
Pieter Stokkink
@forkerino
Jan 10 2017 01:05
@Dirtier Yes, I love those books, actually just read the async js one, but found it the most difficult, especially the part about generators with promises, it made my head spin.
jv775
@jv775
Jan 10 2017 01:05
@Blockshot12 Thanks a lot, I tried they code you showed me and it worked perfectly. Thanks a million.
CamperBot
@camperbot
Jan 10 2017 01:05
jv775 sends brownie points to @blockshot12 :sparkles: :thumbsup: :sparkles:
:warning: jv775 already gave blockshot12 points
Evan W
@Dirtier
Jan 10 2017 01:05
@forkerino Free online too https://github.com/getify/You-Dont-Know-JS
liamllorin1
@liamllorin1
Jan 10 2017 01:05
Problem:
William Cross
@williamtech814
Jan 10 2017 01:05
I'm missing the concept on this challenge: Accessing Objects Properties with Variables
Francois van Leersum
@Blockshot12
Jan 10 2017 01:05
@jv775 your welcome
Pieter Stokkink
@forkerino
Jan 10 2017 01:06
I guess I just need some more real world examples than functions named foo and bar returning 42. @Dirtier :P
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 01:06
i still dont get the foo bar thing
Evan W
@Dirtier
Jan 10 2017 01:07
all the projects requiring APIs are perfect for practicing them
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 01:07
is there specific reason why theyre always used in examples
Evan W
@Dirtier
Jan 10 2017 01:07
I used them in like 4 or 5 of them I think
If FCC went into promises, it would solve about 75% of the questions I come across on here when it comes to the API projects
Like why cant I use this data from the API call like this
liamllorin1
@liamllorin1
Jan 10 2017 01:08

Problem: Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays. My code is this: var arrnewnew = [];
var arrnew = [];
function largestOfFour(arr) {
for (var i in arr) {
arr[i].sort(function(b,a) {
return a - b;
});
arrnew.push(arr[i][0]);
}

return arrnew;
}

largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]);
The array this code outputs is almost correct BUT there are now spaces before each number in each index as the correct answers require... how do I add in this space before each number?? For help, my output is [9,35,97,1000000] NOT [9, 35, 97, 1000000]

Pieter Stokkink
@forkerino
Jan 10 2017 01:10
@Dirtier true, the api lessons definitely need improvement. But even just explaining what a callback is and letting people practice this, would already remove a ton of these questions.
Julia
@medusabeast
Jan 10 2017 01:10
CODE IN QUESTION:
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line 
  switch (val)
  {
    case 1: 
       return ("alpha");
       break;
    case 2: 
      return ("beta");
      break;
    case 3: 
      return ("gamma");
      break;
    case 4:
      return ("delta");
  }


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

// Change this value to test
caseInSwitch(1);
  1. Why the use of return instead of console.log?
  2. Is it because Mozilla provides example in terms of multiple chain statements for that command?
  3. Why do the break statements show up as errors?
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 01:11
console.log doesnt return anything
and i dont think you want to return ('beta')
you want to change the value of answer
Danilo Geronimo
@danilogeronimo
Jan 10 2017 01:11
@medusabeast console.log only shows the output. The return is to pass a value to whoever is calling the function
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 01:12
well youre doing return and break in each case
so that might be why theyre coming up as errors
Julia
@medusabeast
Jan 10 2017 01:12
@HeebieGeeBee @danilogeronimo so you wouldn't do console.log unless you were linking multiple statements, or not at all?
Danilo Geronimo
@danilogeronimo
Jan 10 2017 01:12
@medusabeast wich error?
Pieter Stokkink
@forkerino
Jan 10 2017 01:12
@medusabeast
  1. console.log prints to the console, it doesn't do anything else
  2. no
  3. the intention of the exercise is to asign the answer to the answer variable and returning that at the end. If you use return in a switch/case block, it stops the block (or rather the function), the break is therefore superfluous.
Parker Henderson
@parkerhendo
Jan 10 2017 01:13
Can I get some help with the "Condense arrays with reduce" challenge?
Im not sure what Im doing wrong
Pieter Stokkink
@forkerino
Jan 10 2017 01:13
@medusabeast I only do console.log if the exercise requires it, or if I want to know the value of something in the middle of a function when there is an error (i.e. for hunting bugs).
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 01:13
console.log is only needed if you wanted to see something printed in the console (f12 in chrome)
Julia
@medusabeast
Jan 10 2017 01:13
@forkerino thanks again guys! @danilogeronimo @HeebieGeeBee
CamperBot
@camperbot
Jan 10 2017 01:13
medusabeast sends brownie points to @forkerino and @danilogeronimo and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:warning: medusabeast already gave forkerino points
:cookie: 290 | @danilogeronimo |http://www.freecodecamp.com/danilogeronimo
:cookie: 499 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Pieter Stokkink
@forkerino
Jan 10 2017 01:14
@parkerhendo Show your code!
Julia
@medusabeast
Jan 10 2017 01:14
have to work on being a bit more... literal
Parker Henderson
@parkerhendo
Jan 10 2017 01:14

var singleVal = array.reduce(function(previousVal, currentVal){

  return previousVal+currentVal;

});

@forkerino ^^
Julia
@medusabeast
Jan 10 2017 01:14
lol
Ryan Foley
@brahms101
Jan 10 2017 01:14
can anyone help assign contents of variable a to variable b?
just starting java
var a = 7;
var b = var a;
I wrote that...
Danilo Geronimo
@danilogeronimo
Jan 10 2017 01:15
@forkerino :sparkles:
Parker Henderson
@parkerhendo
Jan 10 2017 01:15
@brahms101 try
var a = 7;
Stephen James
@sjames1958gm
Jan 10 2017 01:15
@brahms101 You should not repeat the var keyword so remove those var
Parker Henderson
@parkerhendo
Jan 10 2017 01:15
var b = a;
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 01:15
@parkerhendo are you just adding up all elelments in an array?
Parker Henderson
@parkerhendo
Jan 10 2017 01:15
yes
Pieter Stokkink
@forkerino
Jan 10 2017 01:15
@parkerhendo that's almost perfect.
Stephen James
@sjames1958gm
Jan 10 2017 01:15
@parkerhendo Maybe remove the extra var in front of singleVal
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 01:15
is there an array called array?
Dylan Hsiao
@greedylan
Jan 10 2017 01:16
why is it returning a extra space ??
function spinalCase(str) {
  var expRule1 = /\s[A-Z](?=[a-z])/g;

  return str.replace(expRule1, function(x){return "-" + x.toLowerCase();}).toLowerCase();
}
spinalCase('This Is Spinal Tap');
//returns this- is- signal -tap
Parker Henderson
@parkerhendo
Jan 10 2017 01:16
yes
Ryan Foley
@brahms101
Jan 10 2017 01:16
@parkerhendo thank you!
CamperBot
@camperbot
Jan 10 2017 01:16
brahms101 sends brownie points to @parkerhendo :sparkles: :thumbsup: :sparkles:
:cookie: 198 | @parkerhendo |http://www.freecodecamp.com/parkerhendo
Parker Henderson
@parkerhendo
Jan 10 2017 01:16
@brahms101 no problem!
Stephen James
@sjames1958gm
Jan 10 2017 01:16
@greedylan because you aren't matching the space so it gets passed through
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 01:17
@parkerhendo show all the code
Pieter Stokkink
@forkerino
Jan 10 2017 01:17
@parkerhendo the second var will just be ignored, because the JS engine sees that singleVar is already defined.
Parker Henderson
@parkerhendo
Jan 10 2017 01:17

var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.
singleVal = array.reduce(function(previousVal, currentVal){

  return previousVal + currentVal;

});

singleVal = array;

Dylan Hsiao
@greedylan
Jan 10 2017 01:17
@sjames1958gm in the regExp?
Stephen James
@sjames1958gm
Jan 10 2017 01:17
@parkerhendo You are overwriting the value assigned to singleVal
@greedylan Yes
aroojmumtaz
@aroojmumtaz
Jan 10 2017 01:17
Hi can someone please point out whats wrong with myy code here:
Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 01:17
oh ok
aroojmumtaz
@aroojmumtaz
Jan 10 2017 01:17

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val) {
case 1
return "alpha";
break;
case 2:
return "beta";
break;
case 3:
return "gamma";
break;
case 4:
return "delta";

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

// Change this value to test
caseInSwitch(1);

Stephen James
@sjames1958gm
Jan 10 2017 01:17
@greedylan Oops missed the \s sry
@aroojmumtaz You are missing a } after the switch
Parker Henderson
@parkerhendo
Jan 10 2017 01:18
I got it! Thanks for the help @HeebieGeeBee @sjames1958gm @forkerino
CamperBot
@camperbot
Jan 10 2017 01:18
parkerhendo sends brownie points to @heebiegeebee and @sjames1958gm and @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 500 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:cookie: 594 | @forkerino |http://www.freecodecamp.com/forkerino
:star2: 5250 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
aroojmumtaz
@aroojmumtaz
Jan 10 2017 01:19
@sjames1958gm nope doesnt work
Stephen James
@sjames1958gm
Jan 10 2017 01:19
@greedylan I was wrong before but I think the x has the space in it
Pieter Stokkink
@forkerino
Jan 10 2017 01:19
@HeebieGeeBee 500! :beers:
Danilo Geronimo
@danilogeronimo
Jan 10 2017 01:19
@aroojmumtaz
switch (val) {
case 1:  //<--- here
return "alpha";
break;
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 01:19
lol
Julia
@medusabeast
Jan 10 2017 01:19
lol!
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 01:19
oops didnt notice
Stephen James
@sjames1958gm
Jan 10 2017 01:19
@aroojmumtaz Also your first case is missin colon
aroojmumtaz
@aroojmumtaz
Jan 10 2017 01:19
ohhhhhhh
thanks @danilogeronimo and @sjames1958gm
CamperBot
@camperbot
Jan 10 2017 01:19
aroojmumtaz sends brownie points to @danilogeronimo and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 291 | @danilogeronimo |http://www.freecodecamp.com/danilogeronimo
:star2: 5251 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Dylan Hsiao
@greedylan
Jan 10 2017 01:20
@sjames1958gm yeah I see what you mean, the matched has a space
Pieter Stokkink
@forkerino
Jan 10 2017 01:20
night night, dear people
HeebieGeeBee
@HeebieGeeBee
Jan 10 2017 01:20
arent you mean to be changing the value of answer? not returning 'alpha' etc
night @forkerino
riz-lyon
@riz-lyon
Jan 10 2017 01:21
so im doing the "Storing values with the Assignment operator" and ive gotten "a should have a value of 7" and "b should have a value of 7" but I can't seem to get "a should be assigned to b with =" help please, this is my first time coding so im trying to get a feel for it
Stephen James
@sjames1958gm
Jan 10 2017 01:22
@riz-lyon assignment goes from right to left as in x = 1 is assigning 1 to x
@forkerino :sleeping:
@riz-lyon Also, you don't repeat the var keyword - so your code shouldn't have that as the setup code already did
riz-lyon
@riz-lyon
Jan 10 2017 01:23
thank you! @sjames1958gm
CamperBot
@camperbot
Jan 10 2017 01:23
riz-lyon sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5252 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jan 10 2017 01:24
@riz-lyon :+1:
FATAI D. SULE
@darefat
Jan 10 2017 01:27
so I am on check or Palindromes....DO anyone have any idea how to begin...i just need someone to juggle my memory
Margaret
@Margaret2
Jan 10 2017 01:28
@darefat reverse the string and check if it's equal to the original string...
obviously you will have to remove non-alphanumeric chars and lowercase it first
FATAI D. SULE
@darefat
Jan 10 2017 01:30
ok.
Albert L. C.
@sirus3020
Jan 10 2017 01:30

how can I prevent having a space at the start of the string?

newString += ' ' + str[i][y].toUpperCase();

but still having space between words.
Margaret
@Margaret2
Jan 10 2017 01:30
@sirus3020 when you declare the var, set it equal to "", then it will be an empty string
then you can add str[i][y].toUpperCase() + ' ' i guess
Moisés Man
@moigithub
Jan 10 2017 01:32
that will make the extra space at the end :)
Margaret
@Margaret2
Jan 10 2017 01:32
haha yeah, just realized. He could just remove the space later
beginning or end
FATAI D. SULE
@darefat
Jan 10 2017 01:32
@Margaret2 this is what i have

function palindrome(str) {
// Good luck!
function palindrome(str) {
var array=[];
var string="";

return true;
}

palindrome("eye");

Johnny
@JohnnyBizzel
Jan 10 2017 01:33
@darefat just starting then?
FATAI D. SULE
@darefat
Jan 10 2017 01:33
yep
Margaret
@Margaret2
Jan 10 2017 01:33
@darefat i would try working with str first... i think you need to use .replace() and .toLowerCase() to get it in the right format
Johnny
@JohnnyBizzel
Jan 10 2017 01:34
@darefat You can use a RegEx test
... to test for valid letters
FATAI D. SULE
@darefat
Jan 10 2017 01:34
oh...ok
Albert L. C.
@sirus3020
Jan 10 2017 01:34
hmm
Stephen James
@sjames1958gm
Jan 10 2017 01:35
@darefat First - don't repeat the function definition
Albert L. C.
@sirus3020
Jan 10 2017 01:35

i didn't get it. @Margaret2.

this is my code. it has a space at the front of string.

function titleCase(str) {

str = str.split(' ');
var newString = '';

for ( var i = 0; i < str.length; i++){
for( var y = 0; y < str[i].length; y++){
if ( y === 0) {
str[i][y].toUpperCase();
} else { newString += str[i][y].toLowerCase(); }
}
}

return newString;
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");

Stephen James
@sjames1958gm
Jan 10 2017 01:36
@sirus3020 If you are using an array - you can put the word back in the array and use join(' ')
Margaret
@Margaret2
Jan 10 2017 01:36
@sirus3020 why not just remove the space before you return the string
Albert L. C.
@sirus3020
Jan 10 2017 01:36
how can i remove the space?
Stephen James
@sjames1958gm
Jan 10 2017 01:37
@sirus3020 str[i][y].toUpperCase(); this won't do anything
Margaret
@Margaret2
Jan 10 2017 01:37
maybe use .substring()
Albert L. C.
@sirus3020
Jan 10 2017 01:37
sorry it should be newString += ' ' + str[i][y].toUpperCase();
Stephen James
@sjames1958gm
Jan 10 2017 01:37
@sirus3020 maybe only use one loop and use slice of first to upper case + slice of rest to lowercase and put back into array
Albert L. C.
@sirus3020
Jan 10 2017 01:38
alright will try your suggestions. thanks.
Margaret
@Margaret2
Jan 10 2017 01:38
@sirus3020 .substring(1) will return everything starting from the second char
Albert L. C.
@sirus3020
Jan 10 2017 01:39
@Margaret2 yup. it worked! thanks!
CamperBot
@camperbot
Jan 10 2017 01:39
sirus3020 sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 1118 | @margaret2 |http://www.freecodecamp.com/margaret2
no wiki entry for: pls declarationsvar studlycapvarvar camelcasevar propercamelcasevar titlecaseover assignmentsstudlycapvar 10camelcase camelcasepropercamelcase a stringtitlecaseover 9000
Zaluth
@Zaluth
Jan 10 2017 01:40
smallest commom multiple, idk how to finish this, help?
function smallestCommons(arr) {
  var sort = arr.sort(function compareNumbers(a, b) {
    return a - b;
  });

  var array = [];
  var firstAndLast;

  for(var i = sort[0]; i <= sort[1]; i++) {
    array.push(i);
    firstAndLast = sort[0]*sort[1];
  }

  // 1 - see if firstAndLast is divisible by each element of array;
  // 2 - if it is, return firstAndLast;
  // 3 - if it's not, multiply firstAndLast
  // by 2 (then 3, 4, 5...) and repeat step 2;
}

smallestCommons([2,5]);
CamperBot
@camperbot
Jan 10 2017 01:42
no wiki entry for: pls studlycapvar and titlecaseover should use camelcase in both declarations and assignments declarationsvar studlycapvarvar camelcasevar propercamelcasevar titlecaseover assignmentsstudlycapvar 10camelcase camelcasepropercamelcase a stringtitlecaseover 9000
mazury
@mazury
Jan 10 2017 01:44
Hi guys, I need help with Falsy Bouncer, would appreciate some hints on what i should be aiming at
function bouncer(arr) {
  function cat(value) {
  return value !== ??????
}

arr = arr.filter(cat);
  return arr;
}

bouncer([7, "ate", "", false, 9]);
Johnny
@JohnnyBizzel
Jan 10 2017 01:47
@adamgithub92 What thinks are classed as falsy?
... null ... 0 ... undefined .etc
mazury
@mazury
Jan 10 2017 01:48
yes, and?
@adamgithub92 test for these types of value... you know...with if (...) else...
mazury
@mazury
Jan 10 2017 01:53
so there should be what if together with filter method?
i mean if else
Hasan
@MHAhmed
Jan 10 2017 01:54
guys i got a quick question is it not possible to do a .reverse(); method on a string? or can it only be done on an array?
Johnny
@JohnnyBizzel
Jan 10 2017 01:55
@adamgithub92 mention people, then they get alerted.
@adamgithub92
function bouncer(arr) {
  function cat(value) {
  return value !== false // or ....
}

arr = arr.filter(cat);
  return arr;
}

bouncer([7, "ate", "", false, 9]);
Margaret
@Margaret2
Jan 10 2017 01:55
@MHAhmed only for array
Hasan
@MHAhmed
Jan 10 2017 01:56
@Margaret2 so does that mean if i want to reverse a string i would need to place the string into an array then reverse and then output it as a string again ?
Margaret
@Margaret2
Jan 10 2017 01:56
yep
Hasan
@MHAhmed
Jan 10 2017 01:57
@Margaret2 @JohnnyBizzel thank you
CamperBot
@camperbot
Jan 10 2017 01:57
mhahmed sends brownie points to @margaret2 and @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1108 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
:star2: 1119 | @margaret2 |http://www.freecodecamp.com/margaret2
Margaret
@Margaret2
Jan 10 2017 01:57
O.O i've passed @JohnnyBizzel
mazury
@mazury
Jan 10 2017 01:57
I've already been there, but didn't know how to implement OR, because doing this false || "" ||nullwasn't working @JohnnyBizzel
Johnny
@JohnnyBizzel
Jan 10 2017 01:57
@adamgithub92 sample code?
Margaret
@Margaret2
Jan 10 2017 01:58
bah, the system is rigged!!
Johnny
@JohnnyBizzel
Jan 10 2017 01:58
@Margaret2 Ha ha! :D
@Margaret2 put your name in "get ranking"
Margaret
@Margaret2
Jan 10 2017 01:58
ohhh lol
Manuel Almeida
@netstudenton
Jan 10 2017 01:58
I need help i got the JSON from wikipedia api but can't access the properties desired .
I wrote a console.log to show articles title but the console shows 'undefined '
https://codepen.io/netstudent/pen/jybxoO?editors=1111
mazury
@mazury
Jan 10 2017 01:59

@JohnnyBizzel ```js

function bouncer(arr) {
function cat(value) {

return value !== (false || "");
}

arr = arr.filter(cat);
return arr;
}

bouncer([7, "ate", "", false, 9]);```


function bouncer(arr) {
  function cat(value) {

  return value !== (false || "");
}

arr = arr.filter(cat);
  return arr;
}

bouncer([7, "ate", "", false, 9]);
Johnny
@JohnnyBizzel
Jan 10 2017 01:59
@adamgithub92
Can't do it like that
Margaret
@Margaret2
Jan 10 2017 01:59
@JohnnyBizzel no ranking found... :disappointed:
Johnny
@JohnnyBizzel
Jan 10 2017 02:00
@Margaret2 rigged!
Margaret
@Margaret2
Jan 10 2017 02:00
obvs
Johnny
@JohnnyBizzel
Jan 10 2017 02:00
I only appeared this month
@adamgithub92
 if (val != false && val != "" && val != 0 && val != NaN && 
             val != null && val != undefined)
chedli
@chedlii
Jan 10 2017 02:02
vjivii.PNG
nearly the same rpoblem
Johnny
@JohnnyBizzel
Jan 10 2017 02:03
@Margaret2 Is js-stack-from-scratch any good?
Margaret
@Margaret2
Jan 10 2017 02:03
@JohnnyBizzel yeah, i liked it, good intro to the various tools. It's not fully complete yet tho i don't think
he still has more chapters planned
Johnny
@JohnnyBizzel
Jan 10 2017 02:04
@Margaret2 I was doing this one...https://www.youtube.com/watch?v=1MOJdx_yZ0w
5 parts, all very long.
He says m'kay a lot.
mazury
@mazury
Jan 10 2017 02:05
thanks @JohnnyBizzel it worked :)
CamperBot
@camperbot
Jan 10 2017 02:05
adamgithub92 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1109 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Jan 10 2017 02:05
@adamgithub92 Anytime ;0)
Margaret
@Margaret2
Jan 10 2017 02:06
@JohnnyBizzel oh wow that's quite involved! do you like it?
Johnny
@JohnnyBizzel
Jan 10 2017 02:07
@Margaret2 It's ok. Me and Ankur, we forked it to work on the Voting app. Bit stuck now though :/
@Margaret2 It is a version of Yik Yak
Margaret
@Margaret2
Jan 10 2017 02:07
yeah i saw that
chedli
@chedlii
Jan 10 2017 02:08

function bouncer(arr) {
function isNotFalsy(value){
if (value !== false && value !== null && value !== 0 && value !== "" && value !== undefined && !isNaN(value))

  return value ;

}

var filetered = arr.filter(isNotFalsy);
return filetered;
}

bouncer([7, "ate", "", false, 9]);

Johnny
@JohnnyBizzel
Jan 10 2017 02:08
@Margaret2 I stuck what I did on GitHub https://github.com/JohnnyBizzel/yikyak
And forked that.
Took me about 5 days!
Margaret
@Margaret2
Jan 10 2017 02:09
@JohnnyBizzel have you got to the MongoDB part? is it tough?
cdrain seemed to be having a hard time with it... :D
Johnny
@JohnnyBizzel
Jan 10 2017 02:10
@Margaret2 I think MongoDb is quite easy, but I have seen others struggle. I'm sure you are capable!
Margaret
@Margaret2
Jan 10 2017 02:10
haha thx @JohnnyBizzel
CamperBot
@camperbot
Jan 10 2017 02:10
:star2: 1110 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
margaret2 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
Johnny
@JohnnyBizzel
Jan 10 2017 02:10
@Margaret2 Did you do learnyoumongo yet?
Margaret
@Margaret2
Jan 10 2017 02:11
not yet
still on the node stuff
Johnny
@JohnnyBizzel
Jan 10 2017 02:11
@Margaret2 The hardest part is installing it on Cloud9!
Margaret
@Margaret2
Jan 10 2017 02:11
lol
i really like c9 though, it's pretty awesome IMO
Johnny
@JohnnyBizzel
Jan 10 2017 02:12
@Margaret2 Make sure you read: https://docs.c9.io/docs/setup-a-database
The FCC instructions are not so in depth!
Margaret
@Margaret2
Jan 10 2017 02:12
my codepen has been pretty dry lately, because i've been busy on c9! :worried:
and yeah, i will
Johnny
@JohnnyBizzel
Jan 10 2017 02:13
I do all the node stuff on C9 now. Even though I have a local install.
:cloud: is the future!
Margaret
@Margaret2
Jan 10 2017 02:15
yeah, something got messed up with my node shortcut on my computer, so i can't save my font/color preferences... just doing it on c9 too
Johnny
@JohnnyBizzel
Jan 10 2017 02:16
:+1:
Hasan
@MHAhmed
Jan 10 2017 02:29
```

function palindrome(str) {
  // Good luck!
  var remove = /[ ._#*,0123456789]/g;
  var newStr = str.replace(remove, '');
  var lowerCaseStr = newStr.toLowerCase();
  var splitStr = lowerCaseStr.split('');
  var lowerCaseArray = [];
    lowerCaseArray.push(splitStr);
  var lowerCaseReverseArray = lowerCaseArray[0].reverse();
  var newReverseStr = lowerCaseReverseArray.join('');

  if (lowerCaseStr === newReverseStr) {
    return true;
  } else if (lowerCaseStr !== newReverseStr) {
    return false;
  }

  return error;
}



palindrome("1 eye for of 1 eye.");
guys i need some help all but two of my palindromes work
Tony
@FreakishLancer
Jan 10 2017 02:30
Oh wow. That is some very long code for the palindrome challenge.
Hasan
@MHAhmed
Jan 10 2017 02:31
the palindromes for the special characters dont work because i removed them
palindrome("1 eye for of 1 eye.") returns true when it should be false
Johnny
@JohnnyBizzel
Jan 10 2017 02:32
@MHAhmed Check the rules
Tony
@FreakishLancer
Jan 10 2017 02:32
I think the most common problem people have here is the removal of special characters and the splitting/reversing/joining of strings.
@MHAhmed I think you could also do well by removing most of your variable declarations.
Hasan
@MHAhmed
Jan 10 2017 02:33
@JohnnyBizzel which part specifically ?
Margaret
@Margaret2
Jan 10 2017 02:33
@MHAhmed you shouldn't have removed numbers
Johnny
@JohnnyBizzel
Jan 10 2017 02:34

@MHAhmed numbers are needed

We'll also pass strings with special symbols, such as "2A33a2", "2A3 3a2", and "2_A33#A2".

Hasan
@MHAhmed
Jan 10 2017 02:34
ow yes it said non-alphanumeric lol
palindrome("0_0 (: /-\ :) 0-0") << thats the only one that dont work now
Tony
@FreakishLancer
Jan 10 2017 02:35
@MHAhmed instead of listing the characters you want to remove, there are special expressions for the characters you want to remove: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#Special_characters_meaning_in_regular_expressions
Hasan
@MHAhmed
Jan 10 2017 02:36
@FreakishLancer thanks i will take a look
CamperBot
@camperbot
Jan 10 2017 02:36
mhahmed sends brownie points to @freakishlancer :sparkles: :thumbsup: :sparkles:
:cookie: 246 | @freakishlancer |http://www.freecodecamp.com/freakishlancer
Hasan
@MHAhmed
Jan 10 2017 02:36
@JohnnyBizzel @Margaret2 thanks for the help
CamperBot
@camperbot
Jan 10 2017 02:36
mhahmed sends brownie points to @johnnybizzel and @margaret2 :sparkles: :thumbsup: :sparkles:
:warning: mhahmed already gave margaret2 points
:warning: mhahmed already gave johnnybizzel points
Hasan
@MHAhmed
Jan 10 2017 02:38
var remove = /[ ._#*,]/g; guys in here i put a space to remove the space is that a reason why it is removing the zero ?
Johnny
@JohnnyBizzel
Jan 10 2017 02:38
@MHAhmed :+1: :candy:
@MHAhmed not sure.
Hasan
@MHAhmed
Jan 10 2017 02:39
wait i never removed some of the special characters i should read that syntax lancer sent
Tony
@FreakishLancer
Jan 10 2017 02:40
What is the console giving you when you are putting the string that is not returning the correct boolean value?
Johnny
@JohnnyBizzel
Jan 10 2017 02:40
@MHAhmed Seems to be working
Hasan
@MHAhmed
Jan 10 2017 02:40
yep its working now i was missing some replace rules
```

function palindrome(str) {
  // Good luck!
  var remove = /[():/\- ._#*,]/g;
  var newStr = str.replace(remove, '');
  var lowerCaseStr = newStr.toLowerCase();
  var splitStr = lowerCaseStr.split('');
  var lowerCaseArray = [];
    lowerCaseArray.push(splitStr);
  var lowerCaseReverseArray = lowerCaseArray[0].reverse();
  var newReverseStr = lowerCaseReverseArray.join('');

  if (lowerCaseStr === newReverseStr) {
    return true;
  } else if (lowerCaseStr !== newReverseStr) {
    return false;
  }

  return error;
}



palindrome("0_0 (: /-\ :) 0-0");
so anyone want to tell me how to improve and write less? and make it more efficient ?
Tony
@FreakishLancer
Jan 10 2017 02:42
@MHAhmed You don't have to make so many variable declarations. You can also do split().reverse().join(); on one line.
@MHAhmed I think the best average solution on here was just 3 lines.
Hasan
@MHAhmed
Jan 10 2017 02:43
okay i will test it out
its the best way to learn not to just accept one answer but to improve your code
Tony
@FreakishLancer
Jan 10 2017 02:44
You don't have to do the "return true". The "lowerCaseStr === newReverseStr" is enough. Just put that in a return statement and it will return true if it is true and false if it is not.
Hasan
@MHAhmed
Jan 10 2017 02:44
@FreakishLancer okay i did not know that
Tony
@FreakishLancer
Jan 10 2017 02:44
Your code still works, but yes, it is definitely good to refactor.
Greg Duncan
@GregatGit
Jan 10 2017 02:46
@MHAhmed it won't get past that if statement so return error isn't need either
Hasan
@MHAhmed
Jan 10 2017 02:46
btw guys i did try and do it on one line by changing methods but some of them did not work and kept giving my syntax errors
chaining *
Tony
@FreakishLancer
Jan 10 2017 02:47
Hm, can you show us your code now?
Hasan
@MHAhmed
Jan 10 2017 02:47
split().reverse().join(); like this...
split only works on strings ? and reverse only on array??
Tony
@FreakishLancer
Jan 10 2017 02:47
Add "" for your split() and join(), of course.
@MHAhmed When you split the string, you turn it into an array, which you can use reverse() on.
Vizij
@Vizij
Jan 10 2017 02:48
@MHAhmed Yeah. split(""), same for join, you need the empty string or it returns the whole thing.
Hasan
@MHAhmed
Jan 10 2017 02:49
thanks guys i will try it out again tomorrow and try to improve the working code to make it better
its 2:50am here i need to be up for 7:30am so going to bed now
Tony
@FreakishLancer
Jan 10 2017 02:49
@MHAhmed No problem. I am at about the same pace as you but like to try to help.
Hasan
@MHAhmed
Jan 10 2017 02:50
yes i like to understand what i am doing and learn rather than just pass the stuff
Kyle Daughenbaugh
@kyledaug
Jan 10 2017 03:01
Feeling dumb, trying to understand escape sequences in strings
Manish Giri
@Manish-Giri
Jan 10 2017 03:02
@kyledaug what's the problem?
Kyle Daughenbaugh
@kyledaug
Jan 10 2017 03:03
the code: var myStr="FirstLine\n\SecondLine\rThirdLine";
shouldn't the \n parts of the string cause a new line break?
'''
var myStr="FirstLine\n\SecondLine\rThirdLine";
'''
CamperBot
@camperbot
Jan 10 2017 03:05
:bulb: to format code use backticks! ``` more info
Kyle Daughenbaugh
@kyledaug
Jan 10 2017 03:05
oh boy. This has not been a great day of camping.
aroojmumtaz
@aroojmumtaz
Jan 10 2017 03:05
please help with Using Objects for Lookups
Robie Sun
@robie01
Jan 10 2017 03:05
hey does anyone here know how to generate a 12/16 teams into 4 groups? any help would be much appreciated
aroojmumtaz
@aroojmumtaz
Jan 10 2017 03:06
Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.

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"

};

val = "Adams";
result = lookup[val];

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

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

whats the correct code?
Kyle Daughenbaugh
@kyledaug
Jan 10 2017 03:07
var myStr="FirstLine\n\SecondLine\rThirdLine";
sorry, new to this. Learning how to share code properly. Still not sure what I'm doing wrong with the new line command.
Manish Giri
@Manish-Giri
Jan 10 2017 03:08
@aroojmumtaz delete this line val = "Adams";
rest looks good.
Richard Monastra
@rmonastra
Jan 10 2017 03:08
Are Users stories vague, so learn to be creative?
Manish Giri
@Manish-Giri
Jan 10 2017 03:09
@kyledaug the \ around SecondLineneed to be escaped too.
Vizij
@Vizij
Jan 10 2017 03:09
@kyledaug Newline is okay. I think that lesson asks you for backslashes before and after SecondLine, you're missing the escape on the first backslash, and the second one is missing entirely.
Kuomu Fan
@txbluebee
Jan 10 2017 03:10

im stuck with this challenge: Stand in Line.

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

js

function nextInLine(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(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
can someone show me how to pass the test
Manish Giri
@Manish-Giri
Jan 10 2017 03:11
@txbluebee you haven't tried any code yet
Richard Monastra
@rmonastra
Jan 10 2017 03:11
What do you have so far?
Kuomu Fan
@txbluebee
Jan 10 2017 03:13
ok let me tried first
Kyle Daughenbaugh
@kyledaug
Jan 10 2017 03:14
` @Manish-Giri @Vizij you guys are life savers, thanks!
CamperBot
@camperbot
Jan 10 2017 03:14
kyledaug sends brownie points to @manish-giri and @vizij :sparkles: :thumbsup: :sparkles:
:cookie: 270 | @vizij |http://www.freecodecamp.com/vizij
:star2: 3676 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jan 10 2017 03:14
@kyledaug :+1:

@txbluebee here's the main thing for the challenge -

Add the number to the end of the array, then remove the first element of array.

use .push() for the first part, .shift() for the second.
Kyle Daughenbaugh
@kyledaug
Jan 10 2017 03:17
out of curiosity, the notes on the left say that \b will perform a backspace. Does this literally mean that the last character prior to \b in the string will be deleted? Am I way off?
Kuomu Fan
@txbluebee
Jan 10 2017 03:20
@Manish-Giri
```
here is my code

function nextInLine(arr, item) {
  // nexYour code here
  nextInline.push([arr, 3]);
  nextInline.shift();
  return item;  // Change this line
}
what i did wrong?
Fidela James
@fidela
Jan 10 2017 03:22
I'm so done with this "Iterate Through an Array with a For Loop" lesson
Manish Giri
@Manish-Giri
Jan 10 2017 03:22
@txbluebee :point_up: January 9, 2017 10:06 PM
Yi
@ycoding007
Jan 10 2017 03:22
hi,all, i managed to do the "where do I belong", here is the code, my comment is in the code
if you have better idea, please instruct, thank you
function getIndexToIns(arr, num) {
    arr.sort(function(a, b) {
        return a - b;
        });
   for (var i=0;i<=arr.length;i++) {
     if (num==arr[i]) {
       return i;
     }
     //the next line of code is kind of cheating because it's there
     //to make sure the index number doesnt exceed the array index number...
     else if (i>=arr.length) {
       return arr.length;
     }
     else if(num>=arr[i] && num<=arr[i+1]) {
       return i+1;
       }
   }


}

getIndexToIns([2,5,10], 19);
Manish Giri
@Manish-Giri
Jan 10 2017 03:22
pls read through my posts from that link
@txbluebee
TracesOfNuts
@TracesOfNuts
Jan 10 2017 03:23
@kyledaug you can try with and without /b to see the effects
Anurag Gupta
@AnuraGupta97
Jan 10 2017 03:23
Hey guys. can anyone help me with basic algorithm scripting challenges?
TracesOfNuts
@TracesOfNuts
Jan 10 2017 03:23
@txbluebee the .push method is for the array arr not the function nextInLine
TracesOfNuts
@TracesOfNuts
Jan 10 2017 03:24
@fidela is there anyway I can help?
@AnuraGupta97 sure! what seems to be the problem?
Anurag Gupta
@AnuraGupta97
Jan 10 2017 03:25
@TracesOfNuts third last challenge "Seek and Destroy".
TracesOfNuts
@TracesOfNuts
Jan 10 2017 03:26
@AnuraGupta97 what do you have so far? share your code
Richard Monastra
@rmonastra
Jan 10 2017 03:26
@txbluebee , .shift should be in your "return".
Anurag Gupta
@AnuraGupta97
Jan 10 2017 03:27
function destroyer(arr) {
var b=[];
var l=arguments.length;
b=arr.filter(function(k){
for(var i=1;i<l;i++) {
return k!==arguments[i];
}
});
return b;
}
i know its totally wrong.
i can't figure it out.
Kuomu Fan
@txbluebee
Jan 10 2017 03:28
@TracesOfNuts @rmonastra anks for the tips let me try now
Richard Monastra
@rmonastra
Jan 10 2017 03:28
'''
.shift
CamperBot
@camperbot
Jan 10 2017 03:28
:bulb: to format code use backticks! ``` more info
Fidela James
@fidela
Jan 10 2017 03:28
please! @TracesOfNuts
Robie Sun
@robie01
Jan 10 2017 03:28
is there any shortcut on how to send the console in here? sorry im new and i dont create shortcut either on my own mac
TracesOfNuts
@TracesOfNuts
Jan 10 2017 03:29
@AnuraGupta97 ah yeah I was stucked on this one too.. hmm you should check out
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments
go the examples section
Jason S
@jsirirathasuk
Jan 10 2017 03:29
kinda confused here, I'm doing the "using objects for lookup" in the JS section and I'm completely confused the with "lookup" table
Ogundele Olumide
@Lumexralph
Jan 10 2017 03:29
@robie01 what do you mean by short cut? you mean format your code?
TracesOfNuts
@TracesOfNuts
Jan 10 2017 03:29
@fidela you wanna share your code?
Fidela James
@fidela
Jan 10 2017 03:29
I set var myTotal = 0 or 20 but that doesn't satisfy the requirement .
Ogundele Olumide
@Lumexralph
Jan 10 2017 03:30
@jsirirathasuk what've you done?
Jason S
@jsirirathasuk
Jan 10 2017 03:30
var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
};
@Lumexralph
Fidela James
@fidela
Jan 10 2017 03:31

// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line

var myTotal = 0;
for (var i= 0; i < myArr.length; i++){
myTotal += myArr[i];
}

Ogundele Olumide
@Lumexralph
Jan 10 2017 03:31
@jsirirathasuk you've not done anything, what're you trying to do?
Jason S
@jsirirathasuk
Jan 10 2017 03:31
i followed the example they gave us
Fidela James
@fidela
Jan 10 2017 03:31
Declare and initialize a variable total to 0. Use a for loop to add the value of each element of the myArr array to total.
Nick Schimek
@NickSchimek
Jan 10 2017 03:31
I've been working on the "no repeats please" in the advanced algorithm scripting. Does anyone have any insight on an efficient algorithm to solve this problem?
Kyle Daughenbaugh
@kyledaug
Jan 10 2017 03:31
@rmonastra I can't seem to get /b to render the way they described but I understand now. Thanks for that!
CamperBot
@camperbot
Jan 10 2017 03:31
kyledaug sends brownie points to @rmonastra :sparkles: :thumbsup: :sparkles:
:cookie: 341 | @rmonastra |http://www.freecodecamp.com/rmonastra
Jason S
@jsirirathasuk
Jan 10 2017 03:31
@Lumexralph they said to convert the switch case to the lookup format. I followed the example and still confused.
Anurag Gupta
@AnuraGupta97
Jan 10 2017 03:32
@TracesOfNuts I checked it out but I still can't figure it out. how can i use filter and the loop in this. can you please help me with the code.
Ogundele Olumide
@Lumexralph
Jan 10 2017 03:32
@jsirirathasuk paste your code
Jason S
@jsirirathasuk
Jan 10 2017 03:33
var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
};
I
Jean Marco Romero
@volkranium
Jan 10 2017 03:33
function nextInLine(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(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
can you help me this one guys?
TracesOfNuts
@TracesOfNuts
Jan 10 2017 03:33
@fidela hmm.. I think coz you declared myTotal as 0
Jean Marco Romero
@volkranium
Jan 10 2017 03:33
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
TracesOfNuts
@TracesOfNuts
Jan 10 2017 03:33
@fidela should be an array
Ogundele Olumide
@Lumexralph
Jan 10 2017 03:33
@volkranium arr is an array, how would you push item to array?
Richard Monastra
@rmonastra
Jan 10 2017 03:33
@volkranium , you'll be using .push and .shift
Jason S
@jsirirathasuk
Jan 10 2017 03:33
@volkranium your .push and .shift should be in the nextInLine function
Nicholas J Coetzee
@nickycoetzee
Jan 10 2017 03:33

For some reason I can't get this code to execute. It is suppose to return "alpha"/ "beta" etc. if my caseInSwitch variable = 1/2/3/4. This is my code: function caseInSwitch(val) {
var answer = "";
// Only change code below this line

switch (answer){
case 1:
console.log("alpha");
break;

case 2:
console.log("beta");
break;

case 3:
console.log("gamma");
break;

case 4:
console.log("delta");
break;
}
// Only change code above this line
return answer;
}

// Change this value to test
caseInSwitch(4);

Robie Sun
@robie01
Jan 10 2017 03:34
what is var means? pls help
Ogundele Olumide
@Lumexralph
Jan 10 2017 03:34
@jsirirathasuk do you understand the construct of switch statement?
TracesOfNuts
@TracesOfNuts
Jan 10 2017 03:34
@jsirirathasuk that's the given code right?
@robie01 var means variable
Nicholas J Coetzee
@nickycoetzee
Jan 10 2017 03:34
@robie01 var = variable
Jason S
@jsirirathasuk
Jan 10 2017 03:34
@nickycoetzee it should case 1: answer = "alpha": break;
Fidela James
@fidela
Jan 10 2017 03:34
shuld it be 20
Nicholas J Coetzee
@nickycoetzee
Jan 10 2017 03:34
@jsirirathasuk thanx
CamperBot
@camperbot
Jan 10 2017 03:34
nickycoetzee sends brownie points to @jsirirathasuk :sparkles: :thumbsup: :sparkles:
:cookie: 205 | @jsirirathasuk |http://www.freecodecamp.com/jsirirathasuk
Jason S
@jsirirathasuk
Jan 10 2017 03:35
@Lumexralph yeah i understand the switch case format. i don't understand the "lookup" format
Ogundele Olumide
@Lumexralph
Jan 10 2017 03:35
@nickycoetzee your switch should execute expression val not answer and for each cases assign the corresonding string to answer e'g answer = "alpha"
@robie01 var is a keyword in js used to declare a variable
Jason S
@jsirirathasuk
Jan 10 2017 03:36
@TracesOfNuts // Only change code below this line
switch(val) {
case "alpha":
result = "Adams";
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
}
that is the given code @TracesOfNuts
Nicholas J Coetzee
@nickycoetzee
Jan 10 2017 03:36
@Lumexralph thanx
CamperBot
@camperbot
Jan 10 2017 03:36
nickycoetzee sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 704 | @lumexralph |http://www.freecodecamp.com/lumexralph
Nicholas J Coetzee
@nickycoetzee
Jan 10 2017 03:36
@jsirirathasuk thanx
CamperBot
@camperbot
Jan 10 2017 03:36
:warning: nickycoetzee already gave jsirirathasuk points
nickycoetzee sends brownie points to @jsirirathasuk :sparkles: :thumbsup: :sparkles:
TracesOfNuts
@TracesOfNuts
Jan 10 2017 03:37
@fidela oh ok. I was mistaken. try putting the var i outside the for loop
Jean Baptiste Kwizera
@jbkwizera
Jan 10 2017 03:37
Why does this loop run forever when I'm changing arr and there should be a time when !func doesn't suffice? Here is the code:
function findIt(arr, func){
  for(var i=0; i<arr.length; i++){
    while(!func(arr[i])){
      arr = arr.slice(i+1);
    }
  }
  return arr;
}
findIt(arr, function(n){ return n < 2});
Ogundele Olumide
@Lumexralph
Jan 10 2017 03:38
@jsirirathasuk your switch will have an expression to check, and case will compare all the properties of lookup object and for each cases you'll return the value of that property in lookup object
TracesOfNuts
@TracesOfNuts
Jan 10 2017 03:39
@jsirirathasuk oh ok my bad. yeah your original code seems right. but i think its just missing something
Fidela James
@fidela
Jan 10 2017 03:39
outside the for loop?
TracesOfNuts
@TracesOfNuts
Jan 10 2017 03:40
@fidela var i; for ( i = 0;....)
dangdien
@dangdien
Jan 10 2017 03:40

Hi, I'm have a problem with comparing a variable with null.
I have a filter function :

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  return arr.filter(function(val){
    switch(val) {
      case false:
      case null;
      case 0:
      case "":
      case undefined:
      case NaN: return false;
      default: return true;
    }
  });
}
bouncer([1, null, NaN, 2, undefined]);

this function return [1,null,2]
my question is : why null does not filtered out of my array?

TracesOfNuts
@TracesOfNuts
Jan 10 2017 03:40
@jsirirathasuk result=result[val];
Ogundele Olumide
@Lumexralph
Jan 10 2017 03:40
@jbkwizera the while loop will run forever except you have a condition to check in the while loop
Fidela James
@fidela
Jan 10 2017 03:41

var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line

var myTotal = 0;
var i; for ( i= 0; i < myArr.length; i++){
myTotal += myArr[i];
}

Ogundele Olumide
@Lumexralph
Jan 10 2017 03:41
@dangdien do you know how filter method of an array works?
Jean Baptiste Kwizera
@jbkwizera
Jan 10 2017 03:42
@Lumexralph so the condition must be in the loop...it can't be a statement for while?
Peyton
@Peydunn
Jan 10 2017 03:42
function golfScore(par, strokes) {
  // Only change code below this line
    if (strokes === 1){
    return "Hole-in-one!";
  }else if (strokes <= par - 2){
    return "Eagle";
  }else if (strokes === par - 1){
    return "Birdie";
  }else if (strokes === par){
    return "par";
  }else if (strokes === par + 1){
    return "Bogey";
  }else if (strokes === par + 2){
    return "Double Bogey";
  }else if (strokes >= par + 3){
    return "Go Home!";
  }

  // Only change code above this line
}

// Change these values to test
golfScore(5, 5);
it says my strokes === par isn't right. I tested with golfScore (4,4) and golfScore(5,5) and they both give par, however the lesson is showing it as incorrect... any guesses?
dangdien
@dangdien
Jan 10 2017 03:44

@Lumexralph I edited my question:
Hi, I'm have a problem with comparing a variable with null.
I have a filter function :

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  return arr.filter(function(val){
    switch(val) {
      case false:
      case null:
      case 0:
      case "":
      case undefined:
      case NaN: return false;
      default: return true;
    }
  });
}
bouncer([1, null, NaN, 2, undefined]);

this function return [1,null,2]
my question is : why null is not filtered out of my array?

Ogundele Olumide
@Lumexralph
Jan 10 2017 03:45
@jbkwizera there has to be a way to make the condition in the while loop fail , else you're dealing with an infinite loop
Peyton
@Peydunn
Jan 10 2017 03:45
lol, it's because P in par wasn't capped
oh man
Tony
@FreakishLancer
Jan 10 2017 03:45
@Peydunn Your "par" string isn't capitalized, I believe.
Oh.
Hehe.
Peyton
@Peydunn
Jan 10 2017 03:45
Silly mistake
:P
Thanks @FreakishLancer anyways :clap:
CamperBot
@camperbot
Jan 10 2017 03:45
peydunn sends brownie points to @freakishlancer :sparkles: :thumbsup: :sparkles:
:cookie: 249 | @freakishlancer |http://www.freecodecamp.com/freakishlancer
Tony
@FreakishLancer
Jan 10 2017 03:46
I try to help. ^.^
Ogundele Olumide
@Lumexralph
Jan 10 2017 03:46
@dangdien do you know how filter works?
Jason S
@jsirirathasuk
Jan 10 2017 03:46
lol still not getting the answer @TracesOfNuts
Phillip
@psnider22
Jan 10 2017 03:47
could one of you take a look at this and tell me why my script isnt working? http://codepen.io/psnider22/full/rjOMjV/
dangdien
@dangdien
Jan 10 2017 03:48
@Lumexralph yes, filter function is passed a callback function which takes the current value (val) as an argument. Filter function will filter out the element if the callback function return false
Andrew Rowe
@andrewrowe
Jan 10 2017 03:50
Snip20170109_1.png
Can someone help me understand why this isn't working?
Ogundele Olumide
@Lumexralph
Jan 10 2017 03:51
@dangdien you sure it's null or NaN ?
Robie Sun
@robie01
Jan 10 2017 03:51
@nickycoetzee , im quite confuse with this var because we never use this at school . we use string instead.
Tyler Del Rosario
@TylerDelRosario
Jan 10 2017 03:52
Could anyone help me out with Sorted Union?
Ogundele Olumide
@Lumexralph
Jan 10 2017 03:53
@andrewrowe don't use a for with filter filter is already looping through the array
dangdien
@dangdien
Jan 10 2017 03:53
@Lumexralph the challenge is I have to remove all falsy values (false, null, 0, "", undefined, and NaN.) in my array.
Andrew Rowe
@andrewrowe
Jan 10 2017 03:54
@Lumexralph Okay, I was trying to use that to loop through the other arguments to compare with the filtered array elements
Ogundele Olumide
@Lumexralph
Jan 10 2017 03:54
@dangdien you asked why null was not filtered and looking at it, i asked if you meant NaN instead of null, null will be filtered but not NaN
dangdien
@dangdien
Jan 10 2017 03:57

@Lumexralph No, as I said, this function ```
function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(function(val){
switch(val) {
case false:
case 0:
case null:
case "":
case undefined:
case NaN: return false;
default: return true;
}
});
}
bouncer([0, null, NaN, 2, undefined]);

return ```[0,null,2]

which means that null is not filtered out. And my question is why null is not filtered out?

//NaN is filtered out.

Ogundele Olumide
@Lumexralph
Jan 10 2017 03:57
@andrewrowe the callback that filter takes has 3 arguments by default the element, the index of the element and the array that's being filtered take advantage of that instead of using for loop, you'll be looping twice in the different order if you do that
check this https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
@dangdien this is what will be returned [ NaN, 2 ] only if there's an error somewhere
dangdien
@dangdien
Jan 10 2017 03:59
@Lumexralph No, it's not. It'll return [1,null,2], null is not filtered out but NaN is. You can try with your console.
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:00
@dangdien i just tried your code and this is what's returned [ NaN, 2 ] which is right judging by the logics in your code
@dangdien how will 1 even be there when it's not in the array? seen it yet, that it's NaN that's not filtered out not null?
Andrew Rowe
@andrewrowe
Jan 10 2017 04:04
@Lumexralph I guess what I'm struggling with is how to get the other arguments in the initial function passed to the callback for filter in order to compare the array I'm filtering with the these arguments.
dangdien
@dangdien
Jan 10 2017 04:05
@Lumexralph Sorry, my bad, just tried and it returned [1, NaN, 2]. So why NaN is not filtered out?
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:05
@andrewrowe don't worry about that, you want to remove falsy values from an array, right?
@dangdien because NaN is not equal to itself
Andrew Rowe
@andrewrowe
Jan 10 2017 04:05
@Lumexralph Yes
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:06
@dangdien NaN !== NaN is true while NaN === NaN is false which is in your callback function
Manuel Almeida
@netstudenton
Jan 10 2017 04:07
Some could test my wikipedia viewer please !!!!
https://codepen.io/netstudent/full/jybxoO?editors=1111
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:08
@andrewrowe filter will pick each value itself with the help of the callback function, all you need to do is make the callback return a boolean when each of the elements that's in the array is picked
@andrewrowe
var arr = [1, 3, 4];
var newArray = arr.filter(function(element, index) {
    return element < 4;
});
newArray[1, 3]// that's how it works
Andrew Rowe
@andrewrowe
Jan 10 2017 04:10
@Lumexralph But how do I compare the values in my array with the values I'm supposed to be "destroying" if I can't pass them in?
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:13
@andrewrowe you pass them in through the callback using the element parameter you saw there it holds each value in arr per iteration..... PS element can be given any name, i chose that for you to understand
Andrew Rowe
@andrewrowe
Jan 10 2017 04:13
@Lumexralph Okay, I understand that part. But let's say we want elements that are less than a variable, "x", and this variable's value is passed into our main function. How would we return elements < x? Can we pass the variable x into the filter function?
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:14
@andrewrowe sure, so far the scope is global to the filter callback
@andrewrowe
var arr = [1, 3, 4], val = 4;
var newArray = arr.filter(function(element, index) {
    return element < val;
});
newArray[1, 3]// that's
Andrew Rowe
@andrewrowe
Jan 10 2017 04:16
@Lumexralph Okay. I probably just need to check my scope. Thanks for the help
CamperBot
@camperbot
Jan 10 2017 04:16
andrewrowe sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 705 | @lumexralph |http://www.freecodecamp.com/lumexralph
Saurabh Jha
@saurbh0409
Jan 10 2017 04:16
can someone help me with "Midlibs"
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:16
@saurbh0409 we can try
Saurabh Jha
@saurbh0409
Jan 10 2017 04:16

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

You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence.
barry01000010
@barry01000010
Jan 10 2017 04:18
Hey all, Newbie here. Can I have my html file in the folder as my js file or is that not reccommended?
Saurabh Jha
@saurbh0409
Jan 10 2017 04:18
I have to make a sentence using variables and some other strings to make a sentence
Manish Giri
@Manish-Giri
Jan 10 2017 04:19
@barry01000010 if you're just starting out, it's fine
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:21
@saurbh0409 you know how to concatenate strings, right?
barry01000010
@barry01000010
Jan 10 2017 04:26
@Manish-Giri thanks, I am doing it all right from what I can gather but its not working, my js is not linking with my html file. can you guide me through it just basically. (can I pm you?)
CamperBot
@camperbot
Jan 10 2017 04:26
barry01000010 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3679 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jan 10 2017 04:26
@barry01000010 sure
ajp001
@ajp001
Jan 10 2017 04:28
Hi everyone, can someone help me with the "Stand in Line" exercise? I did what I THOUGHT would work, but it keeps returning "TypeError: newArray.shift is not a function"
The exercise: Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
My "solution":
function nextInLine(arr, item) {
var inputArray= arr;
var newArray = inputArray.push(item);
var oddOneOut = newArray.shift();
return oddOneOut;
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:30
@ajp001 var newArray = inputArray.push(item); this line will return a TypeError in your code because #push returns the length of the array and causes a side effect by adding value to the end of the array, so newArray is a number and not the array arr
Joseph
@revisualize
Jan 10 2017 04:33
Hello.
ajp001
@ajp001
Jan 10 2017 04:33
@Lumexralph is there a way for newArray to return as a whole array(with the new number added in)?
Joseph
@revisualize
Jan 10 2017 04:33
@ajp001 I could walk you through that.
LOL!
@ajp001 That's a long process.
Why would you want to do that?
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:34
@revisualize hi, good morning though it's evening there, right?
Joseph
@revisualize
Jan 10 2017 04:34
834pm.
:D
@Lumexralph Good Morning to you
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:34
@revisualize 534am
Chris Wingler
@chriswingler
Jan 10 2017 04:35

stuck on my last basic javascript challenge.. profile lookup.

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

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

ajp001
@ajp001
Jan 10 2017 04:35
@revisualize Can you PM me? I don't know how
Joseph
@revisualize
Jan 10 2017 04:36
@ajp001 Do you know what I dislike more than being told to go f myself?
PMs
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:37
@ajp001 yes, doing arr.push(item) will put item to arr, and your new array arr will contain item, you just have to continue work with arr since it already has the value item you pushed
Joseph
@revisualize
Jan 10 2017 04:37

How do you add a number (item) to the end of an array (arr)? What does this method return?
How do you remove the first element from an array (arr)? What does this method return?

The push() method adds one or more elements to the end of an array and returns the new length of the array.

The pop() method removes the last element from an array and returns that element.

The shift() method removes the first element from an array and returns that element.

The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.

Just because a method returns something. Doesn't mean you have to do anything with it.

@ajp001 Side Question:

function getName() { return "Joseph" }
var name = getName();
console.log(name);

What do you think is output to the console when you log the variable name?
Why do you think that is?

eliza khachatryan
@Elijbet
Jan 10 2017 04:38
Hey guys, I moved away from javascript for a couple of months and completly forgot it. Trying to pick up. Can you help me remembe why this code isn't working? I'll paste it here
var tax_rate = 1.15;
var phone_price = 20;
var accessory_price = 5;
var spend_thresh = 20;
var bank_balance = 100;
var phone_total = 0;
var acc_total = 0;
var grand_total = tax_rate * (phone_total + acc_total);


// keep buying phones while you still have money
while (phone_total < bank_balance) {
        // buy a new phone!
    phone_total += phone_price;
        // can we afford the accessory?
    while (acc_total < spend_thresh) {
        acc_total +=accessory_price;
    }
    console.log("Your total is $" + Math.round(grand_total * 100) / 100);
}
eliza khachatryan
@Elijbet
Jan 10 2017 04:39
remind me how to use this
Joseph
@revisualize
Jan 10 2017 04:40
Step one. Copy and past your code into the editor on that website.
Second.
Click VISUALIZE
eliza khachatryan
@Elijbet
Jan 10 2017 04:40
ah okay
Joseph
@revisualize
Jan 10 2017 04:40
third walk through each iteration of your code step by step.
4th.
Eat cake.
eliza khachatryan
@Elijbet
Jan 10 2017 04:41
all clear, exc what does eat cake mean
Andrew Rowe
@andrewrowe
Jan 10 2017 04:42
@Lumexralph Another question. So let's say I wanted to check the array I'm filtering against another array. How can I do this without looping?
Joseph
@revisualize
Jan 10 2017 04:42
@Elijbet You get a slice of cake.
@Elijbet You get a fork.
@Elijbet And you eat the cake.
@Elijbet Do you know what a cake is?
eliza khachatryan
@Elijbet
Jan 10 2017 04:43
I know what a cake is :) I"m not local, so what do i know what eat a cake in this context means :)
Joseph
@revisualize
Jan 10 2017 04:43
This message was deleted
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:44
@andrewrowe without looping through which of the arrays?
ajp001
@ajp001
Jan 10 2017 04:44
@revisualize It'd return "Joseph", wouldn't it? you're calling on getName, which is told to return "Joseph".
Joseph
@revisualize
Jan 10 2017 04:44
@Elijbet It means. To actually go eat cake. There isn't any side context.
@ajp001 Great.

How do you add a number (item) to the end of an array (arr)? What does this method return?
How do you remove the first element from an array (arr)? What does this method return?

The push() method adds one or more elements to the end of an array and returns the new length of the array.

The pop() method removes the last element from an array and returns that element.

The shift() method removes the first element from an array and returns that element.

The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.

CAKE!
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:45
@revisualize :smile: , not a scene i'll love to see when i'm a bit hungry
Joseph
@revisualize
Jan 10 2017 04:45
I <3 cake.
But, I'm becoming a fatty.
So.
meh.
ajp001
@ajp001
Jan 10 2017 04:47

@revisualize I want to .push(item) into the array, then .shift() the fist element fromt he array and return that element.

I believe (or did believe) that Push would return the new array and shift would return a single element (or a number in this case)

Andrew Rowe
@andrewrowe
Jan 10 2017 04:47
@Lumexralph Going with your last example. Let's say I'm trying to do something more like this...
Snip20170109_3.png
@Lumexralph It seems like that doesn't actually loop through like I want it to
Joseph
@revisualize
Jan 10 2017 04:48
@ajp001 Well, what you did believe wasn't correct.
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:49
@andrewrowe how do you want it to loop?
Andrew Rowe
@andrewrowe
Jan 10 2017 04:50
@lumexralph I just want it to compare every element in the array being filtered against all items in a second array
ajp001
@ajp001
Jan 10 2017 04:51
@revisualize i was told that .push(item) would return a single number, but I don't know why that's the case
Ogundele Olumide
@Lumexralph
Jan 10 2017 04:52
@andrewrowe there's a method called map and forEach, familiar with them?
Andrew Rowe
@andrewrowe
Jan 10 2017 04:53
@Lumexralph I'm familiar with forEach, not so much map
Joseph
@revisualize
Jan 10 2017 04:55
@ajp001 That is how the method is designed.
ajp001
@ajp001
Jan 10 2017 04:57

I passed the exercise! I ended up doing this:
function nextInLine(arr, item) {
var inputArray= arr;
inputArray.push(item);

return inputArray.shift();
}

@revisualize thanks for your help. If there's a more elegant solution, I'd love to hear it.
CamperBot
@camperbot
Jan 10 2017 04:58
ajp001 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2890 | @revisualize |http://www.freecodecamp.com/revisualize
Ogundele Olumide
@Lumexralph
Jan 10 2017 05:01
@andrewrowe you can try out those methods but there's no way you'll compare the filtered value without looping, so you can chain the operation like this
arr1.filter(function).map(function) or
arr1.filter(function).forEach(function(el, index, arr) {
  you can compare each flitered elements in arr1 with arr2 elements
})
Mrdaniels3
@Mrdaniels3
Jan 10 2017 05:04
Can someone help me with Booleans
Claudio Restifo
@Marmiz
Jan 10 2017 05:05
@Mrdaniels3 what's the issue?
Andrew Rowe
@andrewrowe
Jan 10 2017 05:05
@Lumexralph Okay, thanks I'll try that
CamperBot
@camperbot
Jan 10 2017 05:05
andrewrowe sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: andrewrowe already gave lumexralph points
Kuomu Fan
@txbluebee
Jan 10 2017 05:06

Im stuck in the lesson: Selecting from many options with Switch Statements

```

here is my code
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  case val === 1;
  answer = "alpha";
  break;
  case val === 2;
  answer = "beta";
  break;
  case val === 3;
  answer = "gamma";
  break;
  case val === 4;
  answer = "delta";
  break;

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

// Change this value to test
caseInSwitch(1);

i follow the example

switch (num) {
case value1:
statement1;
break;
case value2:
statement2;
break;
...
case valueN:
statementN;
break;
}

Ha Nguyen
@uxsasukexnaruto
Jan 10 2017 05:08
you forgot the switch() {}
gupgdown
@r1nc3w1nd
Jan 10 2017 05:09
function palindrome(str){
 var stringToArray = str.split("").join("");
var squish = stringToArray.replace("[^A-Za-z0-9 _]","").toLowerCase();
var newest = squish.split('').reverse().join('');

if (str == newest){
 return true;
}
return false;
}
Ogundele Olumide
@Lumexralph
Jan 10 2017 05:09
@txbluebee where's switch ?
gupgdown
@r1nc3w1nd
Jan 10 2017 05:09
anyone help?
Chris Wingler
@chriswingler
Jan 10 2017 05:09
not sure why this isn't passing
function lookUpProfile(firstName, prop){
// Only change code below this line

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

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
DavidMinAZ
@DavidMinAZ
Jan 10 2017 05:09
@anyone Know if it's possible to use prop=pageimages while doing an action=opensearch? I can include that in a browser and see the usual data come back from my present query but no matter what it searched there are never thumbnail URLs being returned
(For the Wikipedia API, that is, sorry!)
Ogundele Olumide
@Lumexralph
Jan 10 2017 05:11
@r1nc3w1nd your reExp is not well constructed
Kuomu Fan
@txbluebee
Jan 10 2017 05:11
@Lumexralph
gupgdown
@r1nc3w1nd
Jan 10 2017 05:11
can you help me get it straight? needs to check for non aplhanumeric characters and replace with space
Kuomu Fan
@txbluebee
Jan 10 2017 05:11
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
  case val === 1;
  answer = "alpha";
  break;
  case val === 2;
  answer = "beta";
  break;
  case val === 3;
  answer = "gamma";
  break;
  case val === 4;
  answer = "delta";
  break;
  // Only change code above this line  
  return answer;  
}

// Change this value to test
caseInSwitch(1);
Ogundele Olumide
@Lumexralph
Jan 10 2017 05:12
@r1nc3w1nd here var squish = stringToArray.replace("[^A-Za-z0-9 _]","") regExp should be like this /pattern/g it should not be stringed
Ha Nguyen
@uxsasukexnaruto
Jan 10 2017 05:12
@txbluebee check {}
Kuomu Fan
@txbluebee
Jan 10 2017 05:12
i added switch but i still got error message
Ha Nguyen
@uxsasukexnaruto
Jan 10 2017 05:13
you are missing a }
Ogundele Olumide
@Lumexralph
Jan 10 2017 05:13
@txbluebee because you did this case val === 1 just do case 1 you need to fully understand how switch wrks
<