These are chat archives for FreeCodeCamp/HelpJavaScript

31st
Mar 2017
Joseph
@revisualize
Mar 31 2017 00:00
@nitinol By doing: var myStr; you're not actually assigning anything. You're saying declare this variable terminate then do this other thing.
nitinol
@nitinol
Mar 31 2017 00:00
ohhh
Joseph
@revisualize
Mar 31 2017 00:00
@nitinol You're also not escaping a backslash before the SecondLine
@nitinol You have to assign 'FirstLine newline backslash SecondLine backslash carriage-return ThirdLine' to the variable myStr.
But, You have to replace the escape words with the proper escape sequences. (And per the instructions: remove all spaces.)
How do you escape a newline? With: \n
How do you escape a backslash? With: \\
How do you escape a carriage-return? With \r
nitinol
@nitinol
Mar 31 2017 00:02
thank you very much @revisualize . i got that this is asewom
CamperBot
@camperbot
Mar 31 2017 00:02
nitinol sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3633 | @revisualize |http://www.freecodecamp.com/revisualize
nitinol
@nitinol
Mar 31 2017 00:02
e
Cale Switzer
@Tennyx
Mar 31 2017 00:03
is anyone on who knows ajax well?
Gulsvi
@gulsvi
Mar 31 2017 00:06
@Tennyx depends on how "well" you mean, but ask away, I might be able to help
nitinol
@nitinol
Mar 31 2017 00:11
hello @revisualize im almost done but i couldnt figure out the encoded text situation here . plase look up my code here:

var myStr='FirstLine\nSecondLine\\\\\rThirdLine';
i got the escapes but the encoded text
Stephen James
@sjames1958gm
Mar 31 2017 00:12
@nitinol Two \\ before and \\ after SecondLIne
Cale Switzer
@Tennyx
Mar 31 2017 00:12

@SkyCoder01 So I made an app with python backend using google's app engine for hosting and their webapp2 framework and ajax for connecting to the db etc.

It's a very simple app that shuffles team matchups in bubble hockey (we play at work), then after a match is done you select the team that won and submit the info (winners losers) to a db. It keeps tally beyond just that one session so a db is necessary. It works great when I am wired in to an internet connection.

However when I brought it to the bubble hockey table, in a room with poor internet, some wins and losses would hit the database and others would not. The way it's set up is when I submit one of the matchup results, an ajax call goes to one of my handlers that then pulls from my db, adds the new win or loss to the tally, and sends that info back to the db and back to my app to be decoded via javascript. With this setup am I just screwed using it in bad internet environments? Or is there something I can do to help make sure the data writes every time.

jake vickers
@gentlejake605
Mar 31 2017 00:13
blob
this is the last problem im doing for tonight probably
can i get help
on it
Stephen James
@sjames1958gm
Mar 31 2017 00:14
@gentlejake605 you have en not em
jake vickers
@gentlejake605
Mar 31 2017 00:14
thank you
Gulsvi
@gulsvi
Mar 31 2017 00:14
@Tennyx Sorry, that seems more like a question of data resiliency over lossy networks, not a question about ajax
ivorygrant
@ivorygrant
Mar 31 2017 00:14
hi everyone working on the longest word on a string. can anyone please point me the right direction?
function findLongestWord(str) {

  var splitConditions = /\s+/;
  var split = str.split(splitConditions);
  var holder;

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

    if (split[i].length < split[i++].length)

      {
        holder = split[i++].length;


      }

    }

  return holder;
}
Gulsvi
@gulsvi
Mar 31 2017 00:15
I'm sure ajax is doing all it can when it can, but if you have dropped packets, your only option is to store that data somewhere until your network can be more resilient I imagine.
Stephen James
@sjames1958gm
Mar 31 2017 00:15
@ivorygrant Try initializing holder to 0 and comparing each word against holder
jake vickers
@gentlejake605
Mar 31 2017 00:15
<script>
$(document).ready(function() {
$("#target1").css("color", "red");
$("button").html("<em>#target4</em>");

});
</script>
Stephen James
@sjames1958gm
Mar 31 2017 00:15
@Tennyx You could make reading the data back as part of the write process, retrying the write until the read succeeds.
Gulsvi
@gulsvi
Mar 31 2017 00:15
tbh, @Tennyx I was expecting to hear about a CORS error lol
Stephen James
@sjames1958gm
Mar 31 2017 00:16
@gentlejake605 make sure you are selecting the button using the id or all the buttons will changed
ivorygrant
@ivorygrant
Mar 31 2017 00:17
@sjames1958gm thank you! got it right. with the code i had, why was that not correct? I thought it logical to compare the the first word to the next word.
CamperBot
@camperbot
Mar 31 2017 00:17
ivorygrant sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6444 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Cale Switzer
@Tennyx
Mar 31 2017 00:17
@SkyCoder01 thanks sky
CamperBot
@camperbot
Mar 31 2017 00:17
tennyx sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 772 | @skycoder01 |http://www.freecodecamp.com/skycoder01
nitinol
@nitinol
Mar 31 2017 00:17
i dont get this @sjames1958gm . still doesnt work but i will get it
i will make more research
Gulsvi
@gulsvi
Mar 31 2017 00:17
@Tennyx Sorry I don't have a direct answer for that :/
Cale Switzer
@Tennyx
Mar 31 2017 00:18
@sjames1958gm thanks, so r u saying I should maybe make a function in my backend that say...checks the json object before doing anything with it to make sure it has 'x' keys and all keys have properties?
CamperBot
@camperbot
Mar 31 2017 00:18
tennyx sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6445 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Cale Switzer
@Tennyx
Mar 31 2017 00:18
@SkyCoder01 np!
jake vickers
@gentlejake605
Mar 31 2017 00:18
ill firgure this out tommarow im to tired for this XDDDD sorry thank yyou as always for the help imma go get some rest good ngiht all and il see you tommaorw for a new day of coding!!
Stephen James
@sjames1958gm
Mar 31 2017 00:19
@ivorygrant you are incrementing i in the test so that when you save the value you are on to the next word
@gentlejake605 l8ter -
@Tennyx If the bad internet is between the front and backend. After the front end writes, it reads back the data to make sure it made it, if not repeat the write up to a number of retries
ivorygrant
@ivorygrant
Mar 31 2017 00:21
@sjames1958gm so you're saying it cant get the length of the next word before it actually tests it?
Stephen James
@sjames1958gm
Mar 31 2017 00:23
@ivorygrant With those i++ it is somewhat confusing as to what the value of i is. Certainly if the the first word was longest it wouldn't ever set holder.
@ivorygrant Oh, I just realized something i++ increments i after using it so
split[i].length < split[i++].length is always comparing the same word
Sara
@skd726
Mar 31 2017 00:26
for the "factorialize a number" challenge, do I use a for loop ?
Farid Hamid
@farid95
Mar 31 2017 00:26
img000049.jpg
ive been trying this one and it wont let me pass..roman numeral converter algorithm. i even got some help online and this code still doesnt let me pass, can someone give me a hand?
Stephen James
@sjames1958gm
Mar 31 2017 00:26
@skd726 That is one way
@farid95 Your while loop comparison is missing something
Dimitrios Philliou
@DimitriCat
Mar 31 2017 00:27
Hey folks!
Sara
@skd726
Mar 31 2017 00:27
@sjames1958gm can you tell me another way without giving anything away? (if you don't want to though i understand)
and thank you again @sjames1958gm
CamperBot
@camperbot
Mar 31 2017 00:27
skd726 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6446 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Mar 31 2017 00:27
@skd726 recursion
Dimitrios Philliou
@DimitriCat
Mar 31 2017 00:27
I'm hitting a block on some basic Js
Sara
@skd726
Mar 31 2017 00:27
gracias @sjames1958gm
CamperBot
@camperbot
Mar 31 2017 00:27
skd726 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: skd726 already gave sjames1958gm points
Stephen James
@sjames1958gm
Mar 31 2017 00:27
@skd726 de nada
Dimitrios Philliou
@DimitriCat
Mar 31 2017 00:28
Can someone help me out?
Stephen James
@sjames1958gm
Mar 31 2017 00:28
@DimitriCat Ask your question
Dimitrios Philliou
@DimitriCat
Mar 31 2017 00:28
Here is what it wants me to do:

Here is a function myTest with a local variable called loc.

function myTest() {
  var loc = "foo";
  console.log(loc);
}
myTest(); // "foo"
console.log(loc); // "undefined"

loc is not defined outside of the function.
Instructions

Declare a local variable myVar inside myLocalScope. Run the tests and then follow the instructions commented out in the editor.

I put the code in:

function myLocalScope() {
var myVar = "one";
console.log(myVar);
}

myLocalScope();

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

Farid Hamid
@farid95
Mar 31 2017 00:29
@sjames1958gm any idea what it could be? ive got to the point of literally following a tutorial lol. the tutorial shows that this code should pass it but on mine no luck, the while loop is the same as the help i got..
Dimitrios Philliou
@DimitriCat
Mar 31 2017 00:29
It's saying that myVar isn't defined though.
Stephen James
@sjames1958gm
Mar 31 2017 00:29
@DimitriCat You are supposed to delete the last line to get it to pass.
if it doesn't try refreshing browser
Dimitrios Philliou
@DimitriCat
Mar 31 2017 00:29
Got it!
Stephen James
@sjames1958gm
Mar 31 2017 00:29
@farid95 num > z[i] not num > [i]
Dimitrios Philliou
@DimitriCat
Mar 31 2017 00:29
Thanks Stephen.
Stephen James
@sjames1958gm
Mar 31 2017 00:29
@DimitriCat :+1:
Dimitrios Philliou
@DimitriCat
Mar 31 2017 00:30
Lol I'll just read all of the instructions next time!
Cheers
Stephen James
@sjames1958gm
Mar 31 2017 00:30
@DimitriCat lol
ivorygrant
@ivorygrant
Mar 31 2017 00:31
@sjames1958gm ok i think I follow what you mean. since I have to go through the whole array, there's no way to modify the conditions to directly compare the first word to the next word
Stephen James
@sjames1958gm
Mar 31 2017 00:32
@ivorygrant str[i].length < str[i + 1].length
Farid Hamid
@farid95
Mar 31 2017 00:32
@sjames1958gm i dont have a num>[i] in my code there..not sure exactly where to put that/ change in the while loop
ivorygrant
@ivorygrant
Mar 31 2017 00:33
@sjames1958gm how is that different then i++?
Stephen James
@sjames1958gm
Mar 31 2017 00:33
@farid95 while (num >= [i])
while (num >= z[i])
I am going on the image posted earlier
ivorygrant
@ivorygrant
Mar 31 2017 00:33
ohhh you mean set that as a condition @sjames1958gm
Stephen James
@sjames1958gm
Mar 31 2017 00:33
@ivorygrant i++ is called post increment - which means use the current value of i then increment
Farid Hamid
@farid95
Mar 31 2017 00:35
img000050.jpg
@sjames1958gm that returns me this
gives a roman numeral, however not passing
ivorygrant
@ivorygrant
Mar 31 2017 00:35
@sjames1958gm ok, i'll have to think about it. regardless i do understand the way I had it, it would never have checked the first word. thanks!
CamperBot
@camperbot
Mar 31 2017 00:35
ivorygrant sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: ivorygrant already gave sjames1958gm points
Stephen James
@sjames1958gm
Mar 31 2017 00:37
@farid95 See the function name in the tests - change your function to match convertToRoman
Andrew Shieh
@andrewlikes
Mar 31 2017 00:37
@yafiwebdev I tried doing the Seek & Destroy challenge without using filter:
function destroyer(arr) {

  var args = Array.from(arguments);
  var newArr = [];

 args = args.slice(1);

  for (var i = 0; i < arr.length; i++) {
    if (args.indexOf(arr[i]) == -1) {
      newArr.push(arr[i]);
    }
  }



  return newArr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Farid Hamid
@farid95
Mar 31 2017 00:38
@sjames1958gm oh wow, yeah that worked lol. thanks a lot, very silly mistake i got caught up in the code and didnt realise that id changed that haha..i always make variables x,y,z etc instead of actual names sometimes, guess this taught me that i shouldnt do that so much cos it makes me forget. Thanks!
CamperBot
@camperbot
Mar 31 2017 00:38
farid95 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6447 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Mar 31 2017 00:39
@camperbot yw :checkered_flag:
Tung776
@tung776
Mar 31 2017 00:39
Anyone know can I get certificate at beta.freecodecamp.com at this time.
crfc ffffff rccffc. rcc
Can i get certificate from beta.freecodecamp.com at this time?
Hello, anyone here?
Dick Tonye
@SimpletechSolution
Mar 31 2017 00:42
hello guys
Gulsvi
@gulsvi
Mar 31 2017 00:43
@tung776 Doesn't look like it - all progress on the beta will be lost when it's no longer in beta. https://forum.freecodecamp.com/t/beta-certificates/98947
Tung776
@tung776
Mar 31 2017 00:43
Ok
Thanks
Doni Yafi
@yafiwebdev
Mar 31 2017 00:45
@andrewlikes yeah I saw this arguments thing, but couldn't really get my head around it
Roxroy
@roxroy
Mar 31 2017 00:50
@tung776 , not yet, but when it comes out of beta it will replace the current site. You can still practice and learn using the beta site. Note that the score will not carry over.
john94
@lpy1994
Mar 31 2017 00:56
function addTogether(x) {
    function addMore(y) {
        return x + y;
    };
    for (var i = 0; i < arguments.length; i++) {
        if (typeof arguments[i] === 'number') {
            if (arguments.length === 2) {
                return arguments[0] + arguments[1];
            }
            return addMore;
        }
        return undefined;
    }
}
var sum = addTogether(2);
console.log(sum(1));
console.log(addTogether(1, 1));
guys what’s wrong with this
it won’t return undefined when one of the arguments isn’t a number
Abdullah Anis
@Abdullah996
Mar 31 2017 01:00
anyone
how to do it give a short intro plz
Joseph
@revisualize
Mar 31 2017 01:03
Hello.
Abdullah Anis
@Abdullah996
Mar 31 2017 01:03
Hey Joseph
Plz i cant get this Challenge any short intro for this challenge
john94
@lpy1994
Mar 31 2017 01:07
@Abdullah996 there are certain numbers represent certain romanian numerals
when given a number, you need to be able to convert it to romanina numerals.
mikemorancodes
@mikemorancodes
Mar 31 2017 01:09
Hey guys. I'm getting "FEEE PODR CAMC" when I run this code. It's converting some of the characters but leaving others and I can't figure out the reason.
function rot13(str) 
{


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

      if(val>=65&&val<=77)
          str = str.replace(String.fromCharCode(val),String.fromCharCode(val+13));

      else if(val>=77&&val<=90)
          str = str.replace(String.fromCharCode(val),String.fromCharCode(val-13));

    }


  return str;
}
Hernan Mendez
@hernanmendez
Mar 31 2017 01:15
hey everybody i'm smallest common multiple and i'm just about to finish but i need to get the commons out, anyways how do i make so i have the number of matches for a number?
Moisés Man
@moigithub
Mar 31 2017 01:17
@mikemorancodes probably u have "incorrect ranges"
@mikemorancodes also replace will replace the first match
means.. if ur previous replaced changed an A for B
and ur second replace will change B for C
ur final string wont have any B
Hernan Mendez
@hernanmendez
Mar 31 2017 01:21
i mean i could stringify the arrays and weird things like that but i feel like that would be kinda weird
Moisés Man
@moigithub
Mar 31 2017 01:22
@mikemorancodes instead of using replace... create a new empty string.. and use concatenation to build a new string
john94
@lpy1994
Mar 31 2017 01:27
@hernanmendez send code?
vs198907
@vs198907
Mar 31 2017 01:27

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

// Only change code below this line

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

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

why its not grabbing the value
I got it thanks
john94
@lpy1994
Mar 31 2017 01:29
@vs198907 glad I can help :laughing:
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:32
Hey
Is there a method to add something?
Not .push etc...
silver537
@silver537
Mar 31 2017 01:32
:D
john94
@lpy1994
Mar 31 2017 01:32
@mikemorancodes any char code < 90, just + 13 or 77 + charcode - 90.
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:32
@silver537 console.log?
you typed consolelog
mikemorancodes
@mikemorancodes
Mar 31 2017 01:33
@moigithub I'm creating a new string but I'm getting worse results
silver537
@silver537
Mar 31 2017 01:33
@MathematicsCoding you obviously didn't see the string. :P
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:33
Ok whatever
please help me!
Moisés Man
@moigithub
Mar 31 2017 01:34
@mikemorancodes repost ur code again.. with that new string
vigilante0525
@vigilante0525
Mar 31 2017 01:35
This is my code
var myStr ="I am a \"double quoted\" string inside\" double quotes\". "; // Change this line
john94
@lpy1994
Mar 31 2017 01:35
@changfuqiao didn’t follow the instruction
Hernan Mendez
@hernanmendez
Mar 31 2017 01:35

function smallestCommons(arr) {
var arrs=[];
arr.sort(function (a,b){return b-a;});
for (var i=arr[1]+1;i<arr[0];i++){
arr.push(i);
}
arr.sort(function (a,b){return b-a;});

while (1>0){
for(var u=0;u<arr.length;u++){
if(arr[u]!=1){
arrs.push([]);}
for (var o=2;o<=arr[u];o++){

  if(arr[u]%o===0){

    while(arr[u]%o===0){

    arrs[u].push(o);
    arr[u]=arr[u]/o;}
  }
}

}
return arrs;
}
}

smallestCommons([23,18]);

vigilante0525
@vigilante0525
Mar 31 2017 01:35
It wont cross this off Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
mikemorancodes
@mikemorancodes
Mar 31 2017 01:35
@moigithub
function rot13(str) 
{

  var newStr = "";

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

      if(val>=65&&val<=77)
        {
      //str = str.replace(String.fromCharCode(val),String.fromCharCode(val+13));
          newStr = newStr.concat(String.fromCharCode(val+13));
        }

      else if(val>=77&&val<=90)
        {
          newStr = newStr.concat(String.fromCharCode(val+13));
      //str = str.replace(String.fromCharCode(val),String.fromCharCode(val-13));
        }

      else
        newStr = newStr.concat(String.fromCharCode(val));

    }


  return newStr;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Hernan Mendez
@hernanmendez
Mar 31 2017 01:35

function smallestCommons(arr) {
var arrs=[];
arr.sort(function (a,b){return b-a;});
for (var i=arr[1]+1;i<arr[0];i++){
arr.push(i);
}
arr.sort(function (a,b){return b-a;});

while (1>0){
for(var u=0;u<arr.length;u++){
if(arr[u]!=1){
arrs.push([]);}
for (var o=2;o<=arr[u];o++){

  if(arr[u]%o===0){

    while(arr[u]%o===0){

    arrs[u].push(o);
    arr[u]=arr[u]/o;}
  }
}

}
return arrs;
}
}

smallestCommons([23,18]);

changfuqiao
@changfuqiao
Mar 31 2017 01:36
@lpy1994 thank you
CamperBot
@camperbot
Mar 31 2017 01:36
changfuqiao sends brownie points to @lpy1994 :sparkles: :thumbsup: :sparkles:
:cookie: 299 | @lpy1994 |http://www.freecodecamp.com/lpy1994
Jason Lafrance
@SgtRaziel
Mar 31 2017 01:38
I need to filter the the last 2 arguments arguments out of the array, not doing something right.
function destroyer(arr) {
  // Remove all the values

  function filterItems(arg){
    return arg != arguments[1] && arguments[2];
  }

  return arr.filter(filterItems);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Hernan Mendez
@hernanmendez
Mar 31 2017 01:39
the while loop is useless
on my code
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:40
@hernanmendez What challenge are you working on?
Moisés Man
@moigithub
Mar 31 2017 01:40
@mikemorancodes on both if u +13
one of em should be -13
also ur condition overlap on 77
one should be to 77, the other should start on 78
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:41
oh...
.push method is for array right?
If I want to use it on string I would have to split them right?
Hernan Mendez
@hernanmendez
Mar 31 2017 01:41
@MathematicsCoding smallest common multiple
Moisés Man
@moigithub
Mar 31 2017 01:41
@SgtRaziel every function have its own copy of argumetns object
soo calling arguments inside destroyer its NOT the same as calling it inside filterItems function
if u wanna use parent function arguments.. u need to make a copy first on another variable
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:42
@hernanmendez What do you mean by that?
Hernan Mendez
@hernanmendez
Mar 31 2017 01:42
@MathematicsCoding the challenge i'm on
mikemorancodes
@mikemorancodes
Mar 31 2017 01:43
@moigithub of course! Duh. Thanks man
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:43
Oh thought you were talking about my challenge...
CamperBot
@camperbot
Mar 31 2017 01:43
mikemorancodes sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2936 | @moigithub |http://www.freecodecamp.com/moigithub
Jason Lafrance
@SgtRaziel
Mar 31 2017 01:43
@moigithub I'm not clear on how to call the args in destroyer and pass them to the filterItems
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:43
@hernanmendez Basic JS?
vs198907
@vs198907
Mar 31 2017 01:44

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

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

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

why its not working
?
Hernan Mendez
@hernanmendez
Mar 31 2017 01:44
@MathematicsCoding intermediate algorithm scripting
Moisés Man
@moigithub
Mar 31 2017 01:44

to make a copy.. u can use

var args = [].slice.call(arguments);
var args = Array.from(arguments);
var args = [...arguments];

pick one, any of those will create a copy from arguments into an array
then u can pass the variable args inside filteritems funciton @SgtRaziel

Saboor Malik
@MathematicsCoding
Mar 31 2017 01:44
Oh sorry you are already ahead me @hernanmendez
Hernan Mendez
@hernanmendez
Mar 31 2017 01:45
@MathematicsCoding lol
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:45
@hernanmendez In that case... do you mind if you could help me with this challenge from Basic algorithm scripting?
Hernan Mendez
@hernanmendez
Mar 31 2017 01:46
@MathematicsCoding ok then
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:46
This challenge is called truncate a string
Jason Lafrance
@SgtRaziel
Mar 31 2017 01:46
any one better then the other? @moigithub
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:47
@hernanmendez ready?
Moisés Man
@moigithub
Mar 31 2017 01:47
@SgtRaziel last 2 using ES6 methods.. so u need to check if browser support it
most desktop modern browser supports.. so probably no problem
Hernan Mendez
@hernanmendez
Mar 31 2017 01:47
@MathematicsCoding yeah
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:47
Ok here's my code

function truncateString(str, num) {
  // Clear out that junk in your trunk
  return str.slice(0, num);

}
truncateString("A-tisket a-tasket A green and yellow basket", 11);
vs198907
@vs198907
Mar 31 2017 01:48
can anyone help me please?
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:48
It return A-tisket a- but I do not know how to return A-tisket... instead
Jason Lafrance
@SgtRaziel
Mar 31 2017 01:48
never seen the (...arguments) notation. thanks @moigithub
CamperBot
@camperbot
Mar 31 2017 01:48
sgtraziel sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2937 | @moigithub |http://www.freecodecamp.com/moigithub
vs198907
@vs198907
Mar 31 2017 01:48

var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty(myObj[checkProp]) == checkProp){
return myObj[checkProp];
}
else{
return "Not Found";
}
}

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

Saboor Malik
@MathematicsCoding
Mar 31 2017 01:48
I feel like I already know but im not doing anything...
Matthew
@IMDBLM
Mar 31 2017 01:49
I'm having difficulty understanding what the 0 is doing in var singleVal = array.reduce(function(previousVal, currentVal) { return previousVal - currentVal; }, 0);
Hernan Mendez
@hernanmendez
Mar 31 2017 01:49
@MathematicsCoding learn the description again, and try to make some if statements, if you simply don't know or get stuck, tell me
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:50
Okay
john94
@lpy1994
Mar 31 2017 01:52
@IMDBLM 0 is the second argument of the function
Any one?
john94
@lpy1994
Mar 31 2017 01:54
@IMDBLM it is the inital value.
Matthew
@IMDBLM
Mar 31 2017 01:54
@lpy1994 So the (previousVal, currentVal) is one parameter?
oscar carrillo
@oscarrillo90
Mar 31 2017 01:54
function testGreaterThan(val) {
  if (val) {  // Change this line
    return "Over 100";
  }

  if (val) {  // Change this line
    return "Over 10";
  }

  return "10 or Under";
}

// Change this value to test
testGreaterThan(10);
not sure where to go with this problem, help please
danielpawel
@danielpawel
Mar 31 2017 01:54
I just got it! Thanks!
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:54
@hernanmendez Well i think that is all I can do
john94
@lpy1994
Mar 31 2017 01:54
@IMDBLM MDN should have example
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:55

function truncateString(str, num) {
  // Clear out that junk in your trunk
  if (num.length <= 3) {
    return "str";
  }
  return str.slice(0, num);

}
truncateString("Absolutely Longer", 2);
Chaz
@Chrljnsn
Mar 31 2017 01:55
hey guys, i have a variable in java that i need to appear in my html but what is the code to do it?ive tried googling to figure it out but cant seem to find what i need
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:56
@Chrljnsn Java is not same as JavaScript
Chaz
@Chrljnsn
Mar 31 2017 01:56
it is JS sorry
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:56
So maybe you googled Java instead?
Hernan Mendez
@hernanmendez
Mar 31 2017 01:56
@MathematicsCoding first of all, by saying return "str" instead of str will return "str" instead of the string
Chaz
@Chrljnsn
Mar 31 2017 01:56
im on codepen.io projects
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:57
@hernanmendez empty string?
Chaz
@Chrljnsn
Mar 31 2017 01:57
ah,maybe. ok ill try again. i dont remember ever doing it never mind how :(
john94
@lpy1994
Mar 31 2017 01:57
@IMDBLM initialValue
[Optional] Value to use as the first argument to the first call of the callback. If no initial value is supplied, the first element in the array will be used. Calling reduce on an empty array without an initial value is an error.
its from MDN
Hernan Mendez
@hernanmendez
Mar 31 2017 01:57
@MathematicsCoding and you don't need the num.length because the num is not a string or array, is just a number
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:57
course...
just num?
Hernan Mendez
@hernanmendez
Mar 31 2017 01:58
@MathematicsCoding yeah
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:58
Ok what am I supposed to return?
Hernan Mendez
@hernanmendez
Mar 31 2017 01:58
@MathematicsCoding return str;
Chaz
@Chrljnsn
Mar 31 2017 01:58
ah @MathematicsCoding much better results! ty
CamperBot
@camperbot
Mar 31 2017 01:58
chrljnsn sends brownie points to @mathematicscoding :sparkles: :thumbsup: :sparkles:
:cookie: 277 | @mathematicscoding |http://www.freecodecamp.com/mathematicscoding
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:58
@Chrljnsn No problem
Ah that makes sense

function truncateString(str, num) {
  // Clear out that junk in your trunk
  if (num <= 3) {
    return str;
  }
  return str.slice(0, num);

}
truncateString("Absolutely Longer", 2);
Hernan Mendez
@hernanmendez
Mar 31 2017 01:59
@MathematicsCoding nice
Saboor Malik
@MathematicsCoding
Mar 31 2017 01:59
But I dont know how to return with ...
a method with (-3) to put ... maybe?
Hernan Mendez
@hernanmendez
Mar 31 2017 02:00
@MathematicsCoding add +"..." to the return, that will add the ...
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:00
That it....
Hernan Mendez
@hernanmendez
Mar 31 2017 02:01
@MathematicsCoding that's called concatenating when you sum a string and another string
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:02
Yeah I know about concatenating...
I didnt know you could do something like that to return
...
@hernanmendez Add +"..." to second return?
Hernan Mendez
@hernanmendez
Mar 31 2017 02:02
@MathematicsCoding yeah
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:03
What about this way?

function truncateString(str, num) {
  // Clear out that junk in your trunk
  if (num <= 3) {
    return str;
  }
  var a = str+"...";
  return a.slice(0, num);

}
truncateString("Absolutely Longer", 2);
oscar carrillo
@oscarrillo90
Mar 31 2017 02:03
function testGreaterThan(val) {
  if (val) {  // Change this line
    return "Over 100";
  }

  if (val) {  // Change this line
    return "Over 10";
  }

  return "10 or Under";
}

// Change this value to test
testGreaterThan(10);
How do i add the greater than operator to the indicated lines so that the return statements make sense.
Hernan Mendez
@hernanmendez
Mar 31 2017 02:03
@MathematicsCoding yeah, but you don't need to create another variable
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:04
How do I do that in that return?
I have no idea..
Sara
@skd726
Mar 31 2017 02:04
hello! can anyone help? I am trying to delete all the spaces in my string using .replace(" ", "") and .replace("\s+", "") and it hasn't worked. any ideas?
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:04
Oh you mean this?
Hernan Mendez
@hernanmendez
Mar 31 2017 02:04
@MathematicsCoding just add +"..." = return str.slice(0,num)+"...";
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:04
str = str+"...";
  return str.slice(0, num);
I tried that didnt works
Joseph
@revisualize
Mar 31 2017 02:05
Hello.
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:05
@revisualize :wave:
john94
@lpy1994
Mar 31 2017 02:05
@skd726 replace(/\s/g, whatever)
Hernan Mendez
@hernanmendez
Mar 31 2017 02:06
@MathematicsCoding keep in mind that return won' t work
Sara
@skd726
Mar 31 2017 02:06
thanks @lpy1994
CamperBot
@camperbot
Mar 31 2017 02:06
skd726 sends brownie points to @lpy1994 :sparkles: :thumbsup: :sparkles:
:cookie: 300 | @lpy1994 |http://www.freecodecamp.com/lpy1994
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:06
Yeah because of that if statement... @hernanmendez
john94
@lpy1994
Mar 31 2017 02:07
@oscarrillo90 add it in if statement
Hernan Mendez
@hernanmendez
Mar 31 2017 02:07
@MathematicsCoding but using the return i just told you will work on the if statement
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:07
Oh I understand... that +"..." thing
Edward Cronin
@eddiec005
Mar 31 2017 02:08
hello everyone
josephcaetta
@josephcaetta
Mar 31 2017 02:08
var myStr= "I am a "\double quoted\" string inside "\double quotes\"."; // Change this line
Hernan Mendez
@hernanmendez
Mar 31 2017 02:08
@MathematicsCoding remenber this if nun is greater than 3 "Note that inserting the three dots to the end will add to the string length."
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:09
@hernanmendez I see
I changed my code a little
Hernan Mendez
@hernanmendez
Mar 31 2017 02:10
@MathematicsCoding let me see
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:10

function truncateString(str, num) {

  if (num >= 3) {
    return str;
  } 

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

}
truncateString("Absolutely Longer", 2);
Just < to >
Hernan Mendez
@hernanmendez
Mar 31 2017 02:10
@MathematicsCoding swap the return's
Sara
@skd726
Mar 31 2017 02:10
is there a way an escape sequence to find all special characters? like / % #
or do I have to do them all individually?
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:11
@hernanmendez I guess that work same thing...
I had to change > to <
Hernan Mendez
@hernanmendez
Mar 31 2017 02:12
@MathematicsCoding the if is ok,
Micah Cobb
@cobbmic
Mar 31 2017 02:12
How do I see the "terminal" log for all the test cases in a problem (instead of just the first one)
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:13

function truncateString(str, num) {

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

 return str;

}
truncateString("A-tisket a-tasket A green and yellow basket", 11);
Hernan Mendez
@hernanmendez
Mar 31 2017 02:13
@MathematicsCoding yeah now try it
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:14
It works.. but I couldnt return with num 11-14
I mean like first and second wont turn green?
john94
@lpy1994
Mar 31 2017 02:14
@MathematicsCoding (0, num - 3)
  • ...
Hernan Mendez
@hernanmendez
Mar 31 2017 02:15
@MathematicsCoding quick hint to finish your code, what will this do, var ok=98; ok-="...".length
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:15
var ok=98; 
ok-="...".length
That one?
john94
@lpy1994
Mar 31 2017 02:15
@cobbmic console.log all the test case...
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:18
*
Joseph
@revisualize
Mar 31 2017 02:18
@MathematicsCoding Do you know how useful that script you're writing currently is?
john94
@lpy1994
Mar 31 2017 02:19
@hernanmendez still working on scm challenge?
Hernan Mendez
@hernanmendez
Mar 31 2017 02:20
@lpy1994 yeah, guess i can finish it tomorrow
@lpy1994 it's late over here
john94
@lpy1994
Mar 31 2017 02:20
@hernanmendez ok, just let you know, I do it with a formula from math.
@hernanmendez times all numbers in array and divided by gretest common divisor .
*greatest
Micah Cobb
@cobbmic
Mar 31 2017 02:24
I'm working on "Seek and Destroy" -- what's wrong with this code? It doesn't work on 2 of the 5 cases...

function destroyer(arr) {
var my_arr = Array.from(arguments);
var array_length = my_arr[0].length;
var args_length = my_arr.length;

for (var i = 0; i < array_length; i++) {
for (var j = 1; j < args_length; j++) {
if (my_arr[0][i] === my_arr[j]) {
my_arr[0].splice(i,1);
}
}
}

return my_arr[0];
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

john94
@lpy1994
Mar 31 2017 02:26
@cobbmic you return my_arr[0] which is the first element of the array
Hernan Mendez
@hernanmendez
Mar 31 2017 02:27
@lpy1994 ok
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:29
@hernanmendez I think Im going to try to use other if statement
else if statement
john94
@lpy1994
Mar 31 2017 02:29
@MathematicsCoding :bulb:
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:29
Yeah
cwheatley15
@cwheatley15
Mar 31 2017 02:29
Hey guys, currently working on Stand in Line under beginner JavaScript. I don't really understand what they are asking me to do...
john94
@lpy1994
Mar 31 2017 02:30
@hernanmendez good luck :+1:
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:31
I feel like my brain stopped working..
Danny Welstad
@GoonTwo
Mar 31 2017 02:31
bonfire challneg "Ceasers Cipher" Getting a weird return... couple letters are off. Also willing to take suggestions on how to clean up the code or do it more succinctly.
unction rot13(str) { // LBH QVQ VG!
  var newArray = [];
  var temp = 0;

  str.split("").forEach(function(val){
    if (val.charCodeAt() !== 32) {
       temp = val.charCodeAt()-13;
      newArray.push(temp);
    }
    else {
      newArray.push(32);
    }
  });

 newArray = newArray.map(function(val){
return String.fromCharCode(val);
  }).join('');
  return newArray;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC"); // outputs [F8EE C5DE CAM6] supposed to be FREE CODE CAMP
MR-Em
@MR-Em
Mar 31 2017 02:33
im finding the algorithm challenges difficult
when i look for the solution and read how it is done i understand. the problem is i wouldn't have got it right
is this normal?
Raihan Habib
@mrh07
Mar 31 2017 02:35
is there anybody ti help ?
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:36
Omfg I still cant figure it out
Here is my code

function truncateString(str, num) {

  if (num<3) {
     return str.slice(0, num)+"...";
  } else if (str.length>num){
    return str.slice(0, num)+"...";
  }
  return str;
}
truncateString("A-tisket a-tasket A green and yellow basket", 11);
I tried to use .pop method but...
john94
@lpy1994
Mar 31 2017 02:37
@MathematicsCoding when you add , the length is increasing as
well
Danny Welstad
@GoonTwo
Mar 31 2017 02:37
@mrh07 us an if statement to determine if a or b are less than zero and if they are use return to stop the function
john94
@lpy1994
Mar 31 2017 02:37
@MathematicsCoding you are almost there
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:37
Yeah I guess...
unction truncateString(str, num) {

  if (num<3) {
     return str.slice(0, num)+"...";
  } else if (str.length>num){
    return str.slice(0, num).split('').pop().join('')+"...";
  }
  return str;
}
Fail
john94
@lpy1994
Mar 31 2017 02:38
num - 3
Raihan Habib
@mrh07
Mar 31 2017 02:38
@GoonTwo would i plz tell me another way ?
Danny Welstad
@GoonTwo
Mar 31 2017 02:39
@mrh07
if(a < 0 || b < 0) {
return;
}
Raihan Habib
@mrh07
Mar 31 2017 02:39
ok got it
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:39
@lpy1994 Omg.... I was trying to figure out how to remove some last string...
Danny Welstad
@GoonTwo
Mar 31 2017 02:39
@mrh07 return ends the function so if the if statement is true it will hit the return and stop
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:39
Thanks... It was just that all along..
john94
@lpy1994
Mar 31 2017 02:39
@MathematicsCoding got it ?
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:39
Yeah
john94
@lpy1994
Mar 31 2017 02:40
:+1:
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:40
Delete(subtract) 3 then add ...
... So simple...
john94
@lpy1994
Mar 31 2017 02:40
MathematicsCoding bro :laughing:
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:40
xD
Im good at math but with programming combined?
Its complimented..
But some formula from math make sense
num - 3 of couse....
course*
john94
@lpy1994
Mar 31 2017 02:42
@MathematicsCoding math helps tremendously
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:45
they does
john94
@lpy1994
Mar 31 2017 02:47
@MathematicsCoding alright, if need help, send code, we help.
if we can
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:47
Course
I dont know how to split an array into two..
I mean I do but I cant use split method
Error is saying that is not a function..
PhamLinh0889
@PhamLinh0889
Mar 31 2017 02:50
hi all
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:50
Oh Im stupid
.split is for string only to make them into an array...
...
john94
@lpy1994
Mar 31 2017 02:51
@MathematicsCoding take it easy
PhamLinh0889
@PhamLinh0889
Mar 31 2017 02:51
i have misunderstand this challenge
John Dahl
@interactivejohn
Mar 31 2017 02:51
If your solution is way longer than another you found online, do you leave your solution or change it accordingly and learn from it? I don't want to give the impression that I'm cheating.
Jason Luboff
@JLuboff
Mar 31 2017 02:52
@interactivejohn Leave it and then after going through all the challenges...go back and try them again and see if you can come up with shorter solutions
John Dahl
@interactivejohn
Mar 31 2017 02:52
My solution is longer but it works.
john94
@lpy1994
Mar 31 2017 02:52
@JLuboff boss I need help
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:52
@interactivejohn You shouldnt use any solution from online... You can learn from it but meaning you cant figure it yourself
Dont do it like I did... But I managed to start over...
john94
@lpy1994
Mar 31 2017 02:52
function addTogether(x) {
    function add(y) {
        return x + y;
    };
    for (var i = 0; i < arguments.length; i++) {
        if (typeof arguments[i] === 'number') {
            if (arguments.length === 2) {
                return arguments[0] + arguments[1];
            }
            return add;
        }
        return undefined;
    }
}
var sum = addTogether(2);
console.log(sum(1));
console.log(addTogether(2,[2]));
Jason Luboff
@JLuboff
Mar 31 2017 02:53
@lpy1994 Ugh...I hate that challenge :joy:
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:53
lol
john94
@lpy1994
Mar 31 2017 02:53
@JLuboff dont know how to use typeof properly..
John Dahl
@interactivejohn
Mar 31 2017 02:53
@JLuboff Okay thanks! Will do. Yeah, after I solve them I like to search for how other people solved it. Someone solved the solution I was working on in 1 line, where mine took 9.
CamperBot
@camperbot
Mar 31 2017 02:53
interactivejohn sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1349 | @jluboff |http://www.freecodecamp.com/jluboff
john94
@lpy1994
Mar 31 2017 02:54
@JLuboff I assume that Im almost there ?
Jason Luboff
@JLuboff
Mar 31 2017 02:54
@lpy1994 Well it looks like you're using it correctly. You're saying if the type of arguments[i] is a number, then yadda yadda
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:54

function chunkArrayInGroups(arr, size) {
  // Break it up.;
  return arr.slice(size);
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
It only return [c,d] this time but I think Im close Im sure I can do it using .push method
John Dahl
@interactivejohn
Mar 31 2017 02:54
@MathematicsCoding I always figure them out myself first, but as I said, I like to search and see how others solved it to see what I can improve on.
Jason Luboff
@JLuboff
Mar 31 2017 02:55
@interactivejohn Yup. As you continue you'll realize "Hey! I could have done this instead! Oh look at that, I can make it three lines shorter!"
@MathematicsCoding You need a loop
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:55
Loop...
Ugh..
for loop right
?
john94
@lpy1994
Mar 31 2017 02:56
@MathematicsCoding while loop works too
Jason Luboff
@JLuboff
Mar 31 2017 02:56
@MathematicsCoding Yes...you can use a while loop as well..but i think a for loop is easier
john94
@lpy1994
Mar 31 2017 02:57
while loop took me 3 lines :smile:
John Dahl
@interactivejohn
Mar 31 2017 02:57
@JLuboff I won't change them then if it doesn't matter in the long run, as long as I learn as I progress. Thanks for the advice!
CamperBot
@camperbot
Mar 31 2017 02:57
interactivejohn sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:warning: interactivejohn already gave jluboff points
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:57
@lpy1994 I forgot how while loop work... could you explain? or I can just review them..
John Dahl
@interactivejohn
Mar 31 2017 02:57
What is this brownie points stuff?
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:58
Never mind I remember..
i less than 5 then i++
That would be 1-3
1-4**
Jason Luboff
@JLuboff
Mar 31 2017 02:58
@interactivejohn They just show appreciation/how helpful people are. No real value otherwise lol
John Dahl
@interactivejohn
Mar 31 2017 02:59
@JLuboff How does it know how helpful people are? LOL.
Jason Luboff
@JLuboff
Mar 31 2017 02:59
@interactivejohn well whenever someone says thanks when tagging someone, it gives them brownie points (like you will get right now)
CamperBot
@camperbot
Mar 31 2017 02:59
jluboff sends brownie points to @interactivejohn :sparkles: :thumbsup: :sparkles:
:cookie: 245 | @interactivejohn |http://www.freecodecamp.com/interactivejohn
Saboor Malik
@MathematicsCoding
Mar 31 2017 02:59
You say thanks to someone and they get a point
No big deal..
john94
@lpy1994
Mar 31 2017 03:00
@interactivejohn @JLuboff want to say that he is very help here which is true :smile:
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:00
You also get a point after completing a lesson
Matthew
@IMDBLM
Mar 31 2017 03:00
@revisualize you around?
John Dahl
@interactivejohn
Mar 31 2017 03:00
Good to know! Appreciate the advice.
Danny Welstad
@GoonTwo
Mar 31 2017 03:02
bonfire challene "Caesars Cipher" goal is to shift letters 13 spots to decipher a string. My way works, but there has to be a cleaner way to do it.
function rot13(str) { // LBH QVQ VG!
  var newArray = [];
  var temp = 0;

  str.split("").forEach(function(val){
    if (val.charCodeAt() >= 65 && val.charCodeAt() <= 77) {
       temp = val.charCodeAt()+13;
      newArray.push(temp);
    }
     else if (val.charCodeAt() > 77 && val.charCodeAt() <= 90) {
       temp = val.charCodeAt()-13;
      newArray.push(temp);
    }
    else {
      newArray.push(val.charCodeAt());
    }
  });

 newArray = newArray.map(function(val){
return String.fromCharCode(val);
  }).join('');
  return newArray;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:02
Ok I set up a while loop
@lpy1994 You used while loop to pass this challenge?
john94
@lpy1994
Mar 31 2017 03:04
I used splice as well
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:04
slice?
john94
@lpy1994
Mar 31 2017 03:04
splice
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:04
...
Jason Luboff
@JLuboff
Mar 31 2017 03:04
You'll have a bad time using slice with a while loop
but a great time using slice with a for loop :D
Chris Cullen
@123xylem
Mar 31 2017 03:05

Hi, Could you explain to me as if I were a 10 year old what this means.. I just want a VERY basic understanding and from there I can make it specific on my own with research, but at the moment its gobbledegook to me.
I added my comments to show my basic understanding of it so far so feel free to say where im wrong!

app.use(require("express-session")({                        //Use express Session(which uses express with passport)
    secret: "Once again Rusty wins cutest dog!",
    resave: false,
    saveUninitialized: false
}));
app.use(passport.initialize());                                         //method for getting PP to start and look at session data
app.use(passport.session());                                           //something for storing session data
passport.use(new LocalStrategy(User.authenticate())); // gives PP a local strategy (default: name-pword)
passport.serializeUser(User.serializeUser());             //Dloads user info to req.user file ?
passport.deserializeUser(User.deserializeUser());   //uploads that when requested by Passport (PP)

Imagine ur talking to a 10 year old about what these methods/functions do.
THanks! :)

Saboor Malik
@MathematicsCoding
Mar 31 2017 03:05
@JLuboff well he said splice
john94
@lpy1994
Mar 31 2017 03:05
@MathematicsCoding ok, while loop goes with splice, for loop goes with slice
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:06
oh
So basically they are same thing?
Jason Luboff
@JLuboff
Mar 31 2017 03:06
No they are two different methods
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:06
Hm
Jason Luboff
@JLuboff
Mar 31 2017 03:06
slice does not mutate the array, splice mutates the array
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:06
var myFish = ['angel', 'clown', 'drum', 'mandarin', 'sturgeon'];
var removed = myFish.splice(3, 1);

// removed is ["mandarin"]
// myFish is ["angel", "clown", "drum", "sturgeon"]
I see
Joseph
@revisualize
Mar 31 2017 03:07
@IMDBLM I am.
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:08
@JLuboff you know what... I will try with for loop first
john94
@lpy1994
Mar 31 2017 03:12
@JLuboff is the argument.length matter in this case??
@JLuboff I think I mess up with the logic
Jason Luboff
@JLuboff
Mar 31 2017 03:14
@lpy1994 Unfortunately...this is a challenge that I can't help with. I'm not good with closures and/or recursion....I went and tried that challenge again recently and still couldn't get it without looking at my previous answer :(
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:14
@JLuboff what does for loop has to do with this challenge?
Jason Luboff
@JLuboff
Mar 31 2017 03:15
@MathematicsCoding You need to loop through and slice the array at every size
CharlieAguilera090
@CharlieAguilera090
Mar 31 2017 03:15
a should be assigned to b with = var a = 7;
var a = var b;
john94
@lpy1994
Mar 31 2017 03:15
@JLuboff no way.
Joseph
@revisualize
Mar 31 2017 03:16
@CharlieAguilera090 How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:16
@revisualize Jeez
john94
@lpy1994
Mar 31 2017 03:16
@MathematicsCoding Ikr
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:16
He wrote everything about each challenge...
And save it..
@revisualize Well Do you have one for this challenge?
Chunky Monkey
Joseph
@revisualize
Mar 31 2017 03:17
Nope.
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:17
Okay..
john94
@lpy1994
Mar 31 2017 03:17
@revisualize need help here..
function addTogether(x) {
    function add(y) {
        return x + y;
    };
    for (var i = 0; i < arguments.length; i++) {
        if (typeof arguments[i] === 'number') {
            if (arguments.length === 2) {
                return arguments[0] + arguments[1];
            }
            return add;
        }
        return undefined;
    }
}
var sum = addTogether(2);
console.log(sum(1));
console.log(addTogether(2,3));
Joseph
@revisualize
Mar 31 2017 03:24
@lpy1994 I didn't use a for loop for that lesson. Hmm.
CharlieAguilera090
@CharlieAguilera090
Mar 31 2017 03:24
i have no idea
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:24
@revisualize Did you use any loop for this challenge?
Chunky Monkey
john94
@lpy1994
Mar 31 2017 03:24
@revisualize working on it.
Joseph
@revisualize
Mar 31 2017 03:25
@MathematicsCoding You have to.
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:25
Sigh
Joseph
@revisualize
Mar 31 2017 03:25
@lpy1994 Sometimes it is good to visualize your code execution.
john94
@lpy1994
Mar 31 2017 03:25
@revisualize I have this website, but always forgot.
I am so hungry, but I can’t eat without passing this bs.
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:26
Wow 4.5k out of 900k+ earned front end certification...
Joseph
@revisualize
Mar 31 2017 03:27
@lpy1994 Sometimes you need to just walk away.
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:27
@lpy1994 Lol same here
Ray Martinez
@rayjrm
Mar 31 2017 03:27
Hey
john94
@lpy1994
Mar 31 2017 03:27
@revisualize I have that code for two days.
Joseph
@revisualize
Mar 31 2017 03:27
@lpy1994 I've walked away from several challenges and come back to it and realized how dumb my solution was.
Ali Ahmad
@aliahmad-code
Mar 31 2017 03:28
@MathematicsCoding Really? only 4.5k? Where did you find that out?
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:28
About
john94
@lpy1994
Mar 31 2017 03:28
@revisualize I think I almost got it, that’s why
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:28
Map/Chat/ etc....
About is there
Jason Luboff
@JLuboff
Mar 31 2017 03:29
Less than .5% of those who have joined FCC have gotten their front-end cert
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:29
Dang
Joseph
@revisualize
Mar 31 2017 03:30
I don't have the Front End Cert
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:30
@revisualize really?
But you got over 6k points?
Jason Luboff
@JLuboff
Mar 31 2017 03:30
He wishes he had 6000
stvsprc
@stvsprc
Mar 31 2017 03:30
Anyone have any suggestions (not answers) for 'Testing Objects for Properties'? I've tried an if statement
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:30
about @revisualize
CamperBot
@camperbot
Mar 31 2017 03:30
:star2: 3633 | @revisualize |http://www.freecodecamp.com/revisualize
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:31
Oops 3k
Sjames has 6k points...
Chaz
@Chrljnsn
Mar 31 2017 03:31
hi huys, anyone know where i can get help with the random quote generator? ive tried several ways and i cant get it to work. just need something to make me realise what im missing
Chaz
@Chrljnsn
Mar 31 2017 03:32
@stvsprc keep going with if else
@stvsprc the test should be true or false
Saboor Malik
@MathematicsCoding
Mar 31 2017 03:34
I guess I will just do this challenge tomorrow...
Cya guys
Night
Chaz
@Chrljnsn
Mar 31 2017 03:34
ill have a look thanks @revisualize
CamperBot
@camperbot
Mar 31 2017 03:34
chrljnsn sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3634 | @revisualize |http://www.freecodecamp.com/revisualize
john94
@lpy1994
Mar 31 2017 03:36
@JLuboff @revisualize :bulb: :bulb: :bulb:
function addTogether(x) {
    if (arguments.length == 1 && typeof arguments[0] === 'number') {
        var x = arguments[0];
        return function (y) {
            if (typeof y === 'number') {
                return x + y;
            }
        };
    } 
       else if (typeof arguments[0] === 'number' && typeof arguments[1] === 'number') {
            return arguments[0] + arguments[1];
        }
    }
console.log(addTogether(2, 3));
please tell there is a better way.
please tell me
Joseph
@revisualize
Mar 31 2017 03:36
@lpy1994 Does that solve it?
john94
@lpy1994
Mar 31 2017 03:37
@revisualize does it
it does
Jason Luboff
@JLuboff
Mar 31 2017 03:37
Then I'll take it!
Joseph
@revisualize
Mar 31 2017 03:37
@lpy1994 This is how I solved it. My first code was at the bottom. Refactors upward.
https://raw.githubusercontent.com/revisualize/FreeCodeCamp_Lessons/master/Arguments_Optional.js
john94
@lpy1994
Mar 31 2017 03:38
:worried: so long ...
Joseph
@revisualize
Mar 31 2017 03:38
@lpy1994 Not long. I comment out the revisions
john94
@lpy1994
Mar 31 2017 03:38
function addTogether() {
    if (arguments.length === 2 &&
        typeof arguments[0] === "number" &&
            !Number.isNaN(arguments[0]) &&
                typeof arguments[1] === "number" &&
                    !Number.isNaN(arguments[1])) {
                        return arguments[0] + arguments[1];
      }
    if (arguments.length === 1 &&
        typeof arguments[0] === "number" &&
            !Number.isNaN(arguments[0])) {
                var arg0 = arguments[0];
                return function() {
                    if (typeof arguments[0] === "number" &&
                        !Number.isNaN(arguments[0])) {
                            return arg0 + arguments[0];
                    }
                 };
    }
this part?
Joseph
@revisualize
Mar 31 2017 03:38
@lpy1994 Missing a }
But, sure.
That's my final revision.
tinla94
@tinla94
Mar 31 2017 03:39
hello
john94
@lpy1994
Mar 31 2017 03:39
function addTogether() {
    if (arguments.length == 1 && typeof arguments[0] === 'number') {
        var x = arguments[0];
        return function (y) {
            if (typeof y === 'number') {
                return x + y;
            }
        };
    } 
       else if (typeof arguments[0] === 'number' && typeof arguments[1] === 'number') {
            return arguments[0] + arguments[1];
        }
    }
console.log(addTogether(2, 3));
tinla94
@tinla94
Mar 31 2017 03:40
i wanna ask whethere there is a way to prove true/false for a , b without using if/else
Ray Martinez
@rayjrm
Mar 31 2017 03:40
Conditional Operatators
Joseph
@revisualize
Mar 31 2017 03:40
@tinla94 Depends.
Ray Martinez
@rayjrm
Mar 31 2017 03:40
they return booleans
Joseph
@revisualize
Mar 31 2017 03:40
@tinla94 Conditional Statements will return a Boolean value.
john94
@lpy1994
Mar 31 2017 03:41
@revisualize @JLuboff thank you guys.
CamperBot
@camperbot
Mar 31 2017 03:41
lpy1994 sends brownie points to @revisualize and @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1350 | @jluboff |http://www.freecodecamp.com/jluboff
:star2: 3635 | @revisualize |http://www.freecodecamp.com/revisualize
tinla94
@tinla94
Mar 31 2017 03:41
My instruction says i can use === for true/false
i try that but only false return back to me
Joseph
@revisualize
Mar 31 2017 03:41
@tinla94 Like I said, Depends.
What EXACTLY are you trying to do?
David Amanze
@GodKingShogun
Mar 31 2017 03:41
so i have this as an array but an error message is popping up because of the decimals in some of the numbers. does this matter
  var moneyConvert= [100,20,10,5,1,.25,.10,.05,.01];
tinla94
@tinla94
Mar 31 2017 03:42

function isLess(a, b) {
// Fix this code
if (a < b) {
return true;
} else {
return false;
}
}

// Change these values to test
isLess(10, 15);

Joseph
@revisualize
Mar 31 2017 03:42
@tinla94 Okay.
tinla94
@tinla94
Mar 31 2017 03:42
ok so im trying to switch if/else for something else
but also giving me the same result
Joseph
@revisualize
Mar 31 2017 03:42
@tinla94 This (a < b) evaluates to a boolean value.
Ray Martinez
@rayjrm
Mar 31 2017 03:43
^
Joseph
@revisualize
Mar 31 2017 03:43
@tinla94 If you're doing that function and you're trying to use === you're using the INCORRECT comparison.
Ray Martinez
@rayjrm
Mar 31 2017 03:43
No if statement neccessary
Joseph
@revisualize
Mar 31 2017 03:43
@tinla94 Your function name is isLess .. Not isEqual
@tinla94 === compares equality.
@GodKingShogun
  var moneyConvert= [100,20,10,5,1,.25,.10,.05,.01];
undefined
console.log(moneyConvert);
VM294:1 [100, 20, 10, 5, 1, 0.25, 0.1, 0.05, 0.01]
tinla94
@tinla94
Mar 31 2017 03:45
ok lets me try
got it
thnks so much
Joseph
@revisualize
Mar 31 2017 03:45
@camperbot Thanks
CamperBot
@camperbot
Mar 31 2017 03:45
revisualize sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 3138 | @camperbot |http://www.freecodecamp.com/camperbot
tinla94
@tinla94
Mar 31 2017 03:45
@revisualize thnks joseph
David Amanze
@GodKingShogun
Mar 31 2017 03:45
@revisualize okay thanks
CamperBot
@camperbot
Mar 31 2017 03:45
godkingshogun sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3636 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 31 2017 03:46
Two 36's!
revisualize @revisualize goes afk. Need to lay down on my bathroom floor.
Joseph
@revisualize
Mar 31 2017 03:49
Damn. My back is a giant Rice Crispy Treat. ... It goes snap crackle and pop too much.
Jason Luboff
@JLuboff
Mar 31 2017 03:50
@revisualize You're getting old
Joseph
@revisualize
Mar 31 2017 03:50
:(
Jason Luboff
@JLuboff
Mar 31 2017 03:52
:D
iso
@iso1048
Mar 31 2017 03:56
I have an array storing words. How can I make it so that each of these words is stored within its own subarray?
Jordan
@PronetoPonder
Mar 31 2017 03:56
Not sure what I'm doing wrong here. Can I get a nudge in the right direction?
// 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 = lookup.val;

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

// Change this value to test
phoneticLookup("charlie");
CamperBot
@camperbot
Mar 31 2017 03:56
:bulb: to format code use backticks! ``` more info
Jordan
@PronetoPonder
Mar 31 2017 03:57
"Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable."
Joseph
@revisualize
Mar 31 2017 03:58
@spaceless8 Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
Ray Martinez
@rayjrm
Mar 31 2017 03:58
@spaceless8 I think you will need to use Bracket Notation as Dot Notation will not access values.
Dang you're so quick @revisualize
Joseph
@revisualize
Mar 31 2017 03:59
@rayjrm I copy and paste
Jordan
@PronetoPonder
Mar 31 2017 03:59
@revisualize Many thanks friend.
CamperBot
@camperbot
Mar 31 2017 03:59
spaceless8 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3637 | @revisualize |http://www.freecodecamp.com/revisualize
CharlieAguilera090
@CharlieAguilera090
Mar 31 2017 04:03
can someone help? increment a number with javaacript
Roxroy
@roxroy
Mar 31 2017 04:05
@CharlieAguilera090 , sure. whats your question.
Ray Martinez
@rayjrm
Mar 31 2017 04:05
@CharlieAguilera090 Sure, You will need to assign to a variable its current value plus whatever number.
Joseph
@revisualize
Mar 31 2017 04:06
var num = 5;
num = num + 1; // 6
num += 1; // 7
num++; // 8

See how the one for getting num from 7 to 8 doesn't use the assignment operator (=)?
The lesson is requesting that you recreate that process so that you know how to increment and decrement a number with short notation.

Increment (++) The increment operator increments (adds one to) its operand and returns a value.
If used postfix, with operator after operand (for example, x++), then it returns the value before incrementing.
If used prefix with operator before operand (for example, ++x), then it returns the value after incrementing.

Side note: The lesson is trying to teach you this now because this process is useful later when you need to loop through things to quickly increment (++) or the reverse decrement (--) from a value.

obscuredetour
@obscuredetour
Mar 31 2017 04:06
lol
Ray Martinez
@rayjrm
Mar 31 2017 04:06
dang it
Joseph
@revisualize
Mar 31 2017 04:06
Sorry.
I'm super lazy.
I just copy and paste a lot.
CharlieAguilera090
@CharlieAguilera090
Mar 31 2017 04:07

Change the code to use the ++ operator on myVar. var myVar++; = 87;

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

Joseph
@revisualize
Mar 31 2017 04:07
@CharlieAguilera090 You need to read what I wrote above.
Ray Martinez
@rayjrm
Mar 31 2017 04:08
Pasted above*
Joseph
@revisualize
Mar 31 2017 04:08
/collapse-all
Roxroy
@roxroy
Mar 31 2017 04:08
@CharlieAguilera090 ,
num += 1; same as num = num + 1;
num++; same as num = num + 1;
These are just a short hand ways
CharlieAguilera090
@CharlieAguilera090
Mar 31 2017 04:11
@revisualize @roxroy okay thank you
CamperBot
@camperbot
Mar 31 2017 04:11
charlieaguilera090 sends brownie points to @revisualize and @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 508 | @roxroy |http://www.freecodecamp.com/roxroy
:star2: 3638 | @revisualize |http://www.freecodecamp.com/revisualize
Nishargo
@Nishargo
Mar 31 2017 04:16
can't get out of Escape Sequences in Strings
:(
can anybody help?
it says Assign the following three lines of text into the single variable myStr using escape sequences.
FirstLine
\SecondLine\
ThirdLine
here's my code:
var myStr = "FirstLine\n\SecondLine\r ThirdLine"; // Change this line
pepehipolito
@pepehipolito
Mar 31 2017 04:21
Hi. First time posting here. I have one JS script to go from the Advanced Algorithm Scripting section (algorithm title is "No repeats please"). It's about permutations but the formula is not evident and I really would rather not spend time becoming a "master permutator" just to figure out the formula. If somebody here can help with the formula that would be great, otherwise I'm going to have to brute force this one. Thanks!
@Nishargo What is the question? I don't understand the problem you're having based on your post.
Anavel
@arivera165
Mar 31 2017 04:25
need help w my code
i dont understand what is wrong

// Example
var changed = 0;

function change(num) {
return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 0;

function processArg(num) {
return (7 + 3) / 5;
}

// Only change code below this line
var processed = processArg(10);

CharlieAguilera090
@CharlieAguilera090
Mar 31 2017 04:26
this stuffs so confusing
Alexander
@Turtiathan
Mar 31 2017 04:27

Hello,

function palindrome(str) {
// Good luck!
str.toLowerCase();
str.replace(/[^a-z0-9]/g, '');

var reversedStr = str.split("").reverse().join("");

return ( str === reversedStr );
}

palindrome("eye");

I think my regular expression is not working.
It doesn't filter out special characters or blank spaces.
Anavel
@arivera165
Mar 31 2017 04:27
please help
Joseph
@revisualize
Mar 31 2017 04:28
@Turtiathan Strings are immutable.
Alexander
@Turtiathan
Mar 31 2017 04:28
right
Joseph
@revisualize
Mar 31 2017 04:28
@Turtiathan The methods you're trying to use do not mutate the string.
Alexander
@Turtiathan
Mar 31 2017 04:28
Thanks.
Anavel
@arivera165
Mar 31 2017 04:28
anyone?
Roxroy
@roxroy
Mar 31 2017 04:28
@pepehipolito , here is one way to solve it. Take the word and create a list of all the ways of combining the letters. Store each one in a list. Then loop throgh the list to examine each word. if the current letter match the upcoming one ( i + 1) then skip that word. If you get to the end of the word then save it into the no-repeat array. Return the count of that no-repeat array.
pepehipolito
@pepehipolito
Mar 31 2017 04:28
@arivera165 Maybe that you are adding 'var' before 'processed'? It's already declared so you shouldn't need the var. Other than that you will have to be a bit more explicit about the problem.
Anavel
@arivera165
Mar 31 2017 04:29
its saying that i should assign processArg to processed
which i have done
as far as i see anyway
pepehipolito
@pepehipolito
Mar 31 2017 04:30
@roxroy Thanks. That's the brute force approach I was talking about. I'd rather use a formula if there is one, otherwise I'll have to go the way you're proposing.
CamperBot
@camperbot
Mar 31 2017 04:30
pepehipolito sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 509 | @roxroy |http://www.freecodecamp.com/roxroy
Coy Sanders
@coymeetsworld
Mar 31 2017 04:30
@pepehipolito is right though you already declared processArg once, you only put var in front of a variable one time
pepehipolito
@pepehipolito
Mar 31 2017 04:31
@arivera165 What is the title of the challenge? I have done all but one and I think the answers are kept. I can take a look at mine.
Anavel
@arivera165
Mar 31 2017 04:32
i figured it out, thank you though!
pepehipolito
@pepehipolito
Mar 31 2017 04:32
what was the problem?
asvini.ramesh
@asviniramesh
Mar 31 2017 04:34

Hi guys , I am facing the problem in "Escape sequences in strings"

I have given myStr="\ FirstLine \n \"secondLine\" \r \"ThirdLine\" \";

still one point is not passed...myStr should have encoded text with the proper escape sequences and no spacing.
Roxroy
@roxroy
Mar 31 2017 04:34
@pepehipolito , For now go with your idea and later you can improve it. let me know if you come across a formula to solve it.
pepehipolito
@pepehipolito
Mar 31 2017 04:38
@asviniramesh The last sentence in the problem gives you the answer. Remember that the backslashes need escaping as well. I think your "myStr" is wrong.
Feelthewind
@Feelthewind
Mar 31 2017 04:38

function destroyer(arr) {
return arr.filter(function filterfunc(value) {
return value.indexOf(arguments[1]) > -1;
});
}

destroyer(["tree", "hamburger", 53], "tree", 53);

help me
pepehipolito
@pepehipolito
Mar 31 2017 04:38
@roxroy If I figure out a "smarter" way to solve the problem I'll let you know. Thanks.
CamperBot
@camperbot
Mar 31 2017 04:38
pepehipolito sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:warning: pepehipolito already gave roxroy points
Roxroy
@roxroy
Mar 31 2017 04:40
@pepehipolito , sure I'm very interested. Please keep in informed.
pepehipolito
@pepehipolito
Mar 31 2017 04:41
@Feelthewind There is no way to help you unless you explain what the problem is. For example, what the expected outcome is and what is that you're getting when you run the code.
Feelthewind
@Feelthewind
Mar 31 2017 04:42

function destroyer(arr) {
return arr.filter(function(value) {
return value !== arguments[1] && value !== arguments[2];
});
}
destroyer(["tree", "hamburger", 53], "tree", 53);

I can't understand why i can't get access to "tree" and 53 by arguments[];

asvini.ramesh
@asviniramesh
Mar 31 2017 04:42
@pepehipolito I have given escaping for backslashes also, Here is my code
myStr= "\"\\"FirstLine\n\"secondLine\"\r\"ThirdLine\"\"\\"";
Joseph
@revisualize
Mar 31 2017 04:45

You have to assign 'FirstLine newline backslash SecondLine backslash carriage-return ThirdLine' to the variable myStr.
But, You have to replace the escape words with the proper escape sequences. (And per the instructions: remove all spaces.)
How do you escape a newline? With: \n
How do you escape a backslash? With: \\
How do you escape a carriage-return? With \r
So, you have break the problem down.
FirstLine newline backslash SecondLine backslash carriage-return ThirdLine
FirstLine \n backslash SecondLine backslashcarriage-return ThirdLine
FirstLine \n \\ SecondLine backslash carriage-return ThirdLine
FirstLine \n \\ SecondLine \\ carriage-return ThirdLine
FirstLine \n \\ SecondLine \\ \r ThirdLine
You have to follow the instructions and remove all of the spaces
Then assign that to myStr as a string.

This lesson is not trying to teach you how to get some green check marks to pass onto the next lesson. It is trying to teach you a really valuable skill. If you have a string in JavaScript that is instantiated with double quotes (") (Example: var myStr = "Hello World";) you can also instantiate a string with single quotes (') (Example: var myStr = 'Hello World';)

How do you add a " to that string? Let's say you instantiated the string with double quotes and you want to put in a quote that someone said. You have to use an escape character.
Example: var myQuote = "Happy Feet said, \"I really like the rhythm.\"";
Or what happens if you want to add a tab to your string? You can't really add 3 spaces and expect it to show up as a tab. You have to use the escape character for a tab (\t).

OR let's say your trying to output a bunch of text and paragraphs within your JavaScript string. You can't really just make a bunch of variables.
var myParagraph1 = "a bunch of characters";
var myParagraph2 = "a bunch more characters";
I mean you could... but, why not just:
var myStr = "A bunch of characters/sentences.\nThe second paragraph of characters and sentences.";

@asviniramesh --^ .. truly read it and understand it.
pepehipolito
@pepehipolito
Mar 31 2017 04:45
@asviniramesh You have way too many quotes in there. If you read the last sentence of the problem and take a look at the table you should be able to figure it out.
Joseph
@revisualize
Mar 31 2017 04:47
Too many quotes because they're not trying to understand the process. They're trying to rush the answer.
Rushing the answer isn't learning.
Gonna rush through everything and realize that they learned nothing.
I know.. Because I did it.
I did it on Codecademy
I started to do it on FreeCodeCamp.
Understand not only the solution by the why.. Why does a huge community of developers have me working on ... this?
asvini.ramesh
@asviniramesh
Mar 31 2017 04:52
@revisualize very nice explanation for the solution and in personal (This lesson is not trying to teach you how to get some green check marks to pass onto the next lesson. It is trying to teach you a really valuable skill.)
Prakash Shiwakoti
@pshiwakoti1
Mar 31 2017 04:52
Hello guys. good evening. Does anyone know AngularJS 2? And wants to volunteer a real project? Please let me know. I joined this project last week and I am volunteering for 3 months. Its an online project and one can put anywhere between 12 to 40 hours a week
Samreen7
@Samreen7
Mar 31 2017 04:52
ummm
Prakash Shiwakoti
@pshiwakoti1
Mar 31 2017 04:53
To make you guys clearer, this is not a paid position. Just for your experience
Samreen7
@Samreen7
Mar 31 2017 04:53
ahan
Manish Giri
@Manish-Giri
Mar 31 2017 04:53
Is React involved? @pshiwakoti1
pepehipolito
@pepehipolito
Mar 31 2017 04:53
@Feelthewind The problem you're having is that the function you are filtering with also have an 'arguments' argument. If you assign your arguments of the outer function to a variable and then you use the variable it will work.
Prakash Shiwakoti
@pshiwakoti1
Mar 31 2017 04:53
no React @Manish-Giri
Angular
Samreen7
@Samreen7
Mar 31 2017 04:53
react
want to learn
Manish Giri
@Manish-Giri
Mar 31 2017 04:54
sigh
I' don't like angular
Prakash Shiwakoti
@pshiwakoti1
Mar 31 2017 04:54
but you can try for Front End development also. They may require javascript/css/html guy
Joseph
@revisualize
Mar 31 2017 04:54
@pshiwakoti1 People in the Angular chatroom know Angular
Prakash Shiwakoti
@pshiwakoti1
Mar 31 2017 04:54
but I don't know that
pepehipolito
@pepehipolito
Mar 31 2017 04:54
How do you post a piece of code in here so it looks nice?
Samreen7
@Samreen7
Mar 31 2017 04:54
where we can check sir?
Prakash Shiwakoti
@pshiwakoti1
Mar 31 2017 04:54
idealist.org
pepehipolito
@pepehipolito
Mar 31 2017 04:55
@Feelthewind function destroyer(arr) {
var my_args = arguments;
console.log(arguments);
console.log(arr);
return arr.filter(function(value) {
console.log('value: ' + value);
console.log('1: ' + arguments[1]);
console.log('2: ' + arguments[2]);
return value !== my_args[1] && value !== my_args[2];
});
}
output = destroyer(["tree", "hamburger", 53], "tree", 53);
console.log('output: ' + output);
Samreen7
@Samreen7
Mar 31 2017 04:55
ahan thanks
eeflores
@eeflores
Mar 31 2017 04:55
```
code here
```
code here
pepehipolito
@pepehipolito
Mar 31 2017 04:55
function destroyer(arr) { var my_args = arguments; console.log(arguments); console.log(arr); return arr.filter(function(value) { console.log('value: ' + value); console.log('1: ' + arguments[1]); console.log('2: ' + arguments[2]); return value !== my_args[1] && value !== my_args[2]; }); } output = destroyer(["tree", "hamburger", 53], "tree", 53); console.log('output: ' + output);
damn!
:)
JAPerera
@JAPerera
Mar 31 2017 04:57
Has anyone gone through the counting cards challenge? I've been stuck for about an hour and I'm not really sure how to go about fixing my code.
var count = 0;

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

  if (count > 0) {
    return (count + " Bet");
  } else if (count <= 0) {
    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');
remove redeclarations of count eg count = count + 1;
no var
JAPerera
@JAPerera
Mar 31 2017 04:59
Shiiiittt that worked.
eeflores
@eeflores
Mar 31 2017 04:59
actually, leave the first declaration of count at the start of the code
pepehipolito
@pepehipolito
Mar 31 2017 05:00
function destroyer(arr) {
  var my_args = arguments;
  return arr.filter(function(value) {
    return value !== my_args[1] && value !== my_args[2];
  });
}
output = destroyer(["tree", "hamburger", 53], "tree", 53);
console.log('output: ' + output);
@Feelthewind ^^
JAPerera
@JAPerera
Mar 31 2017 05:00
Do you know why that works as is though? I tried putting that in earlier, but didn't run it like that because the syntax highlighting didn't do anything.
Roxroy
@roxroy
Mar 31 2017 05:00
@JAPerera, var, redefines the variable and looses the old value.
JAPerera
@JAPerera
Mar 31 2017 05:01
Ahhh - so we don't want to redefine it, we just want to increment or decrement as we see fit.
I think I get it now. Thanks guys!
Feelthewind
@Feelthewind
Mar 31 2017 05:01
@pepehipolito thanks a lot!
CamperBot
@camperbot
Mar 31 2017 05:01
feelthewind sends brownie points to @pepehipolito :sparkles: :thumbsup: :sparkles:
:warning: @pepehipolito's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Roxroy
@roxroy
Mar 31 2017 05:02
@JAPerera , great. np
pepehipolito
@pepehipolito
Mar 31 2017 05:02
@Feelthewind console.log(<my_message>); is a very helpful tool to figure things out. ;)
Markus Kiili
@Masd925
Mar 31 2017 05:07
@pepehipolito You should loop the arguments inside the filter callback.
Duane
@DuaneYaiser
Mar 31 2017 05:18

"Make Object Properties Private": var gear = 0;

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

not passing, don't know where I'm going wrong. :( thoughts?
Markus Kiili
@Masd925
Mar 31 2017 05:19
@DuaneYaiser setGear should change the private variable.
Don't use same name for the method parameter and private variable.
Duane
@DuaneYaiser
Mar 31 2017 05:21
Ah! I think I see . . .
loudnoyzez
@loudnoyzez
Mar 31 2017 05:29
would anyone be willing to help me figure out how to approach the "stand in line" challenge?
Markus Kiili
@Masd925
Mar 31 2017 05:30
@loudnoyzez Sure.
loudnoyzez
@loudnoyzez
Mar 31 2017 05:31
well thanks @Masd925 I don't even know how to start
CamperBot
@camperbot
Mar 31 2017 05:31
loudnoyzez sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3714 | @masd925 |http://www.freecodecamp.com/masd925
loudnoyzez
@loudnoyzez
Mar 31 2017 05:31
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
not sure how this should look
Markus Kiili
@Masd925
Mar 31 2017 05:32
@loudnoyzez You need to find two array methods that do those things asked, and use them on function parameters arr and item. Parameters hold the passed array and number.
Sam Houlahan
@Sam-Houlahan
Mar 31 2017 05:34
hi guys
need help on Title Case a Sentence.
Markus Kiili
@Masd925
Mar 31 2017 05:34
@keewhy What have you done so far?
Sam Houlahan
@Sam-Houlahan
Mar 31 2017 05:35

```function titleCase(str) {
var newStr = str.toLowerCase().split(" ");

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

newStr[i]=newStr[i].charAt(0).toUpperCase();

}

return newStr;
}

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

Markus Kiili
@Masd925
Mar 31 2017 05:35
@keewhy Just append the rest of the string there lowercased.
Sam Houlahan
@Sam-Houlahan
Mar 31 2017 05:35
how do i get the rest of the string
as it is currently returning me just the first letters
would i slice()?
Markus Kiili
@Masd925
Mar 31 2017 05:36
@keewhy slice, substr, or substring method.
Also think what you are returning.
Sam Houlahan
@Sam-Houlahan
Mar 31 2017 05:36
hmm okay will give it a go thank you :)
Justin
@jerikson05
Mar 31 2017 05:38

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

function checkObj(checkProp) {
// Your Code Here

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

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

am I on the right track here?? ^^^
Markus Kiili
@Masd925
Mar 31 2017 05:38
@jerikson05 hasOwnProperty returns a Boolean you need to test.
Justin
@jerikson05
Mar 31 2017 05:40
do I need an else statement? like return else return?
Markus Kiili
@Masd925
Mar 31 2017 05:41
@jerikson05 You need an if and perhaps then an else.
Justin
@jerikson05
Mar 31 2017 05:42
ahh.. see, I wasn't sure if that's what it was calling for because in the previous two challenges it doesn't have any of that. okay. I'll be right back.
Rick
@r7uaz0n
Mar 31 2017 05:48
Having trouble w/ the Stand in Line challenge.
aamirfreecode
@aamirfreecode
Mar 31 2017 05:49
I have to capitalize first letter of each word.

function titleCase(str) {
var word = str.toLowerCase().split(' ');
var newArr;
for(var i=0; i<word.length; i++){
newArr = word[i].charAt(0).toUpperCase() + word[i].slice(1);
}
return newArr.join(' ');
}

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

Rick
@r7uaz0n
Mar 31 2017 05:49
"Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed."
aamirfreecode
@aamirfreecode
Mar 31 2017 05:49
need help
Rick
@r7uaz0n
Mar 31 2017 05:50

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

return item; // Change this line
}

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

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

any hints?
Ashton
@Electrixz05
Mar 31 2017 05:53
anybody know how to do the ++ operator?
Code Here-
loudnoyzez
@loudnoyzez
Mar 31 2017 05:54
@b00kwheat I am stuck on this one too. I am guessing we are to use the .push and .pop methods to add at the end and remove the first element but still stuck on how to write it
kirbyedy
@kirbyedy
Mar 31 2017 05:54
@b00kwheat @loudnoyzez you have to use push() and shift() methods
@Electrixz05 at the end of your variable add ++
Ashton
@Electrixz05
Mar 31 2017 05:56
@kirbyedy what about the myVar = myVar?
kirbyedy
@kirbyedy
Mar 31 2017 05:57
@Electrixz05 it says there in the instruction add ++ on your variable
same as the example
Ashton
@Electrixz05
Mar 31 2017 05:57
@kirbyedy oh yeah sorry i was reading the wrong thing, thanks
CamperBot
@camperbot
Mar 31 2017 05:57
electrixz05 sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 1970 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
tinla94
@tinla94
Mar 31 2017 05:59
sorry
may i ask
return count + (count > 0 ? " Bet" : " Hold"); what does this line mean ?
Jor
@joreyesl
Mar 31 2017 05:59
@aamirfreecode you are overwriting newArr each time the loop iterates. initilize newArr to an empty array, then try pushing each word or assigning it to an index.
That is the same as:
if (count>0) return String(count) + " Bet";
else return String(count) + " Hold";
tinla94
@tinla94
Mar 31 2017 06:02
Thanks
loudnoyzez
@loudnoyzez
Mar 31 2017 06:10
well I managed to pass the challenge through trial and error but the code doesn't make sense to me lol'
Rick
@r7uaz0n
Mar 31 2017 06:11
@loudnoyzez Yes, push and shift, I believe. I'm having trouble writing it as well.
loudnoyzez
@loudnoyzez
Mar 31 2017 06:14
yeah. that definitely works. aside from that my code doesn't look right but oh well
Fardin-S
@Fardin-S
Mar 31 2017 06:15

Hello, I need help.
function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = -30*9/5+32;

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

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

Markus Kiili
@Masd925
Mar 31 2017 06:15
@Fardin-S You need to use the function parameter celsius on the equation.
Ashton
@Electrixz05
Mar 31 2017 06:16
can someone help me out with this-
loudnoyzez
@loudnoyzez
Mar 31 2017 06:18
@b00kwheat if you get stuck I can share
Rick
@r7uaz0n
Mar 31 2017 06:19
@loudnoyzez you got it? hmm, I prefer some hints first.
loudnoyzez
@loudnoyzez
Mar 31 2017 06:20
ok well my first mistake personally was thinking I should use numbers or nextInLine with my push. that did not get me there
Ashton
@Electrixz05
Mar 31 2017 06:20
nver mind i worked it out
Alina
@Georgia22
Mar 31 2017 06:21
var myStr = "This is the first sentence.";
myStr += "This is the second sentence.";
can someone, please, explain what am I doing wrong here and why it isn’t working? myStr should have a value of "This is the first sentence. This is the second sentence."
Rick
@r7uaz0n
Mar 31 2017 06:21
@loudnoyzez this is what I have for the function but I know it's not correct.

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

testArr.push(x);
var x = 6;
testArr.shift(0);
return nextInLine; // Change this line
}

loudnoyzez
@loudnoyzez
Mar 31 2017 06:21
@b00kwheat it involves literally using the arguments
aamirfreecode
@aamirfreecode
Mar 31 2017 06:22
@joreyesl Got it, Thanks
CamperBot
@camperbot
Mar 31 2017 06:22
aamirfreecode sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 701 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Mar 31 2017 06:22
@Georgia22 when you print out myStr it will look like This is the first sentence.This is the second sentence. You need a space between those 2 sentences. It has to match exactly what they want.
Feelthewind
@Feelthewind
Mar 31 2017 06:23
could anyone explain to me why this code doesn't work?

function destroyer(arr) {
var my_args = arguments;
console.log(my_args);

return arr.filter(function(value) {
var result = 0;
for(var i = 1; i < my_args.length; i++) {
result += (value !== my_args[i]);
}
return result;
});
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

Sean McDaniel
@SeanMcDaniel1
Mar 31 2017 06:24
alt
Jor
@joreyesl
Mar 31 2017 06:25
@Feelthewind value !== my_args[i] is a comparison and will evaluate to true/false
Sean McDaniel
@SeanMcDaniel1
Mar 31 2017 06:25
alt
loudnoyzez
@loudnoyzez
Mar 31 2017 06:25
you are on the right track @b00kwheat. number equals (item). add to the end equals .push. to the end of the array. array equals (arr)
hinting about code is crazy hard via text lol
don't use test at all
Jai Mitch
@jaimitch
Mar 31 2017 06:26

can anyone help me figure out this line of code and why it wont pass the criteria of having encoded text with the proper escape sequences and no spacing.

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

can someone see why the par 4, 5 strokes isnt working?
zihad-faruk
@zihad-faruk
Mar 31 2017 06:28

Hello guys, i am stuck at Understand String Immutability challenge... this is my code,could you tell me what is worng with my code ,thanks // Setup
var myStr = "Hello World";

// Only change code below this line

myStr= "Hello World";

myStr[0] = "H"; // Fix Me

Alina
@Georgia22
Mar 31 2017 06:29
thanks @joreyesl :)
CamperBot
@camperbot
Mar 31 2017 06:29
georgia22 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 702 | @joreyesl |http://www.freecodecamp.com/joreyesl
Dan Couper
@DanCouper
Mar 31 2017 06:33
@Feelthewind almost right, but the filter function has to return true of false; the condition is the only bit you really want; the whole function should return true if value isn't in arts
Himujjal Upadhyaya
@Himujjal
Mar 31 2017 06:33
Steamroller problem in Intermediate algorithms, javascript? Anyone has done it.
My code is producing the required output but then it doesn't show the green sign
Deryck Austin
@Deryckaus
Mar 31 2017 06:35
Hello all . i am battling to understand the .length concept. anyone have a link or site the i could read up on to clear this in my confused mind????
Markus Kiili
@Masd925
Mar 31 2017 06:35
@Himujjal Are you using global variables?
Himujjal Upadhyaya
@Himujjal
Mar 31 2017 06:35
yes
Markus Kiili
@Masd925
Mar 31 2017 06:35
They mess up FCC tests.
Fardin-S
@Fardin-S
Mar 31 2017 06:36
@Masd925 It's not working
Himujjal Upadhyaya
@Himujjal
Mar 31 2017 06:36
so, what can i do to fix it?
Markus Kiili
@Masd925
Mar 31 2017 06:36
@Himujjal Change the logic or make a wrapper function.
Himujjal Upadhyaya
@Himujjal
Mar 31 2017 06:36
@Masd925 Let me try.
Sean McDaniel
@SeanMcDaniel1
Mar 31 2017 06:37

function golfScore(par, strokes) {
// Only change code below this line
if (par <= 4, strokes ==1)
return "Hole-in-one!";

if (par ==4, strokes == 2)
return "Eagle";

if (par ==5 , strokes == 2 )
return "Eagle";

if (par ==4 , strokes == 3)
return "Birdie";

if (par ==4, strokes == 4 )
return "Par";

if (par ==5, strokes ==5)
return "Par";

if (par ==4 , strokes ==5)
return "Bogey";

if (par ==4, strokes ==6)
return "Double Bogey";

if (par == 4, strokes >=7)
return "Go Home!";

// Only change code above this line
}

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

Can anyone see why it wont post Bogey for par 4 , stroke 5
thats the only value that is incorrect
Jai Mitch
@jaimitch
Mar 31 2017 06:38
has anyone finished the escaping sequences in string assignment. I've hit a wall in trying to figure out what I'm doing wrong.
var myStr='"FirstLine\"\n\\"SecondLine\"\r\\"ThirdLine\"';
this is what i have come up with but the requirement to have encoded text with proper escape sequences and no spaces is not correct. I really need help I've been doing this for about a day and half now.
Himujjal Upadhyaya
@Himujjal
Mar 31 2017 06:42
@Masd925 what's a wrapper function? I may have used it but I exactly don't know by terminology.
Markus Kiili
@Masd925
Mar 31 2017 06:43
@Himujjal You can write a function around the global variable and the function you now have and then call the inner function inside the wrapper. You need to rename the functions then.
Better way would be to change the logic.
Rick
@r7uaz0n
Mar 31 2017 06:45
@loudnoyzez still stuck.
Roxroy
@roxroy
Mar 31 2017 06:47
@jaimitch , you will need remove the "" as they are not need to solve.
loudnoyzez
@loudnoyzez
Mar 31 2017 06:48
@b00kwheat ok I did a push with item on arr. then I set the shift on arr equal to item
so literally putting (item) at the end of arr. and then literally putting a .shift on arr that I set to the variable item. then when it returns item it is returning the value that we removed
Ashton
@Electrixz05
Mar 31 2017 06:50
How do i use the += operator?
Manish Giri
@Manish-Giri
Mar 31 2017 06:51

@Electrixz05

myVar += 5; will add 5 to myVar

the example shows how
Jor
@joreyesl
Mar 31 2017 06:51
@Manish-Giri great-grandmasta
Manish Giri
@Manish-Giri
Mar 31 2017 06:52
:smiling_imp:
@joreyesl you are him, notme
Ashton
@Electrixz05
Mar 31 2017 06:52
@Manish-Giri but how do i do it with a= a + 12;?
Manish Giri
@Manish-Giri
Mar 31 2017 06:52
:bow:
Rick
@r7uaz0n
Mar 31 2017 06:52
@loudnoyzez using testArr.push(item); ?
Manish Giri
@Manish-Giri
Mar 31 2017 06:52
@joreyesl I'm more like gangsta :smiling_imp:
Jor
@joreyesl
Mar 31 2017 06:52
@Electrixz05 so you see how he used, 5. You can do it with any number.
@Manish-Giri :joy:
Roger Chavez
@RogChav
Mar 31 2017 06:53
@jaimitch Did you get it?
Ashton
@Electrixz05
Mar 31 2017 06:53
@joreyesl ...
Roger Chavez
@RogChav
Mar 31 2017 06:55
@jaimitch you're only supposed to be using one set of quotations around all of your script
Ashutosh Kumar
@kashutosh845
Mar 31 2017 06:55
Remove all the backslashes ()
You should have two single quotes ' and four double quotes "
How to do this?
Jor
@joreyesl
Mar 31 2017 06:55
@Electrixz05 variables are just identifiers, you can use any variable and literal. What if I had a variable called num and I wanted to add 10 to it. I can change this num = num + 10 to this num += 10
Jai Mitch
@jaimitch
Mar 31 2017 06:55
@roxroy thank you, but I tried that too, unless I'm doing it wrong. I tried
var myStr='FirstLine\n\\SecondLine\r\\ThirdLine'; as well.
CamperBot
@camperbot
Mar 31 2017 06:55
jaimitch sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 515 | @roxroy |http://www.freecodecamp.com/roxroy
Roger Chavez
@RogChav
Mar 31 2017 06:55
@jaimitch this is the solution var myStr= "FirstLine\n\SecondLine\\rThirdLine";
Ashton
@Electrixz05
Mar 31 2017 06:55
a = a + 12;
b = 9 + b;
c = c + 7;
loudnoyzez
@loudnoyzez
Mar 31 2017 06:56
@b00kwheat no. don't use testArr
Dragos
@dmihail94
Mar 31 2017 06:56

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

// Your code above this line
return result;
}

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

can someone help me?
loudnoyzez
@loudnoyzez
Mar 31 2017 06:56
@b00kwheat just use arr
and don't forget to watch the console as you test
...it helped me on this one. I rarely look at the console on these challenges lol
Roxroy
@roxroy
Mar 31 2017 07:01
@jaimitch , did u get it to work?
Roger Chavez
@RogChav
Mar 31 2017 07:01
@jaimitch sorry I just realized that it didn't paste right. If you want I can repost the correct response. Otherwise your code looks good aside from \r\, the back slash\ is supposed to come before the \r.
Jai Mitch
@jaimitch
Mar 31 2017 07:01
@Rochar88 thank you, it's still not working for me but I think I've just been looking at this too long.
CamperBot
@camperbot
Mar 31 2017 07:01
jaimitch sends brownie points to @rochar88 :sparkles: :thumbsup: :sparkles:
:cookie: 28 | @rochar88 |http://www.freecodecamp.com/rochar88
Roger Chavez
@RogChav
Mar 31 2017 07:02
"var myStr= "FirstLine\n\SecondLine\\rThirdLine";"
Darn, I don't know how to post code. It automatically changes when I post in chat.
Roxroy
@roxroy
Mar 31 2017 07:03
@jaimitch . glad to see that you got.
Jai Mitch
@jaimitch
Mar 31 2017 07:03
@roxroy thank you
Ashutosh Kumar
@kashutosh845
Mar 31 2017 07:03
Remove all the backslashes ()
You should have two single quotes ' and four double quotes "
How to complete this challenge?
Ashton
@Electrixz05
Mar 31 2017 07:04
can someone copy and paste their coding for-
Ashutosh Kumar
@kashutosh845
Mar 31 2017 07:06
fahrenheit=celsius*9/5+32;
Roger Chavez
@RogChav
Mar 31 2017 07:07
is anyone here familiar with .replace() ?I'm trying to remove non alphabet characters and spaces from a string.
Markus Kiili
@Masd925
Mar 31 2017 07:08
@Rochar88 You need a suitable regexp object. Take a look at metacharacters \W and \w.
Jor
@joreyesl
Mar 31 2017 07:08
@Rochar88 you will want to use a regex as the first argument
Roxroy
@roxroy
Mar 31 2017 07:09
@Electrixz05 , you need to write the formula fahrenheit=celsius*9/5+32; and return fahrenheit.
loudnoyzez
@loudnoyzez
Mar 31 2017 07:09
@b00kwheat btw your push was perfect, just replace testArr with arr. after that set item = your shift
Roger Chavez
@RogChav
Mar 31 2017 07:09
I did, but It's still not doing the trick. Here's that portion of the code str.replace(/([\d)([\W])([\s]*)/,'');
Jor
@joreyesl
Mar 31 2017 07:11
@Rochar88 you dont need to create a capture group ()and you only need to define 1 set. \W should take care of most things including spaces so you dont need \s. And you dont want to remove numbers, you want to keep those, so you want to remove \d.
The only thing that is not covered by \W is underscore _ so you want to add that to the set. Aside from that make sure to use the global flag g otherwise the regex will only match the first instance and not all instances in the string.
Rick
@r7uaz0n
Mar 31 2017 07:16
@loudnoyzez
function nextInLine(arr, item) {
// Your code here
arr.push(x);
item.shift(0);
return nextInLine; // Change this line
}
I know this doesn't work but this is where I am.
loudnoyzez
@loudnoyzez
Mar 31 2017 07:17
replace x with item
remove the next line
MAYHOO1099
@MAYHOO1099
Mar 31 2017 07:18
hey

var largest= 0;
function largestOfFour(arr) {

for (i=0;i<arr.length;i++) { for (j=0;j<arr[i].length;j++) { if (arr[i][j] > largest){
arr[i][j] = arr[i];
}

  }

}

return arr;
}

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

can someone tell me what wrong with that?
loudnoyzez
@loudnoyzez
Mar 31 2017 07:20
@b00kwheat I actually didn't change the line that said change this line haha
my second line was .... item = .........
Markus Kiili
@Masd925
Mar 31 2017 07:21
@MAYHOO1099 You need to initialize largest for each subarray and then after inner loop assign largest to arr[i].
loudnoyzez
@loudnoyzez
Mar 31 2017 07:22
i set the array argument which is arr with the shift method equal to the variable item
Markus Kiili
@Masd925
Mar 31 2017 07:22
@MAYHOO1099 var largest = -Infinity; would make it work for negative numbers too.
loudnoyzez
@loudnoyzez
Mar 31 2017 07:23
like I said before, still not sure if this is the proper method but it passed @b00kwheat
Roger Chavez
@RogChav
Mar 31 2017 07:24
thanks@ @joreyesl @Masd925
CamperBot
@camperbot
Mar 31 2017 07:24
rochar88 sends brownie points to @joreyesl and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 703 | @joreyesl |http://www.freecodecamp.com/joreyesl
:star2: 3715 | @masd925 |http://www.freecodecamp.com/masd925
John Lawson
@JohnLRI
Mar 31 2017 07:26
one major thing learned there is a difference between code that works, code that is correct and code that is good
Markus Kiili
@Masd925
Mar 31 2017 07:27
@JohnLRI And works usually means seems to work.
iso
@iso1048
Mar 31 2017 07:27
Could somebody please help. I have an array storing words. How can I make it so that each of these words is stored within its own subarray?
Markus Kiili
@Masd925
Mar 31 2017 07:28
@gothamknight Do you mean ["cat", "pants"] -> [["cat"],["pants"]]
iso
@iso1048
Mar 31 2017 07:28
@Masd925 yes
John Lawson
@JohnLRI
Mar 31 2017 07:29
@Masd925 yes like doesn't crash or gives correct result for some test case but not all
Markus Kiili
@Masd925
Mar 31 2017 07:29
var arr = ["cat", "pants"];

arr.map(function(str){
  return [str];
}); // [ [ 'cat' ], [ 'pants' ] ]
@JohnLRI Yeah, and even if bad code passes all the tests there is no way to tell if it has some bugs hiding still.
iso
@iso1048
Mar 31 2017 07:30
@Masd925 Could you explain the code please?
Markus Kiili
@Masd925
Mar 31 2017 07:30
@gothamknight Map makes a new array by passing each arr element into the callback function and making a new array from the return values.
So each element is mapped str -> [str]
devpaaji
@devpaaji
Mar 31 2017 07:32
@Masd925 this does the trick return [str]
if you would have passed with brackets
Markus Kiili
@Masd925
Mar 31 2017 07:33
@devpaaji That makes an array with the passed value as an element and returns it.
iso
@iso1048
Mar 31 2017 07:34
@Masd925 Cool. Thank you.
CamperBot
@camperbot
Mar 31 2017 07:34
gothamknight sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3716 | @masd925 |http://www.freecodecamp.com/masd925
devpaaji
@devpaaji
Mar 31 2017 07:35
  return str; // returns the same ["cat", "pants"];
 array items are changing their form when called with
return [str]
});
@gothamknight
Rick
@r7uaz0n
Mar 31 2017 07:39
@loudnoyzez Ok, let me see what you got.
Thomas Faller
@thomasfaller
Mar 31 2017 07:46
Hey guys, I’m trying to build a script that lets a visitor search through a list of items (array) and print the list if they type “list”, exit the loop if they type “quit” and say whether the item they typed is in or out of stock.
I’m getting errors on my break statement but I have the feeling the whole loop is not well built. Is there something I’m missing here?
// script that create / check / return inventory

var inventory = ["milk","water","wipers","wine","beer","toothpaste","cookies","bread"];

function write(html) {
    document.write(html);
} // function that write the result on the page

while(true) {  // endless loop
    var search = prompt('Type the item you are looking for, type "list" to display the inventory, type "quit" to exit te store.');
    search = search.toLowerCase;
    } if (search = "quit") {
    break; // if the client types quit, they exit the store, loop ends
        } else if search == "list" {
            write("<p>We currently have " + inventory.join(", ") + " in stock.</p>");
            } else if (inventory.indexOf(search) > -1) {
                write("<p>Yes, we have " + search + " in our stock.</p>");
                } else {
                    write("<p>Sorry, we don't have " + search + " in our stock</p>");
                }
Markus Kiili
@Masd925
Mar 31 2017 07:47
@thomasfaller .toLowerCase(); <- parens
Use === for comparisons, not = which is assignment operator.
if search == "list" parens missing here
Rick
@r7uaz0n
Mar 31 2017 07:50
@loudnoyzez I haven't been using the console at all until now.
Thomas Faller
@thomasfaller
Mar 31 2017 07:51
@Masd925 thanks, totally missed those (aha that’s what coding in the bus can do)
CamperBot
@camperbot
Mar 31 2017 07:51
thomasfaller sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3717 | @masd925 |http://www.freecodecamp.com/masd925
Thomas Faller
@thomasfaller
Mar 31 2017 07:51
it’s still giving me a illegal break statement
Markus Kiili
@Masd925
Mar 31 2017 07:53
@thomasfaller Check the braces. Break is outside the while loop.
Dan Couper
@DanCouper
Mar 31 2017 07:54
Fix your formatting, it's much easier to see where the error is:
while (true) { // endless loop
  var search = prompt('Type the item you are looking for, type "list" to display the inventory, type "quit" to exit te store.');
  search = search.toLowerCase;
}
if (search = 'quit') {
  break; // if the client types quit, they exit the store, loop ends
} else if search == 'list'{
  write('<p>We currently have ' + inventory.join(', ') + ' in stock.</p>');
} else if (inventory.indexOf(search) > - 1) {
  write('<p>Yes, we have ' + search + ' in our stock.</p>');
} else {
  write('<p>Sorry, we don\'t have ' + search +