These are chat archives for FreeCodeCamp/HelpJavaScript

28th
Feb 2017
Thiago Cruz
@thy705
Feb 28 2017 00:00
function findLongestWord(str) {
var spaceTakeOut = str.split(" ");
  var a = spaceTakeOut[0];
  var b = spaceTakeOut[1];
  var c = spaceTakeOut[2];
  var d = spaceTakeOut[3];
  var e = spaceTakeOut[4];
  var f = spaceTakeOut[5];
  var g = spaceTakeOut[6];
  var h = spaceTakeOut[7];
  var i = spaceTakeOut[8];
  var j = spaceTakeOut[9];

  while (spaceTakeOut[a].length>spaceTakeOut[b].length && spaceTakeOut[a].length>spaceTakeOut[c].length && spaceTakeOut[a].length>spaceTakeOut[d].length && spaceTakeOut[a].length>spaceTakeOut[e].length && spaceTakeOut[a].length>spaceTakeOut[f].length && spaceTakeOut[a].length>spaceTakeOut[g].length && spaceTakeOut[a].length>spaceTakeOut[h].length && spaceTakeOut[a].length>spaceTakeOut[i].length && spaceTakeOut[a].length>spaceTakeOut[j].length) {

    a++;
    return spaceTakeOut[a].length;



  } while (spaceTakeOut[b].length>spaceTakeOut[a].length && spaceTakeOut[b].length>spaceTakeOut[c].length && spaceTakeOut[b].length>spaceTakeOut[d].length && spaceTakeOut[b].length>spaceTakeOut[e].length && spaceTakeOut[b].length>spaceTakeOut[f].length && spaceTakeOut[b].length>spaceTakeOut[g].length && spaceTakeOut[b].length>spaceTakeOut[h].length && spaceTakeOut[b].length>spaceTakeOut[i].length && spaceTakeOut[b].length>spaceTakeOut[j].length) {

    b++;

    return spaceTakeOut[b].length;

  } while (spaceTakeOut[c].length>spaceTakeOut[a].length && spaceTakeOut[c].length>spaceTakeOut[b].length && spaceTakeOut[c].length>spaceTakeOut[d].length && spaceTakeOut[c].length>spaceTakeOut[e].length && spaceTakeOut[c].length>spaceTakeOut[f].length && spaceTakeOut[c].length>spaceTakeOut[g].length && spaceTakeOut[c].length>spaceTakeOut[h].length && spaceTakeOut[c].length>spaceTakeOut[i].length && spaceTakeOut[c].length>spaceTakeOut[j].length){

    c++;

    return spaceTakeOut[c].length;

  } while (spaceTakeOut[d].length>spaceTakeOut[a].length && spaceTakeOut[d].length>spaceTakeOut[b].length && spaceTakeOut[d].length>spaceTakeOut[c].length && spaceTakeOut[d].length>spaceTakeOut[e].length && spaceTakeOut[d].length>spaceTakeOut[f].length && spaceTakeOut[d].length>spaceTakeOut[g].length && spaceTakeOut[d].length>spaceTakeOut[h].length && spaceTakeOut[d].length>spaceTakeOut[i].length && spaceTakeOut[d].length>spaceTakeOut[j].length) {

    d++;
    return spaceTakeOut[d].length;

  } while (spaceTakeOut[e].length>spaceTakeOut[a].length && spaceTakeOut[e].length>spaceTakeOut[b].length && spaceTakeOut[e].length>spaceTakeOut[c].length && spaceTakeOut[e].length>spaceTakeOut[d].length && spaceTakeOut[e].length>spaceTakeOut[f].length && spaceTakeOut[e].length>spaceTakeOut[g].length && spaceTakeOut[e].length>spaceTakeOut[h].length && spaceTakeOut[e].length>spaceTakeOut[i].length && spaceTakeOut[e].length>spaceTakeOut[j].length) {

    e++;

    return spaceTakeOut[e].length;

  } while (spaceTakeOut[f].length>spaceTakeOut[a].length && spaceTakeOut[f].length>spaceTakeOut[b].length && spaceTakeOut[f].length>spaceTakeOut[c].length && spaceTakeOut[f].length>spaceTakeOut[d].length && spaceTakeOut[f].length>spaceTakeOut[e].length && spaceTakeOut[f].length>spaceTakeOut[g].length && spaceTakeOut[f].length>spaceTakeOut[h].length && spaceTakeOut[f].length>spaceTakeOut[i].length && spaceTakeOut[f].length>spaceTakeOut[j].length) {

    f++;

    return spaceTakeOut[f].length;

  } while (spaceTakeOut[g].length>spaceTakeOut[a].length && spaceTakeOut[g].length>spaceTakeOut[b].length && spaceTakeOut[g].length>spaceTakeOut[c].length && spaceTakeOut[g].length>spaceTakeOut[d].length && spaceTakeOut[g].length>spaceTakeOut[e].length && spaceTakeOut[g].length>spaceTakeOut[f].length && spaceTakeOut[g].length>spaceTakeOut[h].length && spaceTakeOut[g].length>spaceTakeOut[i].length && spaceTakeOut[g].length>spaceTakeOut[j].length) {

    g++;

    return spaceTakeOut[g].length;
Jinnd319
@Jinnd319
Feb 28 2017 00:00
@mitron6 just learned that none of that stuff was necessary because all of those values already returned false rofl.
@mitron6 It's just one if statement this is amazing
mitron6
@mitron6
Feb 28 2017 00:02
@Jinnd319 But you get the point that code should be easy to understand, right?
Thiago Cruz
@thy705
Feb 28 2017 00:02
Anyone?
Gulsvi
@gulsvi
Feb 28 2017 00:02
@GoingAllTheWayUp I'm just trying to practice with promises, I initially used the template approach like I showed you.
Jinnd319
@Jinnd319
Feb 28 2017 00:03
@milton6 Yeah I have more experience in Python than javascript, I understand readability. Does the switch pattern work for all switches that want to compare cases of !== or just for comparing values against true?
Gulsvi
@gulsvi
Feb 28 2017 00:03
I have it working, almost, but I have to use a, b, c, d, etc...all the way up to the length of the array to get all the user data:
  let streamerRequests = [];

  users.forEach(user => {
    const channelsUrl = 'https://wind-bow.gomix.me/twitch-api/channels/' + user,
          streamsUrl = 'https://wind-bow.gomix.me/twitch-api/streams/' + user;

    streamerRequests.push(
      $.getJSON(channelsUrl, channelData => {
        $.getJSON(streamsUrl, streamData => {})
      })
    );
  });

  $.when.apply($, streamerRequests).done(function(a, b, c) {
    console.log(a, b, c)
  });
Need to find a way to just capture it in one variable
Adam
@GoingAllTheWayUp
Feb 28 2017 00:04
@SkyCoder01 I feel like promises are the solution for me
Gulsvi
@gulsvi
Feb 28 2017 00:05
I think this is how you do it with getJSON
$.when and an array of getJSON requests
Thiago Cruz
@thy705
Feb 28 2017 00:05
@GoingAllTheWayUp Thanks Adam, but that only shows my own code.
CamperBot
@camperbot
Feb 28 2017 00:05
:cookie: 268 | @goingallthewayup |http://www.freecodecamp.com/goingallthewayup
thy705 sends brownie points to @goingallthewayup :sparkles: :thumbsup: :sparkles:
Adam
@GoingAllTheWayUp
Feb 28 2017 00:06
@thy705 ok thats the one your working on? then you must use .map() method to pass it
It will only be a few line of code in the end not this loop hell
Thiago Cruz
@thy705
Feb 28 2017 00:06
@GoingAllTheWayUp Yep, that's the one. I'll try that then.
Adam
@GoingAllTheWayUp
Feb 28 2017 00:07
.map() itterrates, kind of like a loop but without all the mess
@SkyCoder01 can I see your codepen
Gulsvi
@gulsvi
Feb 28 2017 00:09
@GoingAllTheWayUp This is the template one: http://codepen.io/skycoder/pen/XpyrYN
Jason Luboff
@JLuboff
Feb 28 2017 00:09
@GoingAllTheWayUp @thy705 You don't have to use map. You could use two loops (one nested in the other) and an if statement. Map would be the cleaner, more advanced solution though
Adam
@GoingAllTheWayUp
Feb 28 2017 00:11
@SkyCoder01 Oh man thats nice!
Gulsvi
@gulsvi
Feb 28 2017 00:11
Thanks, it's turned into a huge project
Adam
@GoingAllTheWayUp
Feb 28 2017 00:11
@JLuboff I think it is a method he should use becuase he just learned it a few lessons before. thats the only reason i stress it
@SkyCoder01 no i really like it. you went nutz on it. love it...
Jason Luboff
@JLuboff
Feb 28 2017 00:13
@GoingAllTheWayUp Fair enough. I just know that my understanding of map at that time was minimal and even now, I haven't really used it lol But, it is something that I'm looking to improve on
Gulsvi
@gulsvi
Feb 28 2017 00:17
:) Thanks @GoingAllTheWayUp Going to be a perfectionist though and get these promises going
CamperBot
@camperbot
Feb 28 2017 00:17
skycoder01 sends brownie points to @goingallthewayup :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @goingallthewayup |http://www.freecodecamp.com/goingallthewayup
Joe Narvaez
@wordyallen
Feb 28 2017 00:18
@sjames1958gm currying solved it
Adam
@GoingAllTheWayUp
Feb 28 2017 00:18
@SkyCoder01 I still am not understaning how you did it, make all that data show up on time in the right place with just Json, becuase i can't with promises lol. Ill be stalking you code tonight
Jason Luboff
@JLuboff
Feb 28 2017 00:19
@SkyCoder01 The design looks really sharp :+1:
Frederick Williams
@ftwilliams89
Feb 28 2017 00:19
excuse me @JLuboff how would I go about multiplying the product variable
Joe Narvaez
@wordyallen
Feb 28 2017 00:19

I need to merge two object returned from seperate promises

.then( obj1 =>  promise)
.then(obj2 => merge(obj1, obj2)

any ideas?

spencerjstewart
@spencerjstewart
Feb 28 2017 00:19
I'm very frustrated trying to understand reduce. Can someone take a look at this and tell me why I'm returning undefined? I'm trying to sum the first number in each array. I put the console.log to check what each array is doing.
Gulsvi
@gulsvi
Feb 28 2017 00:19
@GoingAllTheWayUp It's all in that generateUserCardTemplate() function. If you can comment out the getJSON calls, and then do a right-click, inspect on the HTML, it will make more sense I think.
spencerjstewart
@spencerjstewart
Feb 28 2017 00:19
Adam
@GoingAllTheWayUp
Feb 28 2017 00:19
@SkyCoder01 I see that now
Gulsvi
@gulsvi
Feb 28 2017 00:19
Thanks @JLuboff :)
CamperBot
@camperbot
Feb 28 2017 00:19
skycoder01 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 980 | @jluboff |http://www.freecodecamp.com/jluboff
Jason Luboff
@JLuboff
Feb 28 2017 00:20
@ftwilliams89 myVar *= number Thats an example, don't want to give the full answer ;)
Frederick Williams
@ftwilliams89
Feb 28 2017 00:21
oooooh :smile:
Adam
@GoingAllTheWayUp
Feb 28 2017 00:22
@SkyCoder01 are you calling on the API for each user indivdualy one at a time?
Gulsvi
@gulsvi
Feb 28 2017 00:23
@GoingAllTheWayUp Yeah, every loop of the .forEach calls the /channels/ and /streams/ urls
one for every user
Adam
@GoingAllTheWayUp
Feb 28 2017 00:25
@SkyCoder01 thanks again
CamperBot
@camperbot
Feb 28 2017 00:25
goingallthewayup sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:warning: goingallthewayup already gave skycoder01 points
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 00:25

``` function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
arr = Object.keys(source);
console.log(arr);
// Only change code above this line
return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
```

why this ticks is not working
Adam
@GoingAllTheWayUp
Feb 28 2017 00:26
shift enter
tick tick tick shift enter code tick tick tick
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 00:27

```function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
arr = Object.keys(source);
console.log(arr);
// Only change code above this line
return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
```

Jason Luboff
@JLuboff
Feb 28 2017 00:32
Sweet. My TicTacToe game is almost done!
Aaron Bell
@awb715
Feb 28 2017 00:34
@JLuboff didyou do the lowest common multiple challenge?
Jason Luboff
@JLuboff
Feb 28 2017 00:34
@awb715 Ya I did...a long time ago :(
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 00:35
hi @JLuboff can you please suggest me how to solve Wherefore art thou
Jason Luboff
@JLuboff
Feb 28 2017 00:35
@awb715 I didn't get far on my own, needed a lot of help...so I probably wouldn't be great at helping
Dan Couper
@DanCouper
Feb 28 2017 00:37
@spencerjstewart you aren't returning anything: the reduce bit is working perfectly fine, you just arent actually returning it so it runs then that's it, and the number function returns undefined cos it cant do anything else
Jason Luboff
@JLuboff
Feb 28 2017 00:38
@pshiwakoti1 You cna use filter to filter out the values that don't work
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 00:38
ok
Aaron Bell
@awb715
Feb 28 2017 00:38
@JLuboff i remember we spoke a while ago, where are you in your coding endeavors
Jason Luboff
@JLuboff
Feb 28 2017 00:39
@awb715 Working on finishing my TicTacToe game. I think I have my logic all working how I want. (If the computer can win, it will or will try and block)
Aaron Bell
@awb715
Feb 28 2017 00:43
ive been stuck on this lcm for a 2 months
Seth
@sethdcd
Feb 28 2017 00:43
should i use .ajax over .getJSON ?
Aaron Bell
@awb715
Feb 28 2017 00:43
and have almost quit
Jason Luboff
@JLuboff
Feb 28 2017 00:44
@awb715 Don't quit. You can also skip it and go back to it
Dan Couper
@DanCouper
Feb 28 2017 00:45
@sethdcd if you are just making a GET request that gets JSON, use getJSON, it's exactly the same thing as .ajax, just simplified for the most common procedure so you don't have to type the options out. Anything else, no
Aaron Bell
@awb715
Feb 28 2017 00:46
im doing some stuff on udemy @JLuboff
can you send me yourcode for lcm?
Jason Luboff
@JLuboff
Feb 28 2017 00:47
@awb715 I'll be honest, I think I ended up looking that one up :(
Simeon
@SimeonCodes
Feb 28 2017 00:47

@SimeonCodes
how do i insert something into a stylesheet that im adding to the page after its loaded?

jQuery('._div').css({"left": jQuery('#page_container').offset().left, "top": "124px"})

however im more after wanting to use this method

    var myDiv = '<style type="text/css">'+
    '    ._div {'+
    '        left:'+jQuery('#page_container').offset().left+';'+ 
    '        top: 124px;'+ 
    '    }'+
    '</style>'+
    '<div class="_div">'+
    '</div>';                    

    jQuery('body').prepend(myDiv);
im after making the second method work
Dan Couper
@DanCouper
Feb 28 2017 00:48
@awb715 if you're learning, and you get stuck for more than a few days on a small thing, look up the answer (tbh, if you're stuck for more than a few hours Google it); really, it's not worth the hassle, you don't gain anything. 2 months is silly; I've done it before (a few times), and it's never useful
/* jshint esversion: 6*/
function* range(max, min = 0, step = 1) {
  while (max >= min) {
    yield min
    min+= step
  }
}

function isCommonMultiple(v, numRange) {
  return numRange.every(num => v % num == 0)
}

function lowestCommonMultiple(x, y, counter = y) {
  const mulRange = [...range(y,x)]
  while (true) {
    if(isCommonMultiple(counter, mulRange)) return counter
    counter += y
  }
}
function smallestCommons(arr) {
  const [x, y] = arr.sort((a,b) => a - b)
  return lowestCommonMultiple(x, y)
}


smallestCommons([1,5]);
that may/may not be useful
Aaron Bell
@awb715
Feb 28 2017 00:51
yeah looks a little complex
Dan Couper
@DanCouper
Feb 28 2017 00:51
it's not, I was playing around with other things & made it more complex than it should be:
  1. Range function: a function that takes a min and and a max and makes an array of numbers from min to max
gitstuffedm8
@gitstuffedm8
Feb 28 2017 00:53
wth is am i in the right chatroom? i was expecting Using Objects for Lookups help chat. you guys are way ahead in this room haha
Dan Couper
@DanCouper
Feb 28 2017 00:53
No, false impression
Seth
@sethdcd
Feb 28 2017 00:53
@DanCouper thanks dan!
CamperBot
@camperbot
Feb 28 2017 00:53
sethdcd sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 516 | @dancouper |http://www.freecodecamp.com/dancouper
Seth
@sethdcd
Feb 28 2017 00:54
im struggling hard on this first intermediate challenge
Jason Luboff
@JLuboff
Feb 28 2017 00:58
@gitstuffedm8 This is the help javascript room, so any and all javascript questions come here
Dan Couper
@DanCouper
Feb 28 2017 00:58
@awb715
  1. Function to check if it's a common multiple - given a range of numbers (created using the previous function), and a value, check every number divides evenly (using the array method every)
  2. the actual function. x is the low number, y is the high one. Make a range using them. Set a counter to y. Start a [potentially] infinite loop (while (true)). Check if the counter is a common multiple. If it is, return the counter, that's it found. Otherwise every time it loops, increase the counter by the value of y (it cannot increase by anything else), just keep going forever.
Aaron Bell
@awb715
Feb 28 2017 01:01
mine does that
it works for [1,5]
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 01:01
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  arr = Object.keys(source);
  collection = collection.filter(function( obj ) {
    return obj.first !== source.first;
    });



  console.log(arr);
  // Only change code above this line
  return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Aaron Bell
@awb715
Feb 28 2017 01:01
but doesnt work for theothers cus of a potential infinite loop
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 01:01
can someone tell me whats wrong with my code
Aaron Bell
@awb715
Feb 28 2017 01:03
@DanCouper
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 01:04
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  arr = Object.keys(source);
  collection = collection.filter(function( obj ) {
    return obj.last !== arr;
    });



  //console.log(arr);
  // Only change code above this line
  return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Mike Woodall
@usnwoody
Feb 28 2017 01:07
Need help getting a start on the "Counting Cards" problem please
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 01:07
when I return collection I get 1 test case passed
Martin Lee
@martyk311
Feb 28 2017 01:07
function rot13(str) { // LBH QVQ VG!

  str.split(" ");

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

    str.charCodeAt(i);

  }
  return str; 

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Trying to turn the string into an array that separates the words by letter and make a loop that takes each letter and changes it into its unicode value. Am I on the right track?
quick2delete
@quick2delete
Feb 28 2017 01:09

Can I get some help? It's about 'Truncate a string'. Can anyone let me know what is wrong with my codes? function truncateString(str, num) {
// Clear out that junk in your trunk
if (num <= 3){
var shortLength = str.slice(0, num);
str = shortLength;
return str + "...";
} else if (str.length == num){
return str;
} else if (str.length > num){
var longLength = str.slice(0, num-3);
str = longLength;
return str + "...";
}
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);

Dan Couper
@DanCouper
Feb 28 2017 01:12
@awb715 Shouldn't make any difference; at larger numbers JS will run out of numbers pretty fast, so it'll just fail. There are other ways to do this, this is very naive, but just happens to be the simplest: the potentially infinite loop should not be an issue unless you're trying to input huge numbers, which will fail anyway. You cannot tell if a range has no common divisors unless there's a prime there that the others cannot divide into: so you can check for primality as well, but then that's another huge chunk of CPU power needed
/**
 * Given a min integer and max integer, returns an
 * array of values from min to max.
 */
function range(min, max) {
  // NOTE I'm not doing any kind of sanity check here,
  // just expecting the input to be fine.
  rangeArr = [];
  for (var i = min; i <= max; i++) {
    rangeArr.push(i);
  }
  return rangeArr;
}

/**
 * Given a `value` and a `range`, check if *every* number in
 * the `range` divides evenly be `value`. 
 */
function isCommonMultiple(value, range) {
  return range.every(function(numInRange) {
    return value % numInRange == 0;
  });
}

/**
 * Given a low value `x` and a high value `y`, find the lowest commmon
 * multiple of all numbers from x to y.
 */
function lowestCommonMultiple(x, y) {
  // Range of numbers to check:
  var multipleRange = range(x, y);
  // The value we will use to check *has* to either be the
  // highest number (y) or a multiple of it
  var counter = y;

  while (true) {
    if(isCommonMultiple(counter, multipleRange)) return counter;
    counter += y;
  }
}

// ----------------------------------------------------------------------

/**
 * Actual implementation interface, just puts the arguments
 * in the right order and uses them to call the helper function.
 */
function smallestCommons(arr) {
  // Make sure the two values are lowest then highest:
  var rangeValues = arr.sort(function(a,b) { return a - b; });
  return lowestCommonMultiple(rangeValues[0], rangeValues[1]);
}
gitstuffedm8
@gitstuffedm8
Feb 28 2017 01:14
'test'
test

great here is my question pls:

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

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)) {
return myObj[checkProp];
}
else {
return "Not Found";
}
}

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

why won't it work if i used return myObj.checkProp; why do i have to use the sq bracket?

ah crap the code didn't work
IbnuAzzam
@ibnuazzam
Feb 28 2017 01:16

for(var i = 0; i < 5; i++) {

ourArray.push(i);

}

var myArray = [];

// Only change code below this line.
for (var i = 0; i < 5; i++) {
ourArray.push(i);
}

what's wrong with my code?
Iterate with JavaScript For Loops
David Morales
@davmor94
Feb 28 2017 01:17
Help me! I cant seem to figure out why the last test for the smallestCommons challenge is not working:

function smallestCommons(arr) {
var min= Math.min(arr[0], arr[1]);
var max= Math.max(arr[0], arr[1]);

//get an array of all the values that need to be tested

var fullArr=[];
for(i=1; i<=max; i++){
fullArr.push(i);
}

//Euclidean algorithm
function gcd(x, y){
if (y===0){
return x;
}
else if(x>=y && y>0){
return gcd(y, x%y);
}
else{
return gcd(y,x);
}
}

function lcm(a, b) {
return (a * b) / gcd(a, b);
}

//recursive iteration to get answer
var answer=1;
for(i=0; i<fullArr.length; i++){
answer=lcm(answer, fullArr[i]);
}
return answer;
}

smallestCommons([23,18]);

Dan Couper
@DanCouper
Feb 28 2017 01:18
@gitstuffedm8 return myObj.checkProp: you're looking for a property called checkProp on myObj. Literally called "checkProp"
Joe Narvaez
@wordyallen
Feb 28 2017 01:18
/collapse-all
gitstuffedm8
@gitstuffedm8
Feb 28 2017 01:18
ahh right yes i see, remember now from that earlier lesson. thanks Dan!
Dan Couper
@DanCouper
Feb 28 2017 01:19
:thumbsup: is confusing at first, but it's generally the same or similar in most programming languages: one way is easier to read and write, but you need to know what you're looking for in advance, and another way that is a bit more cryptic but lets you be a bit more general
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 01:20
is anyone helping me
Dan Couper
@DanCouper
Feb 28 2017 01:22
@wordyallen hah, that's pretty neat
ESLMiguel
@ESLMiguel
Feb 28 2017 01:25
Good morning all :sunrise:
Arash D
@ArashDai
Feb 28 2017 01:26
hey for the pig latin challenge am i supposed to move all consonants before the first vowel to the back fo the string?
ESLMiguel
@ESLMiguel
Feb 28 2017 01:26
@ArashDai yes
Arash D
@ArashDai
Feb 28 2017 01:26
ugh
lol
ESLMiguel
@ESLMiguel
Feb 28 2017 01:26
then add 'ay'
Arash D
@ArashDai
Feb 28 2017 01:27
passing all put one test
but*
ESLMiguel
@ESLMiguel
Feb 28 2017 01:27
@ArashDai thats normal, same thing happened for me
you can do it :thumbsup:
Arash D
@ArashDai
Feb 28 2017 01:27
I know i can do it, this challenge just bores me
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 01:29
@ESLMiguel can u please suggest me what to do
ESLMiguel
@ESLMiguel
Feb 28 2017 01:29
@ArashDai if i hit a boring challenge, i put on good music lol
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 01:30
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  arr = Object.keys(source);
  collection = collection.filter(function( obj ) {
    return obj.last !== arr;
    });



  //console.log(arr);
  // Only change code above this line
  return collection;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Jacob Leatherwood
@dadleatherwood
Feb 28 2017 01:30
Can this be done better?
function factorialize(num) {
  var myArray = [];
  for (var i = 1; i < num + 1 ; i++) {
    myArray.push(i);
  }
  if (num > 0) {
    return myArray.reduce(function(previousVal,currentVal) { 
    return previousVal * currentVal;
  });
  } else {
    return 1;
  }
}
factorialize(5);
ESLMiguel
@ESLMiguel
Feb 28 2017 01:30
@pshiwakoti1 oh that one was hard...
Amit Patel
@AmitP88
Feb 28 2017 01:30
Hey guys, I'm planning on creating my own mobile game app similar to candy crush, but with more of an rpg adventure game element to it. Since i'm primarily trained in front end dev, should I try to create my own game graphics or should I use free stock graphics found online for my game?
ESLMiguel
@ESLMiguel
Feb 28 2017 01:30
@ESLMiguel i have to go back and review it one sec
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 01:30
ok
@dadleatherwood I used recursive function for factorial
Jacob Leatherwood
@dadleatherwood
Feb 28 2017 01:32
@pshiwakoti1 Now I just need to review what that is. :)
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 01:32
ok
Dan Couper
@DanCouper
Feb 28 2017 01:33

@pshiwakoti1 Object.keys gives you an array of keys - this is fine, it's useful for the challenge. So for the example, you get ['last']. You are then filtering the array of objects - again, this is fine

But in your comparison, you are asking if the value of the key 'last' in the current object you're filtering on is equal to an array.

Firstly, it will never be equal to an array: you're comparing a string and an array, there not comparable things.
Secondly, you're hardcoding the key 'last'. What if the testcase does not have objects that contain 'last'? Or if there are multiple things you need to check?

The logic in the comparison is the wrong way round. What you need to check is if every key that you get with Object.keys has a matching key in the current object you're looking at, and that the values match as well. Effectively, if you want to keep your logic similar to what you have, you want to iterate through your source object keys, and use that to check against the current one you're filtering on.

ESLMiguel
@ESLMiguel
Feb 28 2017 01:33
@pshiwakoti1 not sure how to give a hint without a spoiler
Gulsvi
@gulsvi
Feb 28 2017 01:33
@dadleatherwood You could do it all in a single for() loop - skip creating the array and multiply inside the loop instead.
ESLMiguel
@ESLMiguel
Feb 28 2017 01:33
but i used a for loop as well...
that was the hardest one in the whole intermediate set for me. (on the prime numbers one now)
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 01:34
@DanCouper thanks Dan
CamperBot
@camperbot
Feb 28 2017 01:34
pshiwakoti1 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 517 | @dancouper |http://www.freecodecamp.com/dancouper
ESLMiguel
@ESLMiguel
Feb 28 2017 01:34
@DanCouper thank you for helping
CamperBot
@camperbot
Feb 28 2017 01:34
eslmiguel sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 518 | @dancouper |http://www.freecodecamp.com/dancouper
ESLMiguel
@ESLMiguel
Feb 28 2017 01:35
@DanCouper i actually solved it without Object.keys lol
Thomson
@taolucks
Feb 28 2017 01:35
need help!
function titleCase(str) {
  str = str.toLowerCase().split(' ');

  for (var i = 0 ; i < str.length; i++) {
    str[i] = str[i].split('');
    str[i][0] = str[i][0].toUpperCase(); 
    str[i] = str.join('');
}
  return str.join(' ');
}  
titleCase("I'm a little tea pot");
i am doing Title Case a Sentence
Riste M.
@djokeriki
Feb 28 2017 01:36

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

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

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

Need help also here
Dan Couper
@DanCouper
Feb 28 2017 01:37
@ESLMiguel to be honest, I think it's probably easier without - the filter is fine, but can just use a function that takes an object and returns true/false if it matches the necessaries in the source object, then dump that in the filter. Object.keys is good because arrays are easier to work with though
Thomson
@taolucks
Feb 28 2017 01:37
@DanCouper can you help me, pls :)
Gulsvi
@gulsvi
Feb 28 2017 01:39
@taolucks In your for() loop, you are modifying str[i] on every loop, it gives you something like:
I,',malittleteapotI,',malittleteapotAlittleteapotI,',malittleteapotI,',malittleteapotAlittleteapotL,i,t,t,l,eteapotI,',malittleteapotI,',malittleteapotAlittleteapotI,',malittleteapotI,',malittleteapotAlittleteapotL,i,t,t,l,eteapotT,e,apotP,o,t"
Thomson
@taolucks
Feb 28 2017 01:40
yes. it did
Gulsvi
@gulsvi
Feb 28 2017 01:40
Hmm, maybe try for a solution with .substr()
Thomson
@taolucks
Feb 28 2017 01:41
    str[i] = str.join('');
i forgot to try to
 str[i] = str[i].join('');
i am not sure how to use substr method
Carey Van
@thisiscarey
Feb 28 2017 01:41
Can I get help on the Longest Word bonfire? I feel like it must be a syntax error or something easy. My code looks like it should work.
CamperBot
@camperbot
Feb 28 2017 01:41
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Carey Van
@thisiscarey
Feb 28 2017 01:41
function findLongestWord(str) {
  var arrayOfWords = str.split(' ');
  var longestWord = 0;
  for (var i = 0; i < arrayOfWords.length; i++) {
    if (arrayOfWords[i] > longestWord) {
      longestWord = arrayOfWords[i].length;
    }
  }

  return longestWord;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Thomson
@taolucks
Feb 28 2017 01:42
thank you @SkyCoder01
CamperBot
@camperbot
Feb 28 2017 01:42
taolucks sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 369 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Gulsvi
@gulsvi
Feb 28 2017 01:42
@taolucks with substr, you can do something like:
var str = 'hello';
str = str[0].toUpperCase() + str.substr(1);
console.log(str); // Hello
Nightsquid7
@Nightsquid7
Feb 28 2017 01:43

So I'm also doing the title case algorithm challenge.

function titleCase(str) {
var newStr = str.toLowerCase().replace(/\b\w/g, function(s) {
return s.toUpperCase();
});
return newStr;
}

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

It works except on "I'M A Little Tea Pot"

Can't figure out what to so about that M, can someone help please?

Alexander Køpke
@alexanderkopke
Feb 28 2017 01:43
@thisiscarey your if condition basically says if(word > number)
Gulsvi
@gulsvi
Feb 28 2017 01:43
The number you pass to .substr() is the position where you want the rest of your string
Thomson
@taolucks
Feb 28 2017 01:44
@SkyCoder01 wow, that looks much easier , thank you
CamperBot
@camperbot
Feb 28 2017 01:44
taolucks sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:warning: taolucks already gave skycoder01 points
Carey Van
@thisiscarey
Feb 28 2017 01:44
thanks @alexanderkopke. missed the .length
CamperBot
@camperbot
Feb 28 2017 01:44
thisiscarey sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1136 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Gulsvi
@gulsvi
Feb 28 2017 01:44
@taolucks You might also try .slice() I think they do similar things
John Nunns
@johnnunns
Feb 28 2017 01:44
if I wanted to separate a string such as "an example" into an array that returned each characters and spaces in 3s. like - ['an ' ,'exa', etc], how would you guys go about doing that
Thomson
@taolucks
Feb 28 2017 01:45
what is that.. lol @SkyCoder01
Gulsvi
@gulsvi
Feb 28 2017 01:45

@taolucks Practically the same thing lol :)

var str = 'hello';
str = str[0].toUpperCase() + str.slice(1);
console.log(str); // hello

I don't know the difference off hand between .slice() and .substr()

Thomson
@taolucks
Feb 28 2017 01:46
oh, ok..! thanks, !!! @SkyCoder01
CamperBot
@camperbot
Feb 28 2017 01:46
taolucks sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:warning: taolucks already gave skycoder01 points
Thomson
@taolucks
Feb 28 2017 01:48
@SkyCoder01
is there a code that i can find the bigger number in a array?
Stephen James
@sjames1958gm
Feb 28 2017 01:48
@johnnunns just like the chunky monkey challenge just strings not arrays as input
Thomson
@taolucks
Feb 28 2017 01:49
oh, great. thanks @SkyCoder01
CamperBot
@camperbot
Feb 28 2017 01:49
taolucks sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:warning: taolucks already gave skycoder01 points
John Nunns
@johnnunns
Feb 28 2017 01:49
chunky monkey is on fcc? @sjames1958gm
Stephen James
@sjames1958gm
Feb 28 2017 01:49
@johnnunns yes.
@awb715 Did you figure it out - looks like jsbin was stopping the code
Dan Couper
@DanCouper
Feb 28 2017 01:50

@taolucks too many strs. Try to avoid changing the thing you're looping over while you're looping over it if you can possibly avoid it. It's impossible to keep in your head what is happening at any one time, and it will break in various fun ways that will make your head hurt. Also, don't use generic names, name things as they are (str was, at various points, a string, and array of strings, an array of smaller strings inside an array also called str, etc)

eg - this doesn't change your logic except to make it work, I just renamed stuff and stopped overwriting things - the stuff gets pushed into a new array which gets joined and returned at the end.

function titleCase(str) {
  var words = str.toLowerCase().split(' ');
  var titlecasedWords = [];

  for (var i = 0 ; i < words.length; i++) {
    var wordArr = words[i].split('');
    wordArr[0]  =  wordArr[0].toUpperCase();
    titlecasedWords.push(wordArr.join(''));
  }
  return titlecasedWords.join(' ');
} 

titleCase("I'm a little tea pot");
Gulsvi
@gulsvi
Feb 28 2017 01:50
@johnnunns Like this:
function ChunkStringInGroups(string, size) {
  var start = 0,
      chunked = [];

  while(start < string.length) {
    chunked.push(string.slice(start, start + size));
    start += size;
  }

  return chunked; // ["an ", "exa", "mpl", "e"]
}

ChunkStringInGroups('an example', 3);
Probably better ways to do it though
Edited variable names :)
Thomson
@taolucks
Feb 28 2017 01:52
@DanCouper wow, big thanks for your help and effort
CamperBot
@camperbot
Feb 28 2017 01:52
taolucks sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 519 | @dancouper |http://www.freecodecamp.com/dancouper
John Nunns
@johnnunns
Feb 28 2017 01:52
where's the chunky monkey challenge?
John Nunns
@johnnunns
Feb 28 2017 01:52
got it, thanks. let me see if I can figure it out first myself
thanks @SkyCoder01 and @sjames1958gm
CamperBot
@camperbot
Feb 28 2017 01:53
johnnunns sends brownie points to @skycoder01 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 370 | @skycoder01 |http://www.freecodecamp.com/skycoder01
:star2: 6072 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm

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

function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty("checkProp")) {
return myObj.checkProp;
}
return "Not Found";
}

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

Seth
@sethdcd
Feb 28 2017 01:55
omgoodness can someone please please just point me in the right direction as to why this getJSON will not work
https://codepen.io/sethdcd/pen/aJOZWW
ive tried to dumb it down so much, i just wonder if where i have the url is correct :(
Gulsvi
@gulsvi
Feb 28 2017 01:57
@sethdcd They give you the code to use here: https://quotesondesign.com/api-v4-0/
John P Penaloza
@johnpyp
Feb 28 2017 01:58

Hey guys, I'm trying the "Validate Phone numbers" challenge. I have two problems with my regex (I'm not super good at it). Here it is so far

[1]*[)(]*\d{3}[-)(]*\d{3}[-]*\d{4}\s*

My problems are the one at the beginng not sure how to verify and if there are multiple numbers at the end this still counts it as a match. I would prefer to only use one line of regex for the challenge

Jacob Leatherwood
@dadleatherwood
Feb 28 2017 01:58
How about this one?
function palindrome(str) {
  if (str.toLowerCase().replace(/[^0-9a-z]/gi,'') ==      str.toLowerCase().split('').reverse().join('').replace(/[^0-9a-z]/gi, '')) { 
    return true;
  } else {
    return false;
  }
}



palindrome("A man, a plan, a canal. Panama");
Stephen James
@sjames1958gm
Feb 28 2017 01:59
@alexvonkaenel "checkProp" is wrong use checkProp - also .checkProp is wrong use brackets
alexvonkaenel
@alexvonkaenel
Feb 28 2017 02:00
@sjames1958gm why did i not realize that!! Thanks!!!
CamperBot
@camperbot
Feb 28 2017 02:00
alexvonkaenel sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6073 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
ESLMiguel
@ESLMiguel
Feb 28 2017 02:00
ugh...keep getting infinite loops and crashing my browser on the sum all prime numbers challenge
Mike Woodall
@usnwoody
Feb 28 2017 02:04
how do you post code again?
ESLMiguel
@ESLMiguel
Feb 28 2017 02:04
'''
CamperBot
@camperbot
Feb 28 2017 02:04
:bulb: to format code use backticks! ``` more info
ESLMiguel
@ESLMiguel
Feb 28 2017 02:05
read this link :arrow_up:
Mike Woodall
@usnwoody
Feb 28 2017 02:05

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

// Only change code below this line

var hatValue = testObj.hat; // Change this line
var shirtValue = testObj.shirt; // Change this line
`

ESLMiguel
@ESLMiguel
Feb 28 2017 02:05
three backticks
Mike Woodall
@usnwoody
Feb 28 2017 02:05

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

// Only change code below this line

var hatValue = testObj.hat; // Change this line
var shirtValue = testObj.shirt; // Change this line
```

ESLMiguel
@ESLMiguel
Feb 28 2017 02:05
at top and bottom
need to press shift+enter after set of backticks at top\
Mike Woodall
@usnwoody
Feb 28 2017 02:06

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

// Only change code below this line

var hatValue = testObj.hat;      // Change this line
var shirtValue = testObj.shirt;    // Change this line
hah!!! Thanks @ESLMiguel
CamperBot
@camperbot
Feb 28 2017 02:07
usnwoody sends brownie points to @eslmiguel :sparkles: :thumbsup: :sparkles:
:cookie: 337 | @eslmiguel |http://www.freecodecamp.com/eslmiguel
ESLMiguel
@ESLMiguel
Feb 28 2017 02:07
Do not post this code as is, will crash your browser
can someone identify what part is causing the infinite loop?
function sumPrimes(num) {

  var arr = [];
  var newArr = []; 
  for (var i=num; i>1; i--) {     //step 1 make array
    arr.push(i);
  }

  for (var y=0; y<arr.length; y++) {   //step 2 for loop to test if remainder is 0 for all numbers
    for (var z=y+1; z<arr.length-y; z++) {
      if (arr[y] % arr[z] !== 0) {
        newArr.push(arr[y]);
      }
    }
  }

  return arr;
}

sumPrimes(10);
Mike Woodall
@usnwoody
Feb 28 2017 02:07
I got this expression to work, but why no "" around objects like hat and shirt
I mean why do you not put them? does the dot (aka period) make it unneeded?
ESLMiguel
@ESLMiguel
Feb 28 2017 02:09
@usnwoody hat and shirt are "keys"
while ballcap and jersey are "values"
Mike Woodall
@usnwoody
Feb 28 2017 02:09
ah ok, so not like normal variables?
ESLMiguel
@ESLMiguel
Feb 28 2017 02:10
keys don't require quotation marks
Mike Woodall
@usnwoody
Feb 28 2017 02:10
so could I have not put them if I had been the one to write the starter coding?
ESLMiguel
@ESLMiguel
Feb 28 2017 02:11
@usnwoody I believe so
Mike Woodall
@usnwoody
Feb 28 2017 02:12
THAT makes sense then... Thanks again @ESLMiguel
CamperBot
@camperbot
Feb 28 2017 02:12
usnwoody sends brownie points to @eslmiguel :sparkles: :thumbsup: :sparkles:
:warning: usnwoody already gave eslmiguel points
the doc above might have a better explanation
Seth
@sethdcd
Feb 28 2017 02:13
@SkyCoder01 which i used?
Unitato5299
@Unitato5299
Feb 28 2017 02:14
function dropElements(arr, func) {
  var array = arr;
  for(var i = 0; i < arr.length; i++){
    if(func(arr[0]) === false){
      array.shift();
    }
    else {
      break;
    }
  }
  return array;
}

dropElements([1, 2, 3, 4], function(n) {return n > 5;});
can anyone explain why this returns [3,4]?
Kate
@katemcint96
Feb 28 2017 02:14
hello, im trying to make a reqeust to search results from wikipeda, but i'm not sure what i am doing wrong. the function isnt executing from what i can tell, any help?
'''
CamperBot
@camperbot
Feb 28 2017 02:14
:bulb: to format code use backticks! ``` more info
Kate
@katemcint96
Feb 28 2017 02:15

'''
//define dummy variable for sake of testing JSON call
var searchTerm = 'socks';

//request json from wikipedia
$.getJSON("https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=" + searchTerm, function(json) {
//print json to check request
console.log(json);
});
'''

CamperBot
@camperbot
Feb 28 2017 02:15
:bulb: to format code use backticks! ``` more info
Gulsvi
@gulsvi
Feb 28 2017 02:15

@sethdcd Here's their getJSON:

$.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(a) {
  $("body").append(a[0].content + "<p>— " + a[0].title + "</p>")
});

Here's yours:

$.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&_jsonp=mycallback", function(val) {            
    var html = '<h1>' + val.content + '</h1>';
  $(".message").html(html);
}); // end get JSON

There are some important differences if you compare the use of a[0] for example and the jsonp argument you have in your url

Mike Woodall
@usnwoody
Feb 28 2017 02:16
@ESLMiguel the next lesson showed how to deal with an object name that needed quotes like "my drink" using brackets
Seth
@sethdcd
Feb 28 2017 02:16
@SkyCoder01 ok well i copy pasted that in place of my code and it still doesn't work :/
Mike Woodall
@usnwoody
Feb 28 2017 02:16
or keys rather
Gulsvi
@gulsvi
Feb 28 2017 02:17
@sethdcd Do you know how to view your browser's developer console?
Seth
@sethdcd
Feb 28 2017 02:17
ctrl + shift + i?
doesn't seem to show anything in codepen though
Gulsvi
@gulsvi
Feb 28 2017 02:18
Yes - check that for errors after clicking the "New Quote!" button
ESLMiguel
@ESLMiguel
Feb 28 2017 02:18
@usnwoody that series of lessons was really confusing for me tbh so dont feel bad if its not clear yet
Gulsvi
@gulsvi
Feb 28 2017 02:18
Ctrl+Shift+J for me to see the console
Bozhidar Dimitrov
@phiratio
Feb 28 2017 02:18
guys i need help with printing piramyd of numbers
Bozhidar Dimitrov
@phiratio
Feb 28 2017 02:19
im struggling with logic
Mike Woodall
@usnwoody
Feb 28 2017 02:19
@ESLMiguel yeah, it seems like I will have to revisit some of them later as well. when I began the counting cards problem, I couldn't think of how to start setting things up, lol.
Gulsvi
@gulsvi
Feb 28 2017 02:19
Yes, what that means, is your API URL also needs to be HTTPS since your Codepen is loaded over HTTPS
Change the API URL to start with HTTPS
If that doesn't work, then change the API URL back to starting with HTTP and open your codepen url over HTTP.
Mixed content means you're trying to open insecure content (http) from a secure (https) website
Seth
@sethdcd
Feb 28 2017 02:20
omg finally
thank you lol
Gulsvi
@gulsvi
Feb 28 2017 02:20
That console will be a lifesaver :)
ESLMiguel
@ESLMiguel
Feb 28 2017 02:20
@usnwoody my best suggestion is to keep a notebook. write down brainstorming ideas/notes. as they get harder, BEFORE you type any code, write a numbered list of steps that you think you will need to do
helped me a lot to 'set up' the solutions
Seth
@sethdcd
Feb 28 2017 02:21
@SkyCoder01 yeah i didn't realize + J showed it all
Mike Woodall
@usnwoody
Feb 28 2017 02:21
@ESLMiguel That is a great idea, Thanks! That is usually where i struggled was setting things up initially
CamperBot
@camperbot
Feb 28 2017 02:21
usnwoody sends brownie points to @eslmiguel :sparkles: :thumbsup: :sparkles:
:warning: usnwoody already gave eslmiguel points
Gulsvi
@gulsvi
Feb 28 2017 02:21
@sethdcd Glad you're not on Mac, I have no idea how to open the console there lol
ESLMiguel
@ESLMiguel
Feb 28 2017 02:22
@usnwoody someone smart said coding is 90% thinking and 10% writing code
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 02:22

function myReplace(str, before, after) {
  //console.log(before.isLowerCase());

var character = before[0];
var newStr="";
var re="";

if (character == character.toUpperCase()) {
   after= after.replace(0,after[0]).toUpperCase(); 
   re = /before/gi;

  newstr = str.replace(re, after);

}
if (character == character.toLowerCase()){

  if (character == character.toLowerCase()) {
   after= after.replace(0,after[0].toLowerCase()); 
   re = /before/gi;

  newstr = str.replace(re, after);

}


}
  return newStr;
}

myReplace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped");
can someone tell me what am I doing wrong
Mike Woodall
@usnwoody
Feb 28 2017 02:22
@ESLMiguel seems legit!
Seth
@sethdcd
Feb 28 2017 02:23
@SkyCoder01 ha yea! is there a reason why it is only showing one quote and just repeats it? i thought this was supposed to be a random quote api
tareq4
@tareq4
Feb 28 2017 02:24

Do not declare oopsGlobal using the var keyword

hi guys ...is there any way to declare it without the var kayword?

Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 02:24
@ESLMiguel can u please look at my code
Alexander Køpke
@alexanderkopke
Feb 28 2017 02:25
@Unitato5299 when you shift the array the length of it gets shorter... so after two iterations the length is 2 and and i is 2. So i < arr.length is no longer true, so the loop stops
Bozhidar Dimitrov
@phiratio
Feb 28 2017 02:26
2017-02-28_04h24_37.png
Stephen James
@sjames1958gm
Feb 28 2017 02:27
@pshiwakoti1 /before/gi is literal before not the variable.
re = new Regex(before, "gi")
is what you want
Bozhidar Dimitrov
@phiratio
Feb 28 2017 02:27
anyone up to help me figure out how to make such a pyramid? Please help me, im struggling a lot ..
function solve(arr) {
    let number = Number(arr[0]);
    let currentRow = 1;
    let currentNumber = 1;
    let globalString = "";

    do{
        let temp = "";
        for(let i = currentNumber; i <= currentRow; i++){
            temp += String(i);
            if(currentNumber === number){
                break;
            }
        }
        globalString += temp + "\n";
        temp = "";
        currentRow++;
    } while(currentRow == number);
    console.log(globalString);
}
my current code so far, it's unfinished
nitinol
@nitinol
Feb 28 2017 02:28
hello everyone
tareq4
@tareq4
Feb 28 2017 02:28

Hi guys ..how can i declare some thing with out (var) keyword ?

Do not declare oopsGlobal using the var keyword

Stephen James
@sjames1958gm
Feb 28 2017 02:28
@phiratio do you need to calculate the number of spaces at the start of the line based on the longest line?
Unitato5299
@Unitato5299
Feb 28 2017 02:28
@alexanderkopke i have the loop set to the length of the original array and the edited one as a separate variable so that wouldnt happen does that not work?
Bozhidar Dimitrov
@phiratio
Feb 28 2017 02:28
no
it's like
Stephen James
@sjames1958gm
Feb 28 2017 02:29
@tareq4
oopsGlobal = 10;
Bozhidar Dimitrov
@phiratio
Feb 28 2017 02:29
you enter number and it prints pyramid of numbers row 1 have 1 number row 2 have 2 row 3 3 and etc
Jacob Leatherwood
@dadleatherwood
Feb 28 2017 02:29
Can someone take a look at this?
function findLongestWord(str) {
  array =  str.split(' ');
  array.map (function(x) {
    newArray = x.length;
  });
  newArray.sort (function (a,b) {
      return a - b;
    });
}
findLongestWord("The quick brown fox jumped over the lazy dog");
tareq4
@tareq4
Feb 28 2017 02:29
@sjames1958gm but you should give it a variable first right?
Stephen James
@sjames1958gm
Feb 28 2017 02:29
@phiratio ah
nitinol
@nitinol
Feb 28 2017 02:29
im trying to figure out the Increment a Number with JavaScript lesson . im really stuck and didnt get this. pls help
Jacob Leatherwood
@dadleatherwood
Feb 28 2017 02:30
@nitinol What does your code look like?
Stephen James
@sjames1958gm
Feb 28 2017 02:30
@tareq4 leaving off the var is part of the challenge - showing that without the var it becomes global
nitinol
@nitinol
Feb 28 2017 02:30
js is much harder and complicated thatn html and css which doesent mean that im going to give up
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 02:30
@sjames1958gm even after I changed my code to the regex u suggested, it didn't work
Bozhidar Dimitrov
@phiratio
Feb 28 2017 02:30
any ideas how to figure that out?
nitinol
@nitinol
Feb 28 2017 02:30

var myVar = 87;

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

@dadleatherwood
Jacob Leatherwood
@dadleatherwood
Feb 28 2017 02:31
@nitinol What challenge again?
tareq4
@tareq4
Feb 28 2017 02:31
@sjames1958gm what does that mean actually ..(it becomes global)?
but it worked
nitinol
@nitinol
Feb 28 2017 02:31
Increment a Number with JavaScript @dadleatherwood
Stephen James
@sjames1958gm
Feb 28 2017 02:31
@pshiwakoti1 This looks wrong.
after= after.replace(0,after[0]).toUpperCase();
maybe
after= after.replace(after[0], after[0].toUpperCase());
nitinol
@nitinol
Feb 28 2017 02:32
i found tha 88 but could not change the myVar = myvar
@dadleatherwood
Stephen James
@sjames1958gm
Feb 28 2017 02:32
@tareq4 The variable is created in the global namespace
maybe reread the description
@nitinol see the instructions
you can replace i = i + 1 with i++
so what can you replace myVar = myVar + 1 with?
Jacob Leatherwood
@dadleatherwood
Feb 28 2017 02:34
@nitinol Try it without the '='
@nitinol myVar++
@nitinol Did that work for you?
Alexander Køpke
@alexanderkopke
Feb 28 2017 02:36
@Unitato5299 doesn't matter because the variables point to the same object in memory. http://jsbin.com/jijavicihi/edit?js,console I made this to illustrate
nitinol
@nitinol
Feb 28 2017 02:36
it did not unfortunately @dadleatherwood . i also tried without space
tareq4
@tareq4
Feb 28 2017 02:36
@sjames1958gm ok thx
CamperBot
@camperbot
Feb 28 2017 02:36
tareq4 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6074 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Jacob Leatherwood
@dadleatherwood
Feb 28 2017 02:38
@nitinol myVar++ should work. What does it say is the error? Do you have a ';' after?
Carolina
@carodelafuente
Feb 28 2017 02:38
hi, can someone help me understand why my .setGear method isn't working here:
  var gear = 0;

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

  this.getGear = function() {
    return gear;
  };
nitinol
@nitinol
Feb 28 2017 02:39
i dont know whats wrong with me guys @dadleatherwood @sjames1958gm
i tried @sjames1958gm . didnt work
mitron6
@mitron6
Feb 28 2017 02:40
@nitinol Nothing wrong with you? You are in the process of learning? Mistakes required to learn?
Carolina
@carodelafuente
Feb 28 2017 02:40
here is the full function, it is a constructor
var Bike = function() {

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

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

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

};
kparker730
@kparker730
Feb 28 2017 02:40
Hello all! I'm working on the "Check for palindromes" algorithm, and can't figure out why this code isn't working. Would appreciate any help!

function palindrome(str) {
str.replace(/^a-z0-9/gi).toLowerCase();
  if(str === str.split().reverse().join()){
return true;
}
 else {
   return false;
 }
}



palindrome("book");
nitinol
@nitinol
Feb 28 2017 02:41
yes right @mitron6 . thanks for your support
CamperBot
@camperbot
Feb 28 2017 02:41
nitinol sends brownie points to @mitron6 :sparkles: :thumbsup: :sparkles:
:cookie: 537 | @mitron6 |http://www.freecodecamp.com/mitron6
Naufaldi
@naufaldi
Feb 28 2017 02:41
function caseInSwitch(val) {
  var answer = "";
    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");
      break;
    default:
      console.log("Nothing");

  }
  return answer;  
}
can someone help me? where error?
Jacob Leatherwood
@dadleatherwood
Feb 28 2017 02:41
@nitinol No worries! Sometimes it can be the simplest thing! We are all learning together.
@kparker730 Make sure you lowercase the original string as well.
nitinol
@nitinol
Feb 28 2017 02:42
thnak you very much @dadleatherwood you are right . now i feel better . i should apply myself
kparker730
@kparker730
Feb 28 2017 02:43
thanks @dadleatherwood
CamperBot
@camperbot
Feb 28 2017 02:43
kparker730 sends brownie points to @dadleatherwood :sparkles: :thumbsup: :sparkles:
:cookie: 241 | @dadleatherwood |http://www.freecodecamp.com/dadleatherwood
Jacob Leatherwood
@dadleatherwood
Feb 28 2017 02:43
@kparker730 Sure. Work out for you?
@kparker730 I just worked on that one, and it took for a while.
kparker730
@kparker730
Feb 28 2017 02:44
Still messing around with it, ripping my hair out a little bit. Haha.
Bozhidar Dimitrov
@phiratio
Feb 28 2017 02:45
well thank you guys for nothing
As usually i managed alone to find sollution <3
Manish Giri
@Manish-Giri
Feb 28 2017 02:46
@naufaldi you're just logging stuff to the console, in each case
instead, assign the right value to answer
Jeremy Kraft
@J-Kraft
Feb 28 2017 02:47
@phiratio no worries mate you're welcome
Alexander Køpke
@alexanderkopke
Feb 28 2017 02:48
@Unitato5299 however, you could make a variable outside of the loop like var arrLength = arr.length; and then use this variable in your loop: i < arrLength. This will work because the length is a number and the value of number can be copied directly and work like you expect.
Naufaldi
@naufaldi
Feb 28 2017 02:52
@Manish-Giri Still cant understand :(
Carolina
@carodelafuente
Feb 28 2017 02:52
guys? :worried:
Manish Giri
@Manish-Giri
Feb 28 2017 02:52
@naufaldi like in case "xyz": answer = ...;
instead of console.log
@carodelafuente gear += change;
this is the problem
they want you to set gear to the new value
not increment with it..
replace the += with just =
Carolina
@carodelafuente
Feb 28 2017 02:53
oh just replace it, you're right
thank you @Manish-Giri such silly mistakes sometimes.
CamperBot
@camperbot
Feb 28 2017 02:53
carodelafuente sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4492 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Feb 28 2017 02:54
:+1:
c0d0er
@c0d0er
Feb 28 2017 02:54
@toianw thanks
CamperBot
@camperbot
Feb 28 2017 02:54
c0d0er sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
:cookie: 495 | @toianw |http://www.freecodecamp.com/toianw
Bonface
@TheBonface
Feb 28 2017 02:55
i need some help , I am working with string literals :worried:

// Setup
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr[0] = "H"; // Fix Me

CamperBot
@camperbot
Feb 28 2017 02:55
:bulb: to format code use backticks! ``` more info
Chris Jantzen
@XXiphias
Feb 28 2017 02:55
I've been trying out the FCC beta and came upon an exercise I cannot complete. It's a fairly simple exercise. Could someone test it and see if it completes for them? https://beta.freecodecamp.com/en/challenges/basic-javascript/global-scope-and-functions
Bonface
@TheBonface
Feb 28 2017 02:55

'''
// Setup
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr[0] = "H"; // Fix Me

'''

CamperBot
@camperbot
Feb 28 2017 02:55
:bulb: to format code use backticks! ``` more info
Naufaldi
@naufaldi
Feb 28 2017 02:55
@Manish-Giri thanks a lot. its work!
:smile:
CamperBot
@camperbot
Feb 28 2017 02:55
naufaldi sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4493 | @manish-giri |http://www.freecodecamp.com/manish-giri
Nicolas Pham-Dinh
@phamdinh
Feb 28 2017 02:59
So my card counting function here works as intended and passes all of the counting tests but FCC does not accept it. Any clue why?
var count = 0;

function cc(card) {
  // Only change code below this line
    switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;
    case 7:
    case 8:
    case 9:
      break;
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      count--;
      break;
  }

  if (count > 0) {
    return '"' + count + ' Bet"';
  } else {
    return '"' + count + ' Hold"';
  }
  // 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');
Bonface
@TheBonface
Feb 28 2017 03:00
'''
'''
CamperBot
@camperbot
Feb 28 2017 03:00
:bulb: to format code use backticks! ``` more info
Bonface
@TheBonface
Feb 28 2017 03:04
// Setup
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr[0] = "H"; // Fix Me
i need some help
Type error: cannot assign to read only property '0' of string 'Hello world'
Mike Woodall
@usnwoody
Feb 28 2017 03:06

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

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


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

// Change this value to test
phoneticLookup("charlie");
Can't figure out how to end this one out
@TheBonface try taking brackets off the zero replacing it with a .
Ken Haduch
@khaduch
Feb 28 2017 03:08
@usnwoody - you have to assign a value to result from the lookup object using the val property. In other words - start with result = and figure out how to perform the object lookup. Recognize that return result; is going to send whatever is in the result variable back to the caller, so you have to put something in result.
Gulsvi
@gulsvi
Feb 28 2017 03:09
@sethdcd That's the next problem to solve in the challenge ;) You'll need to disable cache in your API call.
Frederick Williams
@ftwilliams89
Feb 28 2017 03:10
Can some help discuss the Profile Lookup with me I want to see if I can talk my way to the right answer
Jacob Crawford
@jcrawfo4
Feb 28 2017 03:11
Can someone help me with Local Scope and Functions? I would really appreciate it.
Ken Haduch
@khaduch
Feb 28 2017 03:12
@TheBonface - the lesson is "Understand String Immutability" - means that you cannot do myStr[0] to change a letter in the string. The example shows this, and what you would have to do - replace the entire string with the desired final string.
Chris Jantzen
@XXiphias
Feb 28 2017 03:12
sure @ftwilliams89 What you thinking for it?
Mike Woodall
@usnwoody
Feb 28 2017 03:12
@khaduch it is returning "charlie" instead of "Chicago"
I started with result = val;
Carlo Blanco
@ccBlanco
Feb 28 2017 03:13

hi, so I am trying to figure also how to configure it to equal to their answer, javascript is not my strong suit! function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++) {

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

  product= arr[i][j];
}

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Mike Woodall
@usnwoody
Feb 28 2017 03:15
@khaduch

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

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

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

// Change this value to test
phoneticLookup("charlie");
Ken Haduch
@khaduch
Feb 28 2017 03:16
@usnwoody - okay, that's not right. You have an object - and that object has properties and values. In order to access a property and value in an object, you can use dot notation in some cases, and have to use bracket notation in other cases. But the result should be set bvy accessing result = someObject.someProperty; or result = someObject[someVariable]; where the someVariable contains a potential property name. If you study the testcases, you'll see that if "charlie" is passed to the function, you should return "Chicago" - so you have to access the object in a way that that should happen. But it should be general purpose enough so that other properties can be passed to the function.
Sooraj
@S4j
Feb 28 2017 03:16
```
var singleVal = array.reduce(function(previousVal, currentVal){
  return previousVal + currentVal;
}, 0);
singleVal = array;
Usman Akram
@usmanakram1996
Feb 28 2017 03:16
Plz help me compare two arrays and return the element that is not common in the arrays
Sooraj
@S4j
Feb 28 2017 03:17
Please somedbody help?
Mike Woodall
@usnwoody
Feb 28 2017 03:17
@khaduch AH!!!!!! Thanks!!
CamperBot
@camperbot
Feb 28 2017 03:17
usnwoody sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2550 | @khaduch |http://www.freecodecamp.com/khaduch
mitron6
@mitron6
Feb 28 2017 03:17
@S4j Remove last line.
Frederick Williams
@ftwilliams89
Feb 28 2017 03:17
thanks @XXiphias. Well I know to start with a for loop and set my var = 0 and use contacts.length but I get hung up in the if I mean if use \if(firstName === firstName && prop === prop) \ I get a answer right but I get stuck trying to single out things
CamperBot
@camperbot
Feb 28 2017 03:17
:cookie: 355 | @xxiphias |http://www.freecodecamp.com/xxiphias
ftwilliams89 sends brownie points to @xxiphias :sparkles: :thumbsup: :sparkles:
Ken Haduch
@khaduch
Feb 28 2017 03:18
@S4j - what are you required to do here?
Frederick Williams
@ftwilliams89
Feb 28 2017 03:18
like the "Sherlock", "likes" should return
Usman Akram
@usmanakram1996
Feb 28 2017 03:19
plz?
Mike Woodall
@usnwoody
Feb 28 2017 03:20
@khaduch I got it with result = lookup[val];
Bonface
@TheBonface
Feb 28 2017 03:20
@khaduch which i think i have done by assigning var myStr = "Hello World"
Ken Haduch
@khaduch
Feb 28 2017 03:20
@usmanakram1996 - what are you trying to do? Do you have any code that you have tried? Which lesson is it?
Brien Smarandache
@smarandache1990
Feb 28 2017 03:21
hey guys, i just solved 242 (Titlecase) with something weird. how practical would this be?
'code'

function titleCase(str) {
str = str.toLowerCase();
return str.replace(/\b\w(?!\s)/g, function(f) { // 'f' for (first letter) of occurrence/pattern
return f.toUpperCase();}).replace(/\s.\s/g,function(l) { // 'l' for (single letter pattern)
return l.toUpperCase();});
}

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

RLD2121
@RLD2121
Feb 28 2017 03:23
Hi all, noob question here. Why does the "str" only return twice when num = 3?:

function repeatStringNumTimes(str, num) {
if (num > 0) {
var arr = new Array(num);
return arr.join(str);
} else {return "";
}
}

repeatStringNumTimes("abc", 3);

Chris Jantzen
@XXiphias
Feb 28 2017 03:23
@ftwilliams89 you're on the right track. The way I did it was with 2 ifs. One comparing contacts firstName to firstName and an inner one checking if contacts has the property prop.
Bonface
@TheBonface
Feb 28 2017 03:23

@khaduch ``` // Setup
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr [0]= "H"; // Fix Me

```

Ken Haduch
@khaduch
Feb 28 2017 03:24
@usnwoody - YES! that's the way to do it. The thing to do with these after you get them is to review what the lesson was trying to relate to you, especially with the examples. It should be a close variation of what you need to do. The next thing is to study the test results, after you run it and see how things are supposed to pan out - then put it all together for a solution.
Brien Smarandache
@smarandache1990
Feb 28 2017 03:24

'''
function titleCase(str) {
str = str.toLowerCase();
return str.replace(/\b\w(?!\s)/g, function(f) { // 'f' for (first letter) of occurrence/pattern
return f.toUpperCase();}).replace(/\s.\s/g,function(l) { // 'l' for (single letter pattern)
return l.toUpperCase();});
}

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

CamperBot
@camperbot
Feb 28 2017 03:24
:bulb: to format code use backticks! ``` more info
Bonface
@TheBonface
Feb 28 2017 03:24
@khaduch

``` // Setup
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr [0]= "H"; // Fix Me

```

Moisés Man
@moigithub
Feb 28 2017 03:25
shift enter after backticks
backticks must be on its own line @TheBonface
Ken Haduch
@khaduch
Feb 28 2017 03:25
@TheBonface - the //Fix me comment means that that line is incorrect, so in the final solution, it should NOT exist in that form. In this case, you should just remove that line, and keep the one that you added.
Brien Smarandache
@smarandache1990
Feb 28 2017 03:26
function titleCase(str) {
  str = str.toLowerCase();
  return str.replace(/\b\w(?!\s)/g, function(f) { // 'f' for (first letter) of occurrence/pattern
    return f.toUpperCase();}).replace(/\s.\s/g,function(l) { // 'l' for (single letter pattern)
      return l.toUpperCase();});  
}

titleCase("I'm a little tea pot");
Bonface
@TheBonface
Feb 28 2017 03:26
ooh hehe ok
Usman Akram
@usmanakram1996
Feb 28 2017 03:26
its really tough i no get it what to do rather than starting from comparing two arrays
plz guide me
Carlo Blanco
@ccBlanco
Feb 28 2017 03:27

hey can someone help with this function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++) {

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

  product= arr[i][j];
}

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Bonface
@TheBonface
Feb 28 2017 03:30
@khaduch thank you , i initially thought it was a bug within the test code. It worked
CamperBot
@camperbot
Feb 28 2017 03:30
thebonface sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Jason Luboff
@JLuboff
Feb 28 2017 03:30
@ccBlanco 'product *= arr[i][j]'
CamperBot
@camperbot
Feb 28 2017 03:30
:star2: 2551 | @khaduch |http://www.freecodecamp.com/khaduch
Frederick Williams
@ftwilliams89
Feb 28 2017 03:30
@XXiphias somthing like this
Brien Smarandache
@smarandache1990
Feb 28 2017 03:31
@ccBlanco if that is straight from your code then your missing an operator before the =
like this *=
Frederick Williams
@ftwilliams89
Feb 28 2017 03:32
if(firstName ===firstName){
if(prop === contacts[i]){
}
}
Carlo Blanco
@ccBlanco
Feb 28 2017 03:33
Thanks @JLuboff
CamperBot
@camperbot
Feb 28 2017 03:33
ccblanco sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 981 | @jluboff |http://www.freecodecamp.com/jluboff
Aaron Bell
@awb715
Feb 28 2017 03:39
anyone up to steamroller?
Chris Jantzen
@XXiphias
Feb 28 2017 03:40
yes @ftwilliams89 Assuming one of those firstName's is actually a property of contacts
you want to iterate through the contacts array. so do contacts[var] with whatever your iterator is from the for loop then compare it's firstName property to firstName the variable
with property you just want to check if that property even exists in the contacts list at the current iterator
Rob
@throb36
Feb 28 2017 03:44
Anyone know why for Record Collection, it won't return anything but the damn collection?
Andrew Nichols
@frenata
Feb 28 2017 03:46
You're supposed to return the (updated) collection.
Chris Jantzen
@XXiphias
Feb 28 2017 03:47
@smarandache1990 I would suggest you filter the 2 arrays with array.filter. You can build a function for filter that checks if the value exists in the other array using indexOf
Stany
@stanycclg
Feb 28 2017 03:48
Can anyone tell me what i am doing wrong with manipulating arrays with unshift? This is my code myArray.unshift (["paul",35]);
Andrew Nichols
@frenata
Feb 28 2017 03:49
@XXiphias Or includes
Chris Jantzen
@XXiphias
Feb 28 2017 03:50
that looks fine @stanycclg. It should add "paul" and 35 to the start of your myArray array
Gulsvi
@gulsvi
Feb 28 2017 03:51
@stanycclg capital p in Paul and no space after unshift
Aaron Bell
@awb715
Feb 28 2017 03:51
anyoneup to steam roller?
NaveenRathor
@NaveenRathor
Feb 28 2017 03:52
trueOrFalse(true) should return "Yes, that was true"
trueOrFalse(false) should return "No, that was false"

function trueOrFalse(wasThatTrue) {

// Only change code below this line.

if (wasThatTrue){
return "yes, it's true";
}
else {
return "no, it's false";
}

// Only change code above this line.

}

Chris Jantzen
@XXiphias
Feb 28 2017 03:52
what issues you having with it @awb715 ?
NaveenRathor
@NaveenRathor
Feb 28 2017 03:52
where i'm wrong in this code
Aaron Bell
@awb715
Feb 28 2017 03:53
getting started
@XXiphias
Stany
@stanycclg
Feb 28 2017 03:53
ok sky is right, no space and a capital p did it
Chris Jantzen
@XXiphias
Feb 28 2017 03:53
ah.. gotcha
well good luck! :)
Stany
@stanycclg
Feb 28 2017 03:54
thanks all
lazylizard12
@lazylizard12
Feb 28 2017 03:54
NaveenRathor, its the capitals,
Frederick Williams
@ftwilliams89
Feb 28 2017 03:54
@XXiphias lol you kind of lost me after the "so do" part
Chris Jantzen
@XXiphias
Feb 28 2017 03:55
You're iterating through your contacts list
going through each object in it, one by one
so whatever variable you use in the for loop you can do contacts[i], assuming the variable was i
that way you can check each object in the contacts list
from there if you do contacts[i].firstName for example, you can check the first name from each object in the array and compare it against the first name you are looking for
Frederick Williams
@ftwilliams89
Feb 28 2017 03:56
oh I been did that
Chris Jantzen
@XXiphias
Feb 28 2017 03:57
ok
well what are you getting? :P
Frederick Williams
@ftwilliams89
Feb 28 2017 03:58
blank :smile:
johanna
@joehesse
Feb 28 2017 03:58

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

// Only change code below this line

secondTree1.list1 = "pine"; // Change this line

NaveenRathor
@NaveenRathor
Feb 28 2017 03:58
capital which one
Frederick Williams
@ftwilliams89
Feb 28 2017 03:58
for (var x = 0; x < contacts.length; x++){
   if(firstName === firstName){
      if(prop === contacts[x]){
        return contacts[x].firstName;

    }
  }

}
Chris Jantzen
@XXiphias
Feb 28 2017 03:59
well first things first. When you say firstName === firstName that will always be true
as you are comparing hte variable with itself
you want to compare firstName from contacts with the variable firstName
which is what I was explaining above
Aaron Bell
@awb715
Feb 28 2017 04:00
no1 up to steamroller?
Chris Jantzen
@XXiphias
Feb 28 2017 04:01
as for the if (prop bit. You're checking if prop === an entire object in contacts. You want to check if contacts[x] has the property 'prop'
NaveenRathor
@NaveenRathor
Feb 28 2017 04:02
trueOrFalse(true) should return "Yes, that was true"
trueOrFalse(false) should return "No, that was false"
Frederick Williams
@ftwilliams89
Feb 28 2017 04:02
ooooooooooohhhhhhh :o:
NaveenRathor
@NaveenRathor
Feb 28 2017 04:03
give any suggestion
Chris Jantzen
@XXiphias
Feb 28 2017 04:03
are you asking a question @NaveenRathor ..?
NaveenRathor
@NaveenRathor
Feb 28 2017 04:04
@XXiphias i'm asking a answer
trueOrFalse(true) should return "Yes, that was true"
trueOrFalse(false) should return "No, that was false"
Frederick Williams
@ftwilliams89
Feb 28 2017 04:04
@XXiphias thanks again I going read that doc you sent and call it a night
CamperBot
@camperbot
Feb 28 2017 04:04
ftwilliams89 sends brownie points to @xxiphias :sparkles: :thumbsup: :sparkles:
:warning: ftwilliams89 already gave xxiphias points
Chris Jantzen
@XXiphias
Feb 28 2017 04:04
haha ok. good luck
NaveenRathor
@NaveenRathor
Feb 28 2017 04:05
this is my code

function trueOrFalse(wasThatTrue) {

// Only change code below this line.

if (wasThatTrue){
return "yes, it's true";
}
else {
return "no, it's false";
}

// Only change code above this line.

}

lazylizard12
@lazylizard12
Feb 28 2017 04:05
sorry @NaveenRathor its the wording, it has to be exact.
Ken Haduch
@khaduch
Feb 28 2017 04:06
@usmanakram1996 - do you understand how the .filter method works? There is a link on that page that takes you to the documentation. It is a very useful function for solving this problem.
NaveenRathor
@NaveenRathor
Feb 28 2017 04:06
so what can i do for change
Andrew Nichols
@frenata
Feb 28 2017 04:06
Look at what is different from what you are printing and what they expect.
Change what you are printing to match.
Ken Haduch
@khaduch
Feb 28 2017 04:07
@NaveenRathor - look at the test results, and make sure that you are returning the exact strings - spelling, capitalization, punctuation. The testing code / results are very strict in what they are looking for.
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 04:07

function myReplace(str, before, after) {
  //console.log(before.isLowerCase());

var character = before[0];
var newStr="";
var re="";

if (character == character.toUpperCase()) {
   after= after.replace(after[0], after[0].toUpperCase());
   re = new Regex(before, "gi");

  newstr = str.replace(re, after);

}


  if (character == character.toLowerCase()) {
   after= after.replace(after[0], after[0].toLowerCase());
   re = new Regex(before, "gi");

  newstr = str.replace(re, after);

}
  return newStr;
}

myReplace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped");

`
what is wrong with my code
NaveenRathor
@NaveenRathor
Feb 28 2017 04:08
@khaduch
trueOrFalse should be a function
trueOrFalse(true) should return a string
trueOrFalse(false) should return a string
trueOrFalse(true) should return "Yes, that was true"
trueOrFalse(false) should return "No, that was false"
first three is done but last two is not
Andrew Nichols
@frenata
Feb 28 2017 04:09
@NaveenRathor You have all the information you need. We aren't going to do it for you.
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 04:09
im getting ReferenceError: regex is not defined
NaveenRathor
@NaveenRathor
Feb 28 2017 04:09
@frenata but give a suggestion
Andrew Nichols
@frenata
Feb 28 2017 04:10
We did!
Ken Haduch
@khaduch
Feb 28 2017 04:10
@NaveenRathor - look closely at the test results - you are returning return "yes, it's true"; and it is expecting return "Yes, that was true"; Why don't those two results match?
Andrew Nichols
@frenata
Feb 28 2017 04:10
@pshiwakoti1 Check what the JS regex module is called
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 04:11
I don't know how
Andrew Nichols
@frenata
Feb 28 2017 04:12
NaveenRathor
@NaveenRathor
Feb 28 2017 04:12
@khaduch i'm not understand what u trying to say
lazylizard12
@lazylizard12
Feb 28 2017 04:13
@NaveenRathor Look in the instructions not the example.
NaveenRathor
@NaveenRathor
Feb 28 2017 04:15
still is not working
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 04:15
@frenata I changed my regex to RegExp() but didn't work
lazylizard12
@lazylizard12
Feb 28 2017 04:16
Create an if statement inside the function to return "Yes, that was true" if the parameter wasThatTrue is true and return "No, that was false" otherwise.
NaveenRathor
@NaveenRathor
Feb 28 2017 04:17
yes i know this but i'm not understand
lazylizard12
@lazylizard12
Feb 28 2017 04:18
your code is right, but your string is not
Ken Haduch
@khaduch
Feb 28 2017 04:18

@NaveenRathor - the tests run your code, passing various values to your function, and your function returns a value that indicates the result of the function's execution. The test results for this:

trueOrFalse(true) should return "Yes, that was true"

Are expecting to receive a return value of a string that is spelled exactly like this: "Yes, that was true"
You do not have that string anywhere in your function - you have a string "yes, it's true", but that string is not the same exact text as "Yes, that was true". You have to change your function to return exactly the string that is being expected by the test code - then it should work. You have to do that for both strings. If you think that you changed it and it is still failing, please post your code again so we can help further.

NaveenRathor
@NaveenRathor
Feb 28 2017 04:18

function trueOrFalse(wasThatTrue) {

// Only change code below this line.

if (wasThatTrue){
return "yes, that was true";
}
else {
return "no, that was false";
}

// Only change code above this line.

}

//

this is my code
and it's not working
lazylizard12
@lazylizard12
Feb 28 2017 04:19
return "Yes, that was true";
Ken Haduch
@khaduch
Feb 28 2017 04:19
@NaveenRathor - please change the capitalization on the words "yes" to "Yes", and "no" to "No".... It has to be exact spelling!
NaveenRathor
@NaveenRathor
Feb 28 2017 04:21
thanks guys for support
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 04:21
hello guys any suggestions?
Andrew Nichols
@frenata
Feb 28 2017 04:22
Thus the cycle continues...
lazylizard12
@lazylizard12
Feb 28 2017 04:22
@NaveenRathor its sooo picky, all your spelling going forward has to be bang on.
Ken Haduch
@khaduch
Feb 28 2017 04:22
@frenata :worried:
kparker730
@kparker730
Feb 28 2017 04:22

Hello again everyone! I'm working on the "Check for palindrome" algorithm, and can't figure out why my code isn't working. Right now I'm trying to make sure that I'm splitting, reversing, and joining the string correctly.

Here is the code I am using:

function palindrome(str) {
  if(str === str.split().reverse().join()){
return true;
}
 else {
   return false;
 }
}

palindrome("book");

It is returning the input "book" as true. What am I doing wrong here? Thank you!

Andrew Nichols
@frenata
Feb 28 2017 04:22
@pshiwakoti1 If you're still getting the same error, you're probably still referring to regex incorrectly elsewhere.
@khaduch Problem is, that's the 3rd or 4th time I've seen that total unwillingness/inability to problem-solve.
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 04:23
I changed my regex to both places @frenata
Ken Haduch
@khaduch
Feb 28 2017 04:23
@kparker730 - str.split().reverse().join()) does what to your string?
@frenata - yes... kind of makes you want to :cry: sometimes...
Andrew Nichols
@frenata
Feb 28 2017 04:24
when it doubt, send it to console.log
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 04:24

function myReplace(str, before, after) {
  //console.log(before.isLowerCase());

var character = before[0];
var newStr="";
var re="";

if (character == character.toUpperCase()) {
   after= after.replace(after[0], after[0].toUpperCase());
   re = new RegExp(before, "gi");

  newstr = str.replace(re, after);

}


  if (character == character.toLowerCase()) {
   after= after.replace(after[0], after[0].toLowerCase());
   re = new RegExp(before, "gi");

  newstr = str.replace(re, after);

}
  return newStr;
}

myReplace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped");

`
would this work?
Andrew Nichols
@frenata
Feb 28 2017 04:25
I'm not sure you read the documentation on regex...
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 04:25
i tried @frenata but I probably didn't understand
Andrew Nichols
@frenata
Feb 28 2017 04:26
You can do String.replace without regex
"test".replace("t", "b"); // returns "best"
doing it with regex would look like:
re = new RegExp("^t");
"test".replace(re, "b");
Ken Haduch
@khaduch
Feb 28 2017 04:28
Mike Boardley
@Boardley
Feb 28 2017 04:38
I really need help with the "Sorted Union" algorithm. Can someone help?
Jakumozo
@Jakumozo
Feb 28 2017 04:39
could someone have a look, why don't I have the input box and the 'button' inline? why is there a margin? http://codepen.io/Kromel/pen/LWVwWg
Andrew Nichols
@frenata
Feb 28 2017 04:39
@Jakumozo Not a JS question.
@Boardley What are you confused about?
Ricky Martinez
@Rmartinez532
Feb 28 2017 04:42
Could someone help me out with trying to figure out the Global Scope and Functions

// Declare your variable here
var myGlobal(10)

function fun1() {
// Assign 5 to oopsGlobal Here
}

// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}

Instructions
Using var, declare a global variable myGlobal outside of any function. Initialize it with a value of 10.

Inside function fun1, assign 5 to oopsGlobal without using the var keyword.

Andrew Nichols
@frenata
Feb 28 2017 04:45
So you just posted the assignment. Have you tried to do it yet? @Rmartinez532
Harris Lim
@HarrisLim
Feb 28 2017 04:46
hey guys. How can I compare with sort?
Ricky Martinez
@Rmartinez532
Feb 28 2017 04:47
@frenata Yes, i just got it.. i was confused on what it was asking me to do.
kparker730
@kparker730
Feb 28 2017 04:47
thanks @khaduch
CamperBot
@camperbot
Feb 28 2017 04:47
kparker730 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2552 | @khaduch |http://www.freecodecamp.com/khaduch
Andrew Nichols
@frenata
Feb 28 2017 04:48
Great. :) It's a weird thing to ask you to do in a way, because it's asking you to do something that's a very bad idea... to show you why it's a bad idea.
@HarrisLim Did you read the documentation?
Ricky Martinez
@Rmartinez532
Feb 28 2017 04:49
yes, exactly so i got confused for a while. but Thank you @frenata
CamperBot
@camperbot
Feb 28 2017 04:49
rmartinez532 sends brownie points to @frenata :sparkles: :thumbsup: :sparkles:
:cookie: 429 | @frenata |http://www.freecodecamp.com/frenata
Muhammad Hakimi Shahrul Azmi
@hakimi1999
Feb 28 2017 05:01

There's a problem with my code...

It doesn't seems to remove null, it returns it instead


function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var result = [];


  function remove(a) {
    return a !== undefined && false && null && NaN && 0 && "";
  }


  arr.filter(remove);

  return arr;

}

bouncer([1, null, NaN, 2, undefined]);

// Returns [1,null,null,2,null]

How do I remove null from the code?

Alex G
@glazey132
Feb 28 2017 05:06
how do you use the replace function? how do you notify the symbols you want to replace?
Manish Giri
@Manish-Giri
Feb 28 2017 05:07
@glazey132 I think you use a regex/pattern/string as the first argument, and the value to replace with, as the second one
Carolina
@carodelafuente
Feb 28 2017 05:08
function factorialize(num) {
  var numArray = [];
  for (i = 0; i <= num; i++) {
    numArray.push(i);
  }
  var multiply = numArray.reduce(function(a, b) {
  return a * b;
  });
  return multiply;  

}




factorialize(5);
can someone tell me where I'm going wrong? I know i must have formatted it wrong but I'm stuck..
Alex G
@glazey132
Feb 28 2017 05:09
@Manish-Giri what is a regex?
Manish Giri
@Manish-Giri
Feb 28 2017 05:09
@glazey132 regular expression, like /\d+/g
Alex G
@glazey132
Feb 28 2017 05:10
@Manish-Giri ok thanks. i know g scans global. whata does \d+ do?
CamperBot
@camperbot
Feb 28 2017 05:10
:star2: 4497 | @manish-giri |http://www.freecodecamp.com/manish-giri
glazey132 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
Manish Giri
@Manish-Giri
Feb 28 2017 05:10
@carodelafuente if you have 0 in numArray, and when you get to multiply something to 0, what would you get?
@glazey132 \d matches digits
+ means match 1 or more occurrence of digits
Carolina
@carodelafuente
Feb 28 2017 05:13
@Manish-Giri oh okay, I changed my loop to start at 1. But now 0 doesn't work
Manish Giri
@Manish-Giri
Feb 28 2017 05:13
@carodelafuente then you need to have a special case for 0
Carolina
@carodelafuente
Feb 28 2017 05:14
@Manish-Giri do i have to write a whole separate for function for 0?
Manish Giri
@Manish-Giri
Feb 28 2017 05:15
@carodelafuente nope
Carolina
@carodelafuente
Feb 28 2017 05:15
hmm.
Manish Giri
@Manish-Giri
Feb 28 2017 05:15
@carodelafuente you could have an if/else
in the if, check if num is 0
and if so, push 1
in the else, do the for
you'd need to change reduce accordingly
Carolina
@carodelafuente
Feb 28 2017 05:17
ok, going to try that. @Manish-Giri thanks
CamperBot
@camperbot
Feb 28 2017 05:17
carodelafuente sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4498 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Feb 28 2017 05:18
@carodelafuente you could also try to use recursion, instead of reduce..
that's what I did..
Carolina
@carodelafuente
Feb 28 2017 05:20
@Manish-Giri i don't think i've learned recursion.
i'll google it though?
Andrew Nichols
@frenata
Feb 28 2017 05:20
@glazey132 https://regexone.com/ Fantastic site to learn how to regex.
Manish Giri
@Manish-Giri
Feb 28 2017 05:20
@carodelafuente and this might be a good time to!
recursion is just a function calling itself, until a "base condition"/"terminating condition" is met - upon which it returns
if you think about it
Tyler Lujan
@tlujan
Feb 28 2017 05:21
I need help with the "Golf Code"! is it just supposed to be a long if/else if?
Manish Giri
@Manish-Giri
Feb 28 2017 05:21
factorial of 5 is actually 5 multiplied by factorial of 4
Andrew Nichols
@frenata
Feb 28 2017 05:21

In the simplest definition, recursion is when a function calls itself

function hello(){
  return hello();
}

But ^ will fail with an "infinite recursion" error. So you have to know when to stop. ;)

Tyler Lujan
@tlujan
Feb 28 2017 05:22

'
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, 4); '

Manish Giri
@Manish-Giri
Feb 28 2017 05:22
factorial of 4 is actually 4 multiplied by factorial of 3
and so on
@carodelafuente
Tyler Lujan
@tlujan
Feb 28 2017 05:22
i know this isnt right at all
Manish Giri
@Manish-Giri
Feb 28 2017 05:22
until you reach a terminating case, which would be num == 0, in this case
Andrew Nichols
@frenata
Feb 28 2017 05:22
@tlujan ``` three backticks before and after your code to format it nicely
lazylizard12
@lazylizard12
Feb 28 2017 05:23
@tlujan part 1 use cases, part 2 use if else
Manish Giri
@Manish-Giri
Feb 28 2017 05:23
@tlujan to compare, use == or ===
Carolina
@carodelafuente
Feb 28 2017 05:23
@Manish-Giri do I still use a loop when i'm using recursion?
Manish Giri
@Manish-Giri
Feb 28 2017 05:23
= is just assigning stuff
@tlujan
no loops
just the function calling itself
@carodelafuente
Tyler Lujan
@tlujan
Feb 28 2017 05:23
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, 4);
thanks
Andrew Nichols
@frenata
Feb 28 2017 05:26
function bottles(n) {
  if(n>0) {
    console.log(n + " bottles of beer on the wall! Take one down, pass it around...");
    bottles(n-1);
  } else {
    console.log("No more bottles of beer!");
  }
}
Chris
@capozzic1
Feb 28 2017 05:26
Hey with React JS, can I declare variables inside a render function?
Tyler Lujan
@tlujan
Feb 28 2017 05:27
I still don't know what to do really tbh
Manish Giri
@Manish-Giri
Feb 28 2017 05:27
@capozzic1 yes
Andrew Nichols
@frenata
Feb 28 2017 05:27
@tlujan strokes = par changes the value of strokes instead of comparing it.
Sooraj
@S4j
Feb 28 2017 05:28
var singleVal = array.reduce(function(previousVal, currentVal){
return previousVal + currentVal;
}, 0);
Carolina
@carodelafuente
Feb 28 2017 05:28
@Manish-Giri woah it worked, but I have questions.
Sooraj
@S4j
Feb 28 2017 05:28
Thank you @mitron6
CamperBot
@camperbot
Feb 28 2017 05:28
s4j sends brownie points to @mitron6 :sparkles: :thumbsup: :sparkles:
:cookie: 538 | @mitron6 |http://www.freecodecamp.com/mitron6
Carolina
@carodelafuente
Feb 28 2017 05:28

function factorialize(num) {

  if (num === 0) {
    return 1;
  }
  else {
    return num * factorialize(num-1);
  }

}

factorialize(5);
Manish Giri
@Manish-Giri
Feb 28 2017 05:29
@frenata thx for your post on my forum topic, appreciate it
CamperBot
@camperbot
Feb 28 2017 05:29
manish-giri sends brownie points to @frenata :sparkles: :thumbsup: :sparkles:
:cookie: 432 | @frenata |http://www.freecodecamp.com/frenata
Sooraj
@S4j
Feb 28 2017 05:29
Got the answer but why are we using 0 at the end here
Manish Giri
@Manish-Giri
Feb 28 2017 05:29
@carodelafuente okay
Sooraj
@S4j
Feb 28 2017 05:29
```
var singleVal = array.reduce(function(previousVal, currentVal){
return previousVal + currentVal;
}, 0);
singleVal = array;
Carolina
@carodelafuente
Feb 28 2017 05:29
@Manish-Giri How on earth does it know what to do just by mimicking the function?
Sooraj
@S4j
Feb 28 2017 05:29
var singleVal = array.reduce(function(previousVal, currentVal){
  return previousVal + currentVal;
}, 0);
singleVal = array;
Manish Giri
@Manish-Giri
Feb 28 2017 05:29
@carodelafuente because of this return num * factorialize(num-1);
Tyler Lujan
@tlujan
Feb 28 2017 05:30
@frenata I understand that now. But I am still stuck idk
Sooraj
@S4j
Feb 28 2017 05:30
I have removed the last line and it worked but then why are we using zero at the end here. Please can anyone help
derekmortel
@derekmortel
Feb 28 2017 05:30
stuck on the golf code too
Manish Giri
@Manish-Giri
Feb 28 2017 05:30
at each step, factorialize calls itself, with the prev value minus 1 @carodelafuente
Andrew Nichols
@frenata
Feb 28 2017 05:30
@Manish-Giri No problem. I'm trying to fight the same battle.
@tlujan So don't change values, compare them instead.
Jacob Crawford
@jcrawfo4
Feb 28 2017 05:31
Thanks @CaroleAnneHannon for your help with Checkpoint: Stand in Line
CamperBot
@camperbot
Feb 28 2017 05:31
jcrawfo4 sends brownie points to @caroleannehannon :sparkles: :thumbsup: :sparkles:
:cookie: 874 | @caroleannehannon |http://www.freecodecamp.com/caroleannehannon
how to solve this?
Tyler Lujan
@tlujan
Feb 28 2017 05:32
gotcha
MidhunGeorge
@MidhunGeorge
Feb 28 2017 05:32
anyone please help....
Tyler Lujan
@tlujan
Feb 28 2017 05:32
@frenata thanks
CamperBot
@camperbot
Feb 28 2017 05:32
tlujan sends brownie points to @frenata :sparkles: :thumbsup: :sparkles:
:cookie: 433 | @frenata |http://www.freecodecamp.com/frenata
Andrew Nichols
@frenata
Feb 28 2017 05:32
x = 3 changes x to the value of 3, then returns 3
x == 3 compares x to the value of 3, then returns true or false (depending on the value in x)
Carolina
@carodelafuente
Feb 28 2017 05:32
@Manish-Giri i understand what it's doing, but how does it loop and do that for every number below it? With return num * factorialize(num-1), I only see 1 number getting multiplied by one below it.
Manish Giri
@Manish-Giri
Feb 28 2017 05:33

@carodelafuente so, factorialize(4) will be 4 * factorialize(3),
factorialize(3) will be 3 * factorialize(2), and so on

this goes on until factorialize(0) is reached, which returns 1

when this happens, the return value of 1 is passed back up top one by one, so factorialize(1) would be 1 * fact(0) = 1 * 1 = 1, fact(2) will be 2 * fact(1) = 2 * 1 = 2
factorialize(3) will be 3 * factorialize(2) = 3 * 2 = 6
and so on, until you compute factorialize(5)

Chris
@capozzic1
Feb 28 2017 05:33
@Manish-Giri Thanks
CamperBot
@camperbot
Feb 28 2017 05:33
capozzic1 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4499 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Feb 28 2017 05:34
it's like going down the layers till you reach the base case, and when you get the return value, riding back up the layers with the value computed from each layer
@carodelafuente
derekmortel
@derekmortel
Feb 28 2017 05:34
function golfScore(par, strokes) {
// Only change code below this line
if (strokes == 1) { //<--Is this correct
return "Hole-in one!";
Carolina
@carodelafuente
Feb 28 2017 05:35
@Manish-Giri ohh, i see! I think i understand. it only stops at the 'base' which is 0, because i stated it in my if statement right?
Sooraj
@S4j
Feb 28 2017 05:35
@MidhunGeorge Are you following the instructions there? Why are you using array there?
Manish Giri
@Manish-Giri
Feb 28 2017 05:35
@carodelafuente yes!
that is the "base case"
Carolina
@carodelafuente
Feb 28 2017 05:35
if not it would go on forever @Manish-Giri
ohhh!!! Wow, awesome
@Manish-Giri thank you so much
CamperBot
@camperbot
Feb 28 2017 05:35
carodelafuente sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: carodelafuente already gave manish-giri points
Manish Giri
@Manish-Giri
Feb 28 2017 05:36
@capozzic1 welcome
@carodelafuente welcome
Sooraj
@S4j
Feb 28 2017 05:36
@MidhunGeorge you just have to assign the value
@Manish-Giri bro please help me understand why we are using zero here

var singleVal = array.reduce(function(previousVal, currentVal){
  return previousVal + currentVal;
}, 0);
I can get the solution but not the concept
Manish Giri
@Manish-Giri
Feb 28 2017 05:37
@S4j 0 starts out as the default first value, the first time when reduce runs
it's optional
Andrew Nichols
@frenata
Feb 28 2017 05:39
@carodelafuente Here's another example of recursion:
function alphabet(letter) {
    let next = String.fromCharCode(letter.charCodeAt(0)+1);
  if(next == "z"){
      return "z";
  } else {
      return letter + alphabet(next);
  }
}

console.log(alphabet("a"));
Sooraj
@S4j
Feb 28 2017 05:40
Oh ok. and it's optional. Can we not use the comma after the flower bracket as well? Just the semicolon after the flower bracket?
Manish Giri
@Manish-Giri
Feb 28 2017 05:40
derekmortel
@derekmortel
Feb 28 2017 05:41
function golfScore(par, strokes) {
// Only change code below this line
if (strokes == 1) { //<--Is this correct
return "Hole-in one!";
any help?
nvm i was missing "-" lol
Sooraj
@S4j
Feb 28 2017 05:42
oh oh oh oh . Got it got it. So we are starting from 0 here. The link you've sent me helped. Great. Thank you so much, again! @Manish-Giri
CamperBot
@camperbot
Feb 28 2017 05:42
s4j sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4500 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Feb 28 2017 05:42
@S4j :+1:
Chris
@capozzic1
Feb 28 2017 05:44
@derekmortel maybe type return "Hole-in one!" in between the curly brackets ?
not sure
Muhammad Hakimi Shahrul Azmi
@hakimi1999
Feb 28 2017 05:44
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var process = [];
  var result = [];

  function remove(obj) {

    return obj !== false || null || 0 || "" || undefined || NaN;
  }


  process = arr.filter(remove);

  result = process.filter(function(a) {
    return a !== null;
  });

  return process;

}

bouncer([1, null, NaN, 2, undefined]);

It seems that this code cannot remove null values...

[1,null,null,2,null]

Any suggestions on how to remove the values?

Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 05:45
guys I can't console.log() out in algorithm challenge sections. How do I do that ? is there any other site where I can test my javascript code?
Ayush Bahuguna
@relentless-coder
Feb 28 2017 05:45
your browser console @pshiwakoti1
Joseph
@revisualize
Feb 28 2017 05:45
Hey hey.
@hakimi1999 Your return logic is NOT correct.
Chris
@capozzic1
Feb 28 2017 05:46
@pshiwakoti1 for the algorithm challenges, I used jsfiddle.net since I didn't like freecodecamp's environment
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 05:47
@capozzic1 thanks chris Let me try this
CamperBot
@camperbot
Feb 28 2017 05:47
pshiwakoti1 sends brownie points to @capozzic1 :sparkles: :thumbsup: :sparkles:
:cookie: 230 | @capozzic1 |http://www.freecodecamp.com/capozzic1
Joseph
@revisualize
Feb 28 2017 05:47

@hakimi1999 How to write an if conditional statements with OR and AND operators:
I am seeing a large number of people writing if conditions using OR and AND operators incorrectly.
Here is an example of what I'm seeing:

if (param1 == "a" || "c" || "e") { // incorrect
   var output = "Odd lowercase alpha character"; 
}

What I think people think is that it will compare param1 to "a" then compare param1 to "c" then compare param1 to "e"
However, that's not actually what the computer is processing.

if conditions need to be evaluated to true for the if statement to run:

if ((condition1) || (condition2) || (condition3) {
    // true statement
}

And how we would code that up from our example above where we're trying to get the odd character from a parameter (param1):

if (param1 == "a" || param1 == "c" || param1 == "e") {
   var output = "Odd lowercase alpha character"; 
}

I'm also seeing people writing and statements like this:

if (param1 == "a" && param1 == "e") {
}

The problem with this is the fact that a variable can't really be two strings or two different numbers at the same time.

Andrew Nichols
@frenata
Feb 28 2017 05:47
@hakimi1999 || doesn't work like that
Devean
@deveanpurohit
Feb 28 2017 05:47

Hi, I am going through confirm the ending problem. Here are two scenarios:
confirmEnding("Bastian", "n") should return true.
confirmEnding("He has to give me a new name", "name") should return true.

Now I am confused as Bastian is single string so I have to split it and then resolve the problem and another one is complete string which can be resolved using substr. Kindly can anybody explain me the problem.

Andrew Nichols
@frenata
Feb 28 2017 05:47
@hakimi1999 You would have to do
x == 1 || x ==2 || x ==3
But there's also a way better way for that challenge. Testing for the different "kinds" of falsey is the wrong approach. Just test once. @hakimi1999
Sewwandi Dharmapriya
@SewwandiD
Feb 28 2017 05:48
@JLuboff Thank you for the explanation.. It's well understood now!!
CamperBot
@camperbot
Feb 28 2017 05:48
sewwandid sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 982 | @jluboff |http://www.freecodecamp.com/jluboff
Manish Giri
@Manish-Giri
Feb 28 2017 05:48
check if a value is truthy
Joseph
@revisualize
Feb 28 2017 05:48
Yeah.. Use Boolean
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 05:49
@capozzic1 how do I see output in jjiddle
Tyler Lujan
@tlujan
Feb 28 2017 05:49

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, 4);
Devean
@deveanpurohit
Feb 28 2017 05:49

Can anyone help me in understanding the problem:
Hi, I am going through confirm the ending problem. Here are two scenarios:
confirmEnding("Bastian", "n") should return true.
confirmEnding("He has to give me a new name", "name") should return true.

Now I am confused as Bastian is single string so I have to split it and then resolve the problem and another one is complete string which can be resolved using substr. Kindly can anybody explain me the problem.

Joseph
@revisualize
Feb 28 2017 05:49
@tlujan Your return strings are NOT exact.
Tyler Lujan
@tlujan
Feb 28 2017 05:49
I am still stuck geeeze
Ogundele Olumide
@Lumexralph
Feb 28 2017 05:49
@Manish-Giri :wave: bro
Xi
@yuman959
Feb 28 2017 05:49
Hi, I’m stuck on the Twitter API for the random quotes machine exercise. On twitter’s API resource https://dev.twitter.com/web/tweet-button I didn’t find a place that talks about dynamic content insertion to tweet random quotes generated. Can anybody point me to the right direction/link for this? So far I added this to my html and the tweet function works - just not the dynamic texts I needed.
Muhammad Hakimi Shahrul Azmi
@hakimi1999
Feb 28 2017 05:49
@revisualize Okay, got it :smile: Let me try to solve it...
Joseph
@revisualize
Feb 28 2017 05:49
@tlujan They need to be EXACT.
Tyler Lujan
@tlujan
Feb 28 2017 05:49
ELI5?
Manish Giri
@Manish-Giri
Feb 28 2017 05:50
@Lumexralph :smile: :sun_with_face: :wave:
Tyler Lujan
@tlujan
Feb 28 2017 05:50
I need to do math?
Manish Giri
@Manish-Giri
Feb 28 2017 05:50
good morning
Joseph
@revisualize
Feb 28 2017 05:50
@tlujan Hole-in-one!
Tyler Lujan
@tlujan
Feb 28 2017 05:50
ugh
Chris
@capozzic1
Feb 28 2017 05:50
@pshiwakoti1 you can press CTRL + shift + I on your keyboard. then you will see it says "console"
Sewwandi Dharmapriya
@SewwandiD
Feb 28 2017 05:50
@tlujan Is this the answer.. Because I'm also in the same stage..?
Xi
@yuman959
Feb 28 2017 05:50
<a class= "btn twitter-share-button" href="https://twitter.com/share"data-size="large" data-text = "change that">Tweet This</a><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
Tyler Lujan
@tlujan
Feb 28 2017 05:50
@SewwandiD idk ive been stuck for 15 minutes
Ogundele Olumide
@Lumexralph
Feb 28 2017 05:50
@Manish-Giri morning :smile: ....
Joseph
@revisualize
Feb 28 2017 05:50
@SewwandiD That is not the answer.
Chris
@capozzic1
Feb 28 2017 05:51
@pshiwakoti1 then, under console, whenever you run the code using console.log, it should show up
Joseph
@revisualize
Feb 28 2017 05:51
@tlujan You've been stuck on one challenge for 15min. That's cute.
Andrew Nichols
@frenata
Feb 28 2017 05:51
:laughing: Get used to being stuck.
Sewwandi Dharmapriya
@SewwandiD
Feb 28 2017 05:51
@tlujan @revisualize Actualy I don't understand what they ask me to do there..
Xi
@yuman959
Feb 28 2017 05:51
<a class= "btn twitter-share-button" href="https://twitter.com/share"data-size="large" data-text = "change that">Tweet This</a><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 05:52
function myReplace(str, before, after) {
  //console.log(before.isLowerCase());

var character = before[0];
var newStr="";
var re="";

if (character == character.toUpperCase()) {
   after= after.replace(after[0], after[0].toUpperCase());
  // re = new RegExp(before, "gi");
  console.log(after);

  re = before.replace(before, after);

  newstr = str.replace(re, after);

}


  if (character == character.toLowerCase()) {
   after= after.replace(after[0], after[0].toLowerCase());
   //re = new RegExp(before, "gi");
    re = before.replace(before, after);

  newstr = str.replace(re, after);

}
  return newStr;
}

myReplace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped");

`
Muhammad Hakimi Shahrul Azmi
@hakimi1999
Feb 28 2017 05:52
Thanks @revisualize @frenata
CamperBot
@camperbot
Feb 28 2017 05:52
hakimi1999 sends brownie points to @revisualize and @frenata :sparkles: :thumbsup: :sparkles:
:cookie: 434 | @frenata |http://www.freecodecamp.com/frenata
:star2: 3371 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Feb 28 2017 05:52
@SewwandiD It wants you to return a string based upon conditional logic.
Sewwandi Dharmapriya
@SewwandiD
Feb 28 2017 05:52

```function golfScore(par, strokes) {
// Only change code below this line
if ((4,1)&&(1,1)){
return "Hole-in-one!";
}
else if ((4,2)&&(5,2)){
return "Eagle";
}
else if (4,3){
return "Birdie";
}
else if ((4,4)&&(5,5)){
return "Par";
}
else if (4,5){
return "Bogey";
}
else if (4,6){
return "Double Bogey";
}
else if((4,7)&&(5, 9)){
return "Go Home!";
}

// Only change code above this line
}

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

Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 05:52
I can't tell where I am wrong
Joseph
@revisualize
Feb 28 2017 05:52
@SewwandiD All of your conditional logic is wrong.
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 05:52
since im unable to console.log out the values
Joseph
@revisualize
Feb 28 2017 05:52
@pshiwakoti1 You can console.log
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 05:53
I don't see it on output
Joseph
@revisualize
Feb 28 2017 05:53
@pshiwakoti1 It's in your console.
Where it belongs.
Where all console.log messages go.
The console.
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 05:53
broswer console?
Joseph
@revisualize
Feb 28 2017 05:53
Yes
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 05:53
ok
Sewwandi Dharmapriya
@SewwandiD
Feb 28 2017 05:54
@tlujan Have any idea now?
Manish Giri
@Manish-Giri
Feb 28 2017 05:54
@SewwandiD if ((4,1)&&(1,1)){
what's this?
Joseph
@revisualize
Feb 28 2017 05:54
@SewwandiD Your conditions aren't following the instructions.
Tyler Lujan
@tlujan
Feb 28 2017 05:54

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, 4);
Joseph
@revisualize
Feb 28 2017 05:55
@tlujan Get it?
Tyler Lujan
@tlujan
Feb 28 2017 05:55
apparently my Double Bogey is wrong
nope
Joseph
@revisualize
Feb 28 2017 05:55
I think the condition for Bogey is actually wrong.
Tyler Lujan
@tlujan
Feb 28 2017 05:56
I switched Double Bogey to ```>=
Sewwandi Dharmapriya
@SewwandiD
Feb 28 2017 05:56
@revisualize @Manish-Giri :( Al right.. I'll try more and come back !
Tyler Lujan
@tlujan
Feb 28 2017 05:56
and it didnt work
Joseph
@revisualize
Feb 28 2017 05:56
Because that one isn't wrong.
BOGEY
Crap.
Tunnel time.
I am going to lose cell reception.
bye.
Tyler Lujan
@tlujan
Feb 28 2017 05:57

```
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, 4);

Manish Giri
@Manish-Giri
Feb 28 2017 05:57
@SewwandiD okay, btw, read the table on the left..the first column is strokes and the second one is what you should compare strokes to, in each comparison. So, no hardcoding numbers like if(4,1)
Tyler Lujan
@tlujan
Feb 28 2017 05:57
im just muffing
Danielfro5
@Danielfro5
Feb 28 2017 05:58
Greetings friends, just wondering why the code I wrote seems to work but will not pass the test. its for the CAESARS CIPHER CHALLENGE. https://cpy.pt/FUvGxThh it seems to return correct answers but I do not get a pass. thanks :)
Joseph
@revisualize
Feb 28 2017 05:58
@tlujan Bogey condition is still wrong. Now Double Bogey is wrong too.
Tyler Lujan
@tlujan
Feb 28 2017 05:58
pls
Joseph
@revisualize
Feb 28 2017 05:58
@tlujan They are supposed to be ==
cbot
CamperBot
@camperbot
Feb 28 2017 05:59
you called?
Tyler Lujan
@tlujan
Feb 28 2017 05:59
@revisualize THANK YOU
CamperBot
@camperbot
Feb 28 2017 05:59
tlujan sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3372 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Feb 28 2017 05:59
I still have cell reception.
I'm in the Seattle Bus Tunnel.
Chris
@capozzic1
Feb 28 2017 05:59
@pshiwakoti1 https://jsfiddle.net/kn9fk2pL/ might help. output is for looking at what html, javascript, and css would produce. console.log is for the console of the browser.
Joseph
@revisualize
Feb 28 2017 05:59
hehe
Manish Giri
@Manish-Giri
Feb 28 2017 06:00
I just use jsbin
at least I don't need to load external resources just to check console output
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 06:03
I need help I can't tell where Iam wrong
Ogundele Olumide
@Lumexralph
Feb 28 2017 06:04
@pshiwakoti1 show your code
Harvinder Athwal
@harvinderathwal
Feb 28 2017 06:04
@pshiwakoti1 can you tell where you stuck
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 06:05
function myReplace(str, before, after) {
  //console.log(before.isLowerCase());

var character = before[0];
var newStr="";
var re="";

if (character == character.toUpperCase()) {
   after= after.replace(after[0], after[0].toUpperCase());
  // re = new RegExp(before, "gi");
  console.log(after);

  re = before.replace(before, after);

  newstr = str.replace(re, after);

}


  if (character == character.toLowerCase()) {
   after= after.replace(after[0], after[0].toLowerCase());
   //re = new RegExp(before, "gi");
    re = before.replace(before, after);

  newstr = str.replace(re, after);

}
  return newStr;
}

myReplace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped");

`
derekmortel
@derekmortel
Feb 28 2017 06:08

'''

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");
break;
}
'''

CamperBot
@camperbot
Feb 28 2017 06:08
:bulb: to format code use backticks! ``` more info
Ogundele Olumide
@Lumexralph
Feb 28 2017 06:08
@pshiwakoti1 why're you doing this var character = before[0];?
derekmortel
@derekmortel
Feb 28 2017 06:08
Any help?
Manish Giri
@Manish-Giri
Feb 28 2017 06:08
@derekmortel you need to assign things to answer in each case, instead of logging stuff.
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 06:08
@Lumexralph to get teh first character in a string
Ogundele Olumide
@Lumexralph
Feb 28 2017 06:08
@derekmortel assign the respective string to answer for each cases not logging it
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 06:09
I wana check if it is a capital letter or not
Ogundele Olumide
@Lumexralph
Feb 28 2017 06:09
@pshiwakoti1 that'll mean J inJumped, right?
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 06:09
yes
Ogundele Olumide
@Lumexralph
Feb 28 2017 06:11
@pshiwakoti1 can you just say what you're trying to do? can't start going through your whole code without knowng what you're trying to achieve
Kamal
@kpbro
Feb 28 2017 06:11
Capture.PNG
cant understand what i have to do here
derekmortel
@derekmortel
Feb 28 2017 06:12
switch (val) {
case answer = 1:
console.log("alpha");
break;
case answer = 2:
console.log("beta");
break;
case answer = 3:
console.log("gamma");
break;
case answer = 4:
console.log("delta");
break;
}
@Lumexralph @Manish-Giri like this?
Manish Giri
@Manish-Giri
Feb 28 2017 06:12
@kpbro you need to form a string, and assign it to result, using string concatenation (+). The string has to be formed by concatenating the four parameters in your function - myNoun, myAdjective, etc, along with spaces and (optionally) some words of your own - to form a coherent sentence.
Ogundele Olumide
@Lumexralph
Feb 28 2017 06:12
@derekmortel answer = "alpha" for case 1 ditto for the rest
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 06:13
Im finding the first character in before string first and try to check if it is a capital letter. If yes replace before string with after string with capitalized letter
Ogundele Olumide
@Lumexralph
Feb 28 2017 06:14
@kpbro if you know how to concatenate strings, your parameters are holding strings you're to concatenate together separating them with spaces " "
derekmortel
@derekmortel
Feb 28 2017 06:14
thanks! @Lumexralph @Manish-Giri
CamperBot
@camperbot
Feb 28 2017 06:14
derekmortel sends brownie points to @lumexralph and @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 1209 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 4502 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ogundele Olumide
@Lumexralph
Feb 28 2017 06:14
@derekmortel
case 1:
answer = "alpha";
break;
Andrew Nichols
@frenata
Feb 28 2017 06:17
@derekmortel Try to understand what each of these components actually does:
switch case break answer = "foo"
Making it work is good. Understanding why it works is 1000x better.
Kamal
@kpbro
Feb 28 2017 06:18
@Manish-Giri @Lumexralph thanks
CamperBot
@camperbot
Feb 28 2017 06:18
kpbro sends brownie points to @manish-giri and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 4503 | @manish-giri |http://www.freecodecamp.com/manish-giri
:star2: 1210 | @lumexralph |http://www.freecodecamp.com/lumexralph
Danielfro5
@Danielfro5
Feb 28 2017 06:18
Hello, can anybody tell me where im going wrong with the Caesars Cipher Challenge. My code seems to work but i do not get a pass for reasons unknown to me. thanks
Jor
@joreyesl
Feb 28 2017 06:18
@Danielfro5 post code?
Prakash Shiwakoti
@pshiwakoti1
Feb 28 2017 06:19
@Lumexralph Can you please let me know where I am wrong
Juan Sebastian Ortega
@juanakin180
Feb 28 2017 06:19
@Manish-Giri could you help me with a JavaScrip challenge please?