These are chat archives for FreeCodeCamp/HelpJavaScript

6th
Mar 2017
Manish Giri
@Manish-Giri
Mar 06 2017 00:00
@revisualize .....
Simon
@smnshulgan
Mar 06 2017 00:00
@adamvz why
function mutation(arr) 
{
  var total = 0;
  arr[0] = arr[0].toLowerCase();
  arr[1] = arr[1].toLowerCase();
  for(var i = 0; i < arr[1].length; i++)
    {
      total = total + arr[1].substr(i,i).indexOf(arr[0]);
    }
  if(total === 0)
    return true;
  else
    return false;
}
mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);
Joseph
@revisualize
Mar 06 2017 00:01
@Manish-Giri Yeah, That's what I said.
Vaisakh Raghunandan Nair
@vaisakh92nair
Mar 06 2017 00:01
can somebody help please ?? /
Simon
@smnshulgan
Mar 06 2017 00:01
im not sure the total = total + arr[1].substr(i,i).indexOf(arr[0]); is doing what i want it to do
Joseph
@revisualize
Mar 06 2017 00:01
@vaisakh92nair What have you done?
Vaisakh Raghunandan Nair
@vaisakh92nair
Mar 06 2017 00:02
i didnt understand the question at all
Simon
@smnshulgan
Mar 06 2017 00:02
@revisualize im using that but it doesnt help with it
Vaisakh Raghunandan Nair
@vaisakh92nair
Mar 06 2017 00:02
like what we need to do
the mad Libs concept
Joseph
@revisualize
Mar 06 2017 00:02

@vaisakh92nair Gist by revisualize / FreeCodeCamp - Word_Blanks.js
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks and with four parameter of myNoun, myAdjective, myVerb and myAdverb.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

Simon
@smnshulgan
Mar 06 2017 00:02
@revisualize either i dont know what .indexOf is doing or something is else is amiss
Joseph
@revisualize
Mar 06 2017 00:03
@smnshulgan Did you run your code through the link that I provided?
Jor
@joreyesl
Mar 06 2017 00:03
@smnshulgan you dont need to create a substring. You just need to check the index of ith character of arr[1] in arr[0]. If the index returned in not -1 then its in the string.
Simon
@smnshulgan
Mar 06 2017 00:04
@joreyesl how do i do it w/o using a substr()
Adam VanZuiden
@adamvz
Mar 06 2017 00:04
@smnshulgan use Joseph's link. It will show you what's going on. You are pretty close but just need to finish it off.
Simon
@smnshulgan
Mar 06 2017 00:05
@adamvz his link isnt helping
Jor
@joreyesl
Mar 06 2017 00:05
@smnshulgan you can access a character at a specific index of a string like you would do an array. arr[1][i]
Simon
@smnshulgan
Mar 06 2017 00:05
@adamvz i ran it and it just keeps puting total down by -1
function mutation(arr) 
{
  var total = 0;
  arr[0] = arr[0].toLowerCase();
  arr[1] = arr[1].toLowerCase();
  for(var i = 0; i < arr[1].length; i++)
    {
      total = total + arr[1][i].indexOf(arr[0]);
    }
  if(total === 0)
    return true;
  else
    return false;
}
mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);
still doesnt work
@joreyesl doesnt doing arr[1][i] make it try to look into a subarray
Jor
@joreyesl
Mar 06 2017 00:06
@smnshulgan no you dont want to call indexOf on arr[1], you want to check if that character is found in arr[0]. You are doing the reverse
Adam VanZuiden
@adamvz
Mar 06 2017 00:07
@smnshulgan swap your arrays around
Simon
@smnshulgan
Mar 06 2017 00:07
wait how does the .indexOf work
tell me in your own words please
i dont understand the explanation from mdn
Adam VanZuiden
@adamvz
Mar 06 2017 00:08
it returns the first position of the string you are looking for.
Jor
@joreyesl
Mar 06 2017 00:08
@smnshulgan you call indexOf on the string that you want to search on, and the argument you pass is the string you want to search for
Adam VanZuiden
@adamvz
Mar 06 2017 00:08
if the string isn't there it returns -1
Simon
@smnshulgan
Mar 06 2017 00:08
@joreyesl arent i trying to search on arr1
Jor
@joreyesl
Mar 06 2017 00:09
@smnshulgan no arr[1] is the characters you want to search for in arr[0]
Manish Giri
@Manish-Giri
Mar 06 2017 00:09
@smnshulgan open dev tools and give it a shot yourself..
it'll help.
Simon
@smnshulgan
Mar 06 2017 00:09
@Manish-Giri open dev tools?
Manish Giri
@Manish-Giri
Mar 06 2017 00:10
@smnshulgan your browser's developer tools
Adam VanZuiden
@adamvz
Mar 06 2017 00:10
so
var a = "abcdefg";
console.log(a.indexOf("c) )//will return 4 as it's in the 4th 0 indexed position)
_
Simon
@smnshulgan
Mar 06 2017 00:10
@Manish-Giri ive never done that or know how to do that
Adam VanZuiden
@adamvz
Mar 06 2017 00:10
@smnshulgan on chrome it's right click.
Manish Giri
@Manish-Giri
Mar 06 2017 00:10
@smnshulgan really should have done that much earlier..
Simon
@smnshulgan
Mar 06 2017 00:11
@Manish-Giri do you want to tell me how to open it
Adam VanZuiden
@adamvz
Mar 06 2017 00:11
@simon which browser are you using?
Simon
@smnshulgan
Mar 06 2017 00:11
@adamvz chrome
Adam VanZuiden
@adamvz
Mar 06 2017 00:12
@smnshulgan ctrl + shift + i
@simon or right click and click inspect
Manish Giri
@Manish-Giri
Mar 06 2017 00:13
@herunan because
Simon
@smnshulgan
Mar 06 2017 00:13
oh this is developer tools
Manish Giri
@Manish-Giri
Mar 06 2017 00:13
function(wheels, seats, engines)
you're not using these parameters
@herunan
Simon
@smnshulgan
Mar 06 2017 00:13
what am i supposed to do with the dev tools now
Manish Giri
@Manish-Giri
Mar 06 2017 00:14
write code
for ex, test indexOf
herunan
@herunan
Mar 06 2017 00:14
@Manish-Giri Of course… Thanks! I realised right after posting—stupid me...
CamperBot
@camperbot
Mar 06 2017 00:14
herunan sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4598 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Mar 06 2017 00:15
@herunan :+1:
Simon
@smnshulgan
Mar 06 2017 00:16
wait so to fix my code i just have to check if total is postive
Adam VanZuiden
@adamvz
Mar 06 2017 00:16
@smnshulgan well more than that. You will need to swap the places of the arr[0] and arr[0][i]. You are using it backwards.
Simon
@smnshulgan
Mar 06 2017 00:17
function mutation(arr) 
{
  var total = 0;
  arr[0] = arr[0].toLowerCase();
  arr[1] = arr[1].toLowerCase();
  for(var i = 0; i < arr[1].length; i++)
    {
      total = total + arr[0].indexOf(arr[1][i]);
    }
  if(total > 0)
    return true;
  else
    return false;
}
mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);
this shouldnt work like if the majority are returning positives one negative will still leave total with a positive value
Adam VanZuiden
@adamvz
Mar 06 2017 00:18
@smnshulgan so you are closer. However that code will only tell if you if 1 or more of the letters in the second string are in the first.
@smnshulgan think about what I said indexOf will return if it doesn't find it. Can you test against that?
Jor
@joreyesl
Mar 06 2017 00:20
@smnshulgan seems you are trying to keep a count of some sort. You will need an if statement checking if the index returned is positive. If it is positive then increment total by 1. At the end of the loop, if total matches the length of arr[1] then that means all characters of that string had positive indices, so all were found and you can return true.
Simon
@smnshulgan
Mar 06 2017 00:20
function mutation(arr) 
{
  var total = 0;
  arr[0] = arr[0].toLowerCase();
  arr[1] = arr[1].toLowerCase();
  for(var i = 0; i < arr[1].length; i++)
    {
      total = 0;
      total = arr[0].indexOf(arr[1][i]);
      if(total < 0)
        return false;
    }
    return true;
}
mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);
it works
thanks @adamvz @joreyesl
CamperBot
@camperbot
Mar 06 2017 00:21
smnshulgan sends brownie points to @adamvz and @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 565 | @joreyesl |http://www.freecodecamp.com/joreyesl
:cookie: 264 | @adamvz |http://www.freecodecamp.com/adamvz
Simon
@smnshulgan
Mar 06 2017 00:21
can i see your guy's code for this one
Adam VanZuiden
@adamvz
Mar 06 2017 00:21
uh sure let me look
whats the name of it?
Simon
@smnshulgan
Mar 06 2017 00:22
mutations
Adam VanZuiden
@adamvz
Mar 06 2017 00:25
here
function mutation(arr) {

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


  for (var n = 0; n < arr[1].length; n++) {

        if (arr[0].indexOf(arr[1][n],0) == -1 ) {
          console.log(arr[0].length);console.log(n);
        return false;   
       }
  }
  return true;
}
Simon
@smnshulgan
Mar 06 2017 00:26
whats with the console.log's
Adam VanZuiden
@adamvz
Mar 06 2017 00:26
@smnshulgan trying to debug my code because I struggled with it. :)
Simon
@smnshulgan
Mar 06 2017 00:26
ah ok
@adamvz dang thats really concise
@adamvz thanks
CamperBot
@camperbot
Mar 06 2017 00:27
smnshulgan sends brownie points to @adamvz :sparkles: :thumbsup: :sparkles:
:warning: smnshulgan already gave adamvz points
Adam VanZuiden
@adamvz
Mar 06 2017 00:27
@smnshulgan it could be cleaned up a little too!
Joseph
@revisualize
Mar 06 2017 00:28
could use .every()
Jor
@joreyesl
Mar 06 2017 00:29

@smnshulgan first one is preferred

function mutation(arr) {
  arr[0] = arr[0].toLowerCase();
  arr[1] = arr[1].toLowerCase();

  for(var i = 0; i < arr[1].length; i++){
    if(arr[0].indexOf(arr[1][i]) === -1) {
      return false;
    }
  }
  return true;
}

or what you were trying to do earlier

function mutation(arr) {
  arr[0] = arr[0].toLowerCase();
  arr[1] = arr[1].toLowerCase();

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

  return count === arr[1].length;
}
Joseph
@revisualize
Mar 06 2017 00:30
This is how I did it:
function mutation(arr) {
  var firstStr = arr[0].toLowerCase();
  var secondStr = arr[1].toLowerCase();
  for (var i = 0; i < secondStr.length; i++) {
    if (firstStr.indexOf(secondStr[i]) < 0) {
      return false;
    }
  }
  return true;
Abrar Kh.
@abrar-kh
Mar 06 2017 00:30
Hey guys need some help. I'm working on random quote machine.
I want to generate random quote every time when i clicks the button but actually once the page loaded. The quote remains the same.
$("#getMessage").on("click",function(){
  $.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(json) {
      var html = "";
      json.forEach(function(val){
      html += "<h4>Arthur: " + val.title + "</h4>";
      html += "<p>" + val.content + "</p>";

    });
    $(".message").html(html);
  });
});
Joseph
@revisualize
Mar 06 2017 00:31
Then I refactored my code to this:
function mutation(arr) {
  return arr[1].toLowerCase().split('').every(x => arr[0].toLowerCase().split('').indexOf(x) !== -1);
}
Little Joe
@iamlittlejoe
Mar 06 2017 00:32
Hi all. Question on the Factorialize a Number lesson. Why does the solution need to include: if (num === 0) { return 1; }
Joseph
@revisualize
Mar 06 2017 00:32
@iamlittlejoe I did.
@iamlittlejoe Because of how you Factorial a Number... 0 returns 1
Abrar Kh.
@abrar-kh
Mar 06 2017 00:33
@iamlittlejoe because you don't want to multiply 0 with the result. so it stops at 0.
and return 1
Adam VanZuiden
@adamvz
Mar 06 2017 00:34
I did it this way

function factorialize(num) {
  var i = 1;
  var ans = 1;
  while (i < (num+1)) {
    ans *= i;
    i++;
  }
  return ans;
}
Jor
@joreyesl
Mar 06 2017 00:34
@iamlittlejoe 0! is defined to equal 1. You will have to go ask the math guys why.
Manish Giri
@Manish-Giri
Mar 06 2017 00:35
@adamvz isn't it a bit...complex?
Little Joe
@iamlittlejoe
Mar 06 2017 00:36
Got it. So it's just basically a pre-defined rule that needs to be in place in order not to send things bonkers when multiplying?
Abrar Kh.
@abrar-kh
Mar 06 2017 00:36
yea
Adam VanZuiden
@adamvz
Mar 06 2017 00:36
@Manish-Giri yup. Not concise at all just wanted to see if I could do without an if statement
Manish Giri
@Manish-Giri
Mar 06 2017 00:37
@adamvz okay..
Rob Gibb
@RobGibb
Mar 06 2017 00:44
how to codepen
?
Adam VanZuiden
@adamvz
Mar 06 2017 00:46
@RobGibb going to have to be a little more specific
Rob Gibb
@RobGibb
Mar 06 2017 00:47
I'm trying to get help please to my code pen javascript not working
Adam VanZuiden
@adamvz
Mar 06 2017 00:48
@RobGibb post a link to it
yes rthere it is thnx , see not working ...I'm sure I made an error but where ?
help would be kind plz
innerHTML not working
Timothy Lehner
@TimLehner
Mar 06 2017 00:51
trying out p5.js, what do you think of my TicTacToe in progress so far? http://codepen.io/TimLehner/full/RpRXrZ/
Rob Gibb
@RobGibb
Mar 06 2017 00:55
JS is balls!
Timothy Lehner
@TimLehner
Mar 06 2017 00:56
@RobGibb What's getting you down?
Matt
@mypixels
Mar 06 2017 00:56
Hey guys, can I get some help with 'Nesting For Loops' pls
Rob Gibb
@RobGibb
Mar 06 2017 00:56
my problem above @TimLehner
JS
I'll be nesting fruit loops here in a minute
Manish Giri
@Manish-Giri
Mar 06 2017 00:57
@mypixels what's the problem?
Matt
@mypixels
Mar 06 2017 00:58
@Manish-Giri It's confusing me. Let me type up what I think is correct and I'll post it
Manish Giri
@Manish-Giri
Mar 06 2017 00:58
@mypixels okay
OuRyoShin
@DJQTDJ
Mar 06 2017 00:58
i watched lalaland yesterday.. but i dont like the end...->not happy ending
Joseph
@revisualize
Mar 06 2017 00:59
@RobGibb
document.getElementById("secondButton").onclick = function() {
  document.getElementById("secondParagraph").innerHTML = "Free"
}
Matt
@mypixels
Mar 06 2017 01:00

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j * i);
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
@Manish-Giri I don't think i++ is correct but I don't know what else to do
Timothy Lehner
@TimLehner
Mar 06 2017 01:00
@RobGibb Sorry I just got here, can you show me your code?
Manish Giri
@Manish-Giri
Mar 06 2017 01:00
@mypixels j * i is wrong
you want the inner loop to iterate through the length of each innermost array
Joseph
@revisualize
Mar 06 2017 01:00
@mypixels You're not modifying product but, you're returning product
Timothy Lehner
@TimLehner
Mar 06 2017 01:00
@mypixels j * i should be j++. After the closing parenthesis, the ; should be {
Manish Giri
@Manish-Giri
Mar 06 2017 01:01
@mypixels like [1,2] and [3,4], and so on
Timothy Lehner
@TimLehner
Mar 06 2017 01:01
then in that block, keep track of how product updates with product *= factor
Praveen Kaushik
@kaushikpraveen
Mar 06 2017 01:01
URGENT HELP REQUIRED!!!
Can someone PLEASE help me with a project right now??
Joseph
@revisualize
Mar 06 2017 01:01
@kaushikpraveen Nope.
Timothy Lehner
@TimLehner
Mar 06 2017 01:01
To multiply all the array elements, factor will be arr[i][j]
@kaushikpraveen Pm me
Joseph
@revisualize
Mar 06 2017 01:02
@TimLehner You just jumped on a grenade.
Timothy Lehner
@TimLehner
Mar 06 2017 01:02
or just post here if not sensitive
oh dear @revisualize hehe what am I getting myself into
@revisualize have you ever used p5.js?
Joseph
@revisualize
Mar 06 2017 01:03
Nope.
Timothy Lehner
@TimLehner
Mar 06 2017 01:03
It's quite nice for small scale apps, VERY high level
Joseph
@revisualize
Mar 06 2017 01:03
@TimLehner Don't care.
Timothy Lehner
@TimLehner
Mar 06 2017 01:03
fair enough haha
Joseph
@revisualize
Mar 06 2017 01:04
My focus is not to learn some crappy framework or library. I want to actually learn JavaScript.
Timothy Lehner
@TimLehner
Mar 06 2017 01:04
I think that is of fundamental importance, need to understand the basics first
Joseph
@revisualize
Mar 06 2017 01:05
I don't want to be one of those people that learned and devoted all of my time to Knockout.js ... Only to have it be irrelevant in 2 years
Timothy Lehner
@TimLehner
Mar 06 2017 01:06
@revisualize quite, the rapid pace of new frameworks means, once you have a good understanding of javascript fundamentals, trying to play with multiple frameworks will get you used to quickly learning to use a new framework
thats the actual skill you need
Joseph
@revisualize
Mar 06 2017 01:06
Anyone remember when Knockout.js was hot and you could get a job with it. Now.. It's meh.
@TimLehner Hmmm.. You're telling me about skills that I need but, you don't know what my goals are. ... Interesting.
Timothy Lehner
@TimLehner
Mar 06 2017 01:07
The right tool for the job, there'll always be new frameworks that are hip and new, learn to learn to use new tools
@revisualize my apologies I don't mean to tell you what to learn, I just mean in general
Joseph
@revisualize
Mar 06 2017 01:07
What if I told you I don't actually want to be a web developer.
Timothy Lehner
@TimLehner
Mar 06 2017 01:08
Then I'd question what you're doing in a javascript gitter
AJ
@DracIdea
Mar 06 2017 01:08
Hey guys, a little help with this would be much appreciated
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {

  var gear = 10;

  this.getGear = function(){

    return gear;
  };

  this.setGear = function(gear){

    myBike.setGear = (gear); //<--????

  };
};

var myCar = new Car();

var myBike = new Bike();
Joseph
@revisualize
Mar 06 2017 01:08
@TimLehner Helping people learn JavaScript.
Manish Giri
@Manish-Giri
Mar 06 2017 01:09
@DracIdea myBike.setGear = (gear); - what is this doing?
Timothy Lehner
@TimLehner
Mar 06 2017 01:09
@revisualize Me too, so sounds like we have the same goals :).
Jor
@joreyesl
Mar 06 2017 01:09
@DracIdea you will want to change the name of the parameter to something other than gear. then you can reference gear without causing confusion.
Umesi Obusor Ezekiel
@obusorezekiel
Mar 06 2017 01:09
Please i am having an issue with the lesson understanding-uninitialized-variables number 123
AJ
@DracIdea
Mar 06 2017 01:10
@joreyesl ah ok, thats ill try that. Thanks
CamperBot
@camperbot
Mar 06 2017 01:10
dracidea sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 566 | @joreyesl |http://www.freecodecamp.com/joreyesl
Manish Giri
@Manish-Giri
Mar 06 2017 01:10
@obusorezekiel you are assigning 6 to a, for example..
Joseph
@revisualize
Mar 06 2017 01:11
@TimLehner My focus for learning JavaScript is to leverage those skills to learn other programming languages and compound upon my skills of HTML / CSS. My focus is to actually migrate my career from being a rack'em stack'em IT Ops Admin to moving into an Automation DevOps role.
Manish Giri
@Manish-Giri
Mar 06 2017 01:11
you need to initialize your variables with values such that after the operations executed on them, they would have the respective values, like after a = a + 1, a would be 6.
@obusorezekiel
Timothy Lehner
@TimLehner
Mar 06 2017 01:12
@revisualize I have experience working in DevOps, if you are interested in DevOps I believe javascript won't get you there, you'll need to learn a whole host of skills. You say you are It Ops admin so I assume server stuff linux ssh etc is all trivial to you
Have you looked at tools like Gitlab-CI?
Joseph
@revisualize
Mar 06 2017 01:13
@TimLehner I haven't.
treeshadegit
@treeshadegit
Mar 06 2017 01:13
@revisualize your profile location is hilarious
Joseph
@revisualize
Mar 06 2017 01:13
@treeshadegit :D
Umesi Obusor Ezekiel
@obusorezekiel
Mar 06 2017 01:14
Thank you @Manish-Giri
CamperBot
@camperbot
Mar 06 2017 01:14
obusorezekiel sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
Mar 06 2017 01:14
@treeshadegit I actually ran out of characters. That's the max.
CamperBot
@camperbot
Mar 06 2017 01:14
:star2: 4602 | @manish-giri |http://www.freecodecamp.com/manish-giri
treeshadegit
@treeshadegit
Mar 06 2017 01:15
i'm barely into javascript now, but this is exponentially harder than the CSS/HTML/Bootstrap portions
Joseph
@revisualize
Mar 06 2017 01:15
@TimLehner You make lots of assumptions.
Timothy Lehner
@TimLehner
Mar 06 2017 01:15
@revisualize Very nice and free way to get started with automating deployment processes. You write a gitlab-ci.yml file to configure you jobs. When you push commits to certain branches, it'll start a build server on Gitlab public servers (you can attach private servers if necessary) You can then use docker images and apt-get mvn pkg whatever necessary
@revisualize such as?
Joseph
@revisualize
Mar 06 2017 01:17
@TimLehner "if you are interested in DevOps I believe javascript won't get you there" ... :|
@TimLehner "You say you are It Ops admin so I assume server stuff linux ssh etc is all trivial to you" ... :|
Timothy Lehner
@TimLehner
Mar 06 2017 01:18
@revisualize you have not worked with a terminal?
AJ
@DracIdea
Mar 06 2017 01:19
@joreyesl That worked great! Thanks agian
CamperBot
@camperbot
Mar 06 2017 01:19
dracidea sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: dracidea already gave joreyesl points
@TimLehner I work in Windows environments.
PowerShell.
Timothy Lehner
@TimLehner
Mar 06 2017 01:20
Right so powershell putty etc basically the same
you understand about using computers with text only
you can connect to other servers with putty
Joseph
@revisualize
Mar 06 2017 01:21
I know how to use PuTTy
I'm a Senior Network Systems Administrator.
Timothy Lehner
@TimLehner
Mar 06 2017 01:21
of course you do, you're an It Ops admin, hence me assuming that stuff was trivial for you
either that or, quite frankly, you shouldn't have your job
Joseph
@revisualize
Mar 06 2017 01:22
Last Week I was connected to five Layer 3 switches configuring VLANs and ACLs on our Cisco equipment.
Timothy Lehner
@TimLehner
Mar 06 2017 01:22
Sounds horrendous, @revisualize understand I am not trying to be disrespectful to you in any way
Joseph
@revisualize
Mar 06 2017 01:23
Look here's the stand point that I'm coming from.
I taught myself HTML and CSS back in 1997.
I'm using JavaScript to learn syntax and programming methodologies that are transferable.
Timothy Lehner
@TimLehner
Mar 06 2017 01:24
and thats great
Joseph
@revisualize
Mar 06 2017 01:24
I took my JS skills and was able to carry them over to the code that I write with PowerShell.
I'm able to take the skills that I'm learning from JS to apply them to automating switch configs.
Timothy Lehner
@TimLehner
Mar 06 2017 01:25
to be honest I reckon your JS skills benefitted more from your powershell skills than the other way round, all same concepts
I mean it all helps each other
Joseph
@revisualize
Mar 06 2017 01:25
I'm also able to take the logic that I'm learning and apply it to Bash.
Or Python.
I still suck at Python.
But, the core logic is the same.
Pathrinathan (Pat). P
@pathmanp
Mar 06 2017 01:26
@revisualize @TimLehner can one of u help me out with JS Objects
Timothy Lehner
@TimLehner
Mar 06 2017 01:26
Python can make alot of things that bash makes cumbersome easy
Sure @pathmanp what's the problem?
Joseph
@revisualize
Mar 06 2017 01:26
@pathmanp What's the name of the challenge and what have you done?
Pathrinathan (Pat). P
@pathmanp
Mar 06 2017 01:26
remember this: Make Object Properties Private

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

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

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

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

var Bike = function() {

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

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

this.setGear = function(){
return gear;

};

};

var myCar = new Car();

var myBike = new Bike();

Seth
@sethdcd
Mar 06 2017 01:27

getCurrentPosition() and watchPosition() no longer work on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.

any ideas on this because if I switch over to https then the open weather api will not work :/

Pathrinathan (Pat). P
@pathmanp
Mar 06 2017 01:27
gear =4, but what If I want gear to return 4 or 3 or 1
Joseph
@revisualize
Mar 06 2017 01:28
@TimLehner I do know that I need to learn a vastly different skill set if I do want to move into Systems Automation. But, I'm starting somewhere and using the skills to help guide my other knowledge. While the skills may not be the best. It makes things easier if I have some sort of a foundation to leverage.
Timothy Lehner
@TimLehner
Mar 06 2017 01:28
@Seth yes switch to https, and then change all the url for get requests to https
Joseph
@revisualize
Mar 06 2017 01:28
@pathmanp You need to add a parameter to setGear and then use that parameter to change the gear
Pathrinathan (Pat). P
@pathmanp
Mar 06 2017 01:28
Car is codecamp example. I'm suppose to solve the bike example
Timothy Lehner
@TimLehner
Mar 06 2017 01:29
for weathermap, prepend the request with https://cors-anywhere.herokuapp.com/url/path/to/api/call
Pathrinathan (Pat). P
@pathmanp
Mar 06 2017 01:30
how do i set parameter to

this.getGear = function(){

};

setGear should return diffrent values
Timothy Lehner
@TimLehner
Mar 06 2017 01:31
@pathmanp the function needs to be passed an argument, then set value with that argument
Seth
@sethdcd
Mar 06 2017 01:33
@TimLehner i dont believe the open weather api works with https though unless you pay for it, at least that is what someone told me the other day :/
Failed to load resource: net::ERR_CONNECTION_REFUSED @TimLehner
Joseph
@revisualize
Mar 06 2017 01:34
@pathmanp getGear should just return the gear
Timothy Lehner
@TimLehner
Mar 06 2017 01:34
@sethdcd could you show me the codepen?
Joseph
@revisualize
Mar 06 2017 01:34
@pathmanp setGear is the one that needs a parameter
Timothy Lehner
@TimLehner
Mar 06 2017 01:37

@sethdcd
Step 1) Go to https://codepen.io/sethdcd/pen/oZxGoO?editors=1010
Step 2) Change

$.getJSON("https://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + long + "&appid=410463b3935acea56c8171825dbb4440&units=imperial",

to

$.getJSON("https://cors-anywhere.herokuapp.com/api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + long + "&appid=410463b3935acea56c8171825dbb4440&units=imperial",
Adam
@GoingAllTheWayUp
Mar 06 2017 01:39
Is it possible to .map() over an argument?
Timothy Lehner
@TimLehner
Mar 06 2017 01:39
@GoingAllTheWayUp What do you mean?
Adam
@GoingAllTheWayUp
Mar 06 2017 01:40
sorry arguments
Timothy Lehner
@TimLehner
Mar 06 2017 01:40
What are you trying to do? by .map()
Adam
@GoingAllTheWayUp
Mar 06 2017 01:41
arguments.map().reduce();
Timothy Lehner
@TimLehner
Mar 06 2017 01:41
ahh I'm not sure
I know whilst arguments can be accessed like an array with [i], they are not arrays, but a special object
Adam
@GoingAllTheWayUp
Mar 06 2017 01:42
ok
Timothy Lehner
@TimLehner
Mar 06 2017 01:42
If you make an array from the arguments, then .map should work as expected
Adam
@GoingAllTheWayUp
Mar 06 2017 01:42
ok .from()?
Timothy Lehner
@TimLehner
Mar 06 2017 01:42
try it, if not explicitly loop over arguments and build one
Adam
@GoingAllTheWayUp
Mar 06 2017 01:42
ok will do
Timothy Lehner
@TimLehner
Mar 06 2017 01:43
good luck
@sethdcd Did you have any luck?
Jor
@joreyesl
Mar 06 2017 01:45
@GoingAllTheWayUp you can do Array.from(arguments) or use ES6 spread operator[...arguments]
Adam
@GoingAllTheWayUp
Mar 06 2017 01:46
I am useing .from(), right now but am aware of the spread operator.
Steven
@LemonTruth
Mar 06 2017 01:49
ayy, I need some help with something
someone pls help
Joseph
@revisualize
Mar 06 2017 01:51
@LemonTruth Remove the space
@LemonTruth You have a space after \n remove it.
Solved.
Steven
@LemonTruth
Mar 06 2017 01:52
WHAT???
I could have sworn I already tried that xD
well, nonetheless, you've solved my problem. Thanks :) @revisualize
CamperBot
@camperbot
Mar 06 2017 01:53
lemontruth sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3434 | @revisualize |http://www.freecodecamp.com/revisualize
justinmaines
@justinmaines
Mar 06 2017 01:56
hey guys, I need some help! I am on the Intermediate Algorithm Challenge, Smallest Common Multiple, and I almost have the solution. Everything passes except the lest test. When the last test goes through, it turns my while loop into an infinite loop. No other values do this. thanks!
well all large numbers break the loop. How can I fix this?
Timothy Lehner
@TimLehner
Mar 06 2017 01:58
@justinmaines Are you computing LCM by working out prime factors?
justinmaines
@justinmaines
Mar 06 2017 01:59
here's my code
var x = true;
var leastCommonMultiple = 0;
while(x){
leastCommonMultiple++;
for(var j = newArr[0]; j <= newArr[newArr.length - 1]; j++){
if (leastCommonMultiple % j !== 0){
break;
} else if (j == newArr[newArr.length -1]){
x = false;
}
}
newArr is an array created from the range given
Jor
@joreyesl
Mar 06 2017 02:06
@justinmaines you are probably timing out when the numbers get very large. Instead of increasing leastCommonMultiple by 1, you should increased it by the largest number in the range. The LCM has to be a multiple of that number.
Ex: [1,5] Why would I check 6,7,8,etc.? i should instead check 10,15,20,etc.
Cory Bowles
@cbconsulting
Mar 06 2017 02:07

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

i++;

is the equivalent of

i = i + 1;

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

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

Hint
Learn more about Arithmetic operators - Increment (++).

var myVar = 87;

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

i can not get this to accept the code after is say's 88 myVar = 88
in output box
anyone know how diagnose this solution
Never mind i figured it out after digging for solution on git hub.
Uros Tadic
@urketadic
Mar 06 2017 02:17
i got it fixed
Joseph
@revisualize
Mar 06 2017 02:18

@truepalyer6

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.

@truepalyer6 You have the answer.. You just need to remove two useless lines.
Bigyan Karki
@bigyankarki
Mar 06 2017 02:22

function dropElements(arr, func) {
  // Drop them elements.
  var cut = arr.findIndex(func);
  return arr.slice(cut, arr.length);
}

dropElements([1, 2, 3, 4], function(n) {return n > 5;});
why does this code returns 4?
justinmaines
@justinmaines
Mar 06 2017 02:22
@joreyesl so what can I change in my code? Do I need to complete ditch what I have?
Paul Debevec
@PaulDebevec
Mar 06 2017 02:28

Hey I'm struggling with the && operator.
This is what I have...
if (val <= 50 && val >= 25); {
return "Yes";
}
return "No";

My problem is when I test it it's returning all my tests as yes.

What am I doing wrong?
Bigyan Karki
@bigyankarki
Mar 06 2017 02:31
@PaulDebevec you are giving a variable two values to check...
what are you trying to do?
Paul Debevec
@PaulDebevec
Mar 06 2017 02:32
I'm trying to test different values from 0 - 80 and have it return whether or not it's between 25 & 50
snbest
@snbest
Mar 06 2017 02:33
can somebody help me out with profile lookup in js?
Bigyan Karki
@bigyankarki
Mar 06 2017 02:33
maybe you can try if( val >=25 && val <=50)
Paul Debevec
@PaulDebevec
Mar 06 2017 02:35
@bigyankarki Doesn't appear to be working that way either... RIP
I appreciate the help though :) I'll keep working on it.
Bigyan Karki
@bigyankarki
Mar 06 2017 02:42
:D good luck @PaulDebevec :)
Paul Debevec
@PaulDebevec
Mar 06 2017 02:43
@bigyankarki Thanks! I appreciate the assistance.
CamperBot
@camperbot
Mar 06 2017 02:43
pauldebevec sends brownie points to @bigyankarki :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @bigyankarki |http://www.freecodecamp.com/bigyankarki
David Shin
@datadaveshin
Mar 06 2017 02:44
@PaulDebevec you have a semicolon after (val <= 50 && val >= 25) , you need to remove it
Nik Jaggers
@Jaggers93
Mar 06 2017 02:44
a should be assigned to b with = . How do i do this ?
Paul Debevec
@PaulDebevec
Mar 06 2017 02:47
@datadaveshin That did it - Thank you so much! I can't believe I missed that.
CamperBot
@camperbot
Mar 06 2017 02:47
pauldebevec sends brownie points to @datadaveshin :sparkles: :thumbsup: :sparkles:
:cookie: 51 | @datadaveshin |http://www.freecodecamp.com/datadaveshin
David Shin
@datadaveshin
Mar 06 2017 02:48
@Jaggers93 a = b; ???
No problem @PaulDebevec
Nik Jaggers
@Jaggers93
Mar 06 2017 02:54
does it need to be var a=b; ?? I did that and its not working
Nathan Vu
@NathanVu
Mar 06 2017 02:54
This should be basic. MyVar should equal to 88

I have this so far
var myVar = 87;

// Only change code below this line
myVar = myVar i++

what am I doing wrong>
Joseph
@revisualize
Mar 06 2017 02:57

@NathanVu

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.

Raul Rodriguez
@SoldadoNieve
Mar 06 2017 02:57

Can anyone tell me why I have to use the brackets instead of parenthesis in 'Testing Objects or Properties' :
'''
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

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

CamperBot
@camperbot
Mar 06 2017 02:57
:bulb: to format code use backticks! ``` more info
Joseph
@revisualize
Mar 06 2017 02:58
@SoldadoNieve What?
@SoldadoNieve Are you asking why you're dong myObj[checkProp] instead of myObj(checkProp) ?
Raul Rodriguez
@SoldadoNieve
Mar 06 2017 02:59
@revisualize yes, that. thank you for simplifying that for me.
CamperBot
@camperbot
Mar 06 2017 02:59
soldadonieve sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3435 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 06 2017 02:59
@SoldadoNieve Because myObj isn't a function.
@SoldadoNieve How do you access object properties using variables?
David Shin
@datadaveshin
Mar 06 2017 03:01
@Jaggers93 I can't see the context, but if the variable hasn't been declared yet, then yes, it needs var or let in front of it. Perhaps it's backwards... assign a to b, so put b on the left hand side
Joseph
@revisualize
Mar 06 2017 03:02
@Jaggers93 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.
Raul Rodriguez
@SoldadoNieve
Mar 06 2017 03:04
Thanks a bunch @revisualize ! I really appreciate you helping me out with that one! I'm still trying to get a grip on some of these fundamentals.
CamperBot
@camperbot
Mar 06 2017 03:04
soldadonieve sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: soldadonieve already gave revisualize points
Nathan Vu
@NathanVu
Mar 06 2017 03:11
@revisualize Still can't figure it out

var myVar = 87;

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

myVar should equal 88
myVar = myVar should be changed
Use the ++ operator
Do not change code above the line
Joseph
@revisualize
Mar 06 2017 03:13

@NathanVu

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.

@NathanVu If I have

var num = 7;

How did I make num become 8?

Nathan Vu
@NathanVu
Mar 06 2017 03:14
@revisualize you would increment by using the ++operator
Joseph
@revisualize
Mar 06 2017 03:14
@NathanVu I want an EXACT answer.
Nathan Vu
@NathanVu
Mar 06 2017 03:15
var num =num +1; @revisualize
Joseph
@revisualize
Mar 06 2017 03:15
@NathanVu That is not what I did.
@NathanVu I didn't ask how do.. I asked how did.
@NathanVu I showed you all of the code needed to answer my question.
@NathanVu Would you like for me to show you the code and ask my question again?
Nathan Vu
@NathanVu
Mar 06 2017 03:18
@revisualize Working on it!
Joseph
@revisualize
Mar 06 2017 03:20
@NathanVu What are you looking at right now?
Clearly, not looking at chat.
Nathan Vu
@NathanVu
Mar 06 2017 03:22
Hey @revisualize I got it. I was overthinking it the answer was myVar++;
Joseph
@revisualize
Mar 06 2017 03:23
@NathanVu Grats
CamperBot
@camperbot
Mar 06 2017 03:28
:bulb: to format code use backticks! ``` more info
:bulb: to format code use backticks! ``` more info
Ryan Steen
@Rsteen76
Mar 06 2017 03:31
  var test = Object.keys(source);

  for(var i = 0; i < collection.length; i++) {
    if (collection[i].test == source[0].test){
      arr[i] = collection[i];
    }
  }
CamperBot
@camperbot
Mar 06 2017 03:31
:bulb: to format code use backticks! ``` more info
Ryan Steen
@Rsteen76
Mar 06 2017 03:32
I was wondering why this does not work. Test is undefined.
Andrew Charlebois
@andrewchar
Mar 06 2017 03:42
@revisualize still saving the day around these parts eh :P
Dominic Jones
@dhjfoodstech
Mar 06 2017 03:50

I need help, I put some javascript from fcc challenge answer into the script section of codepen, I'm guessing something is missing I can't get fahrenheit to print in the console
function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

fahrenheit = celsius*(9/5)+32;
// Only change code above this line
return fahrenheit;
}

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

Andrew Charlebois
@andrewchar
Mar 06 2017 03:52
@dhjfoodstech if you want to see the result you'll need to do console.log(fahrenheit);
before the return statement
Dominic Jones
@dhjfoodstech
Mar 06 2017 03:53
hmm brb
@andrewchar thanks alot I was writing it outside the function
CamperBot
@camperbot
Mar 06 2017 03:56
dhjfoodstech sends brownie points to @andrewchar :sparkles: :thumbsup: :sparkles:
:cookie: 457 | @andrewchar |http://www.freecodecamp.com/andrewchar
Bruno Esparza
@baesparza
Mar 06 2017 03:57
hello, i need help with a problem, can someones check it up?

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

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

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

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

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

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

this is the task
Dominic Jones
@dhjfoodstech
Mar 06 2017 03:59
my follow up question is where was it returning fahrenheit too?
Andrew Charlebois
@andrewchar
Mar 06 2017 04:00
@dhjfoodstech not sure I understand your question
Bruno Esparza
@baesparza
Mar 06 2017 04:02
i couldn't do it, i pass it.
https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(name%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20contacts.length%3B%20i%2B%2B)%20%7B%0A%20%20%20%20if%20(contacts%5Bi%5D.firstName%20%3D%3D%20name)%20%7B%0A%20%20%20%20%20%20if%20(contacts%5Bi%5D.hasOwnProperty(prop))%20%7B%0A%20%20%20%20%20%20%20%20return%20contacts%5Bi%5D%5Bprop%5D%3B%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20return%20%22No%20such%20property%22%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20return%20%22No%20such%20contact%22%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Kristian%22%2C%20%22lastName%22)%3B%0A
can someone help me?
Dominic Jones
@dhjfoodstech
Mar 06 2017 04:04
@andrewchar I always thought when it says return variable it would print somewhere
Andrew Charlebois
@andrewchar
Mar 06 2017 04:05
nope. return is just sending the information back. console.log is to print it so you can check things out
@dhjfoodstech return statement stops the function from running at the time its called and returns the value that you tell it to.
Dominic Jones
@dhjfoodstech
Mar 06 2017 04:11
@andrewchar I think I understand, but I must say I'm a little ahead of myself. I'm excited because as a chef this is something I could use.
Andrew Charlebois
@andrewchar
Mar 06 2017 04:12
all good. i was brand new to coding last year using fcc to learn
Dominic Jones
@dhjfoodstech
Mar 06 2017 04:17
Awesome i'm at 6 mnths I think, not as consistant as I would like but thats only because of work. Are you in front end work?
Andrew Charlebois
@andrewchar
Mar 06 2017 04:17
yeah, front-end developer
Jorge Taylor
@BigBankElit3
Mar 06 2017 04:17
im stuck guys what am i doing wrong? function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for( var i = 0; i< arr.length; i++){
for(var j = 0; j < arr[i].length; j++) {
console.log(arr[i][j]);
product *= arr[i][j];}
// Only change code above this line
return product;
}
}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Andrew Charlebois
@andrewchar
Mar 06 2017 04:18
 function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for( var i = 0; i< arr.length; i++){
for(var j = 0; j < arr[i].length; j++) {
console.log(arr[i][j]);
product *= arr[i][j];}
// Only change code above this line
return product;
}
}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Dominic Jones
@dhjfoodstech
Mar 06 2017 04:21
arrays its where I'm actually stuck on fcc, so i'm doing all my js challenges over because I definitely missed something lol
Andrew Charlebois
@andrewchar
Mar 06 2017 04:21
@BigBankElit3 whats the challenge name
Jorge Taylor
@BigBankElit3
Mar 06 2017 04:22
Nesting For Loops
@andrewchar
Andrew Charlebois
@andrewchar
Mar 06 2017 04:23
@BigBankElit3 one of your closing brackets are in the wrong place
@andrewchar you have one to many after the return
indenting your code properly can eliminate those kinds of problems. like this.
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {
      product *= arr[i][j]; 
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Jorge Taylor
@BigBankElit3
Mar 06 2017 04:28
wow thanks idk how i missed it @andrewchar
CamperBot
@camperbot
Mar 06 2017 04:28
bigbankelit3 sends brownie points to @andrewchar :sparkles: :thumbsup: :sparkles:
:cookie: 458 | @andrewchar |http://www.freecodecamp.com/andrewchar
Andrew Charlebois
@andrewchar
Mar 06 2017 04:29
happy coding :)
Nathan Vu
@NathanVu
Mar 06 2017 04:34
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
I have this as an answer var remainder; 11%3;
what am I doing wrong here?
Andrew Charlebois
@andrewchar
Mar 06 2017 04:36
can you post your full code
oh
you put ; instead of =
Nathan Vu
@NathanVu
Mar 06 2017 04:38
@andrewchar ahh that did the job. Thanks Andrew!
CamperBot
@camperbot
Mar 06 2017 04:38
nathanvu sends brownie points to @andrewchar :sparkles: :thumbsup: :sparkles:
:cookie: 459 | @andrewchar |http://www.freecodecamp.com/andrewchar
Andrew Charlebois
@andrewchar
Mar 06 2017 04:38
np
Edgar Pan
@edgaryp
Mar 06 2017 04:39
Hi anybody familiar with JS modular pattern?
Andrew Charlebois
@andrewchar
Mar 06 2017 04:40
Module Pattern*
what about it
Eric Chung
@chungeric
Mar 06 2017 04:41
Anyone know why they got rid of the advanced date ranges challenge?
grantknaver
@grantknaver
Mar 06 2017 04:43
anyone have any ideas on this curiosity.
Everything is functioning perfectly on my calculator assignment, but I have snippet of redundant code, and I'm trying to streamline it.
I created a function to get rid of the redundancy, but to no avail. Anyone have any ideas as to why this function is not working?
Edgar Pan
@edgaryp
Mar 06 2017 04:43
Hi Andrew, I could not figure out why my variable result does not update. I think line 19 is the problem.
http://codepen.io/edgaryp/pen/yMeRLX?editors=1111
grantknaver
@grantknaver
Mar 06 2017 04:44
/*
    function clearField(targetField){ //>>>>>>>>>>>>>>>>>>>>>>>>clearField()
      if (targetField ==='0') {
              targetField='';
          }
    }
    */

        if (counter==='0') {// duplicate code>>>>>>>>>>>>>>>>>>>>>>Use clearField to streamline
            counter='';
        } //if (counter==='0')
    else if (cosmeticDisplay ==='0') {//duplicate code>>>>>>>>>>>>>>>>>>>>>>Use clearField to streamline
            cosmeticDisplay='';
        } //if (cosmeticDisplay==='0')
The the commented out function is obviously what is not working. The if statements work fine, but are very efficient.
here's a link to the project.
https://codepen.io/GrantKnaver/pen/aJZKBE?editors=1010
Edgar Pan
@edgaryp
Mar 06 2017 04:45
@grantknaver i am doing this assessment as well lol
grantknaver
@grantknaver
Mar 06 2017 04:46
lol copy cat lol
its fun
didn't take me to long in comparison to some of the previous assignments
I dont wanna ruin it for you, anyone else have any ideas
KharmaZ
@KharmaZ
Mar 06 2017 04:49
Hey so I'm having an issue on the string section of JS heres my code
var myStr = "FirstLine
\n\SecondLine\
\rThirdLine";
it keeps saying Its a bad escaping of EOL
Not too sure what that means..
Andrew Charlebois
@andrewchar
Mar 06 2017 04:53
@edgaryp remove the render in your updateResult and remove .bind(this) in your bindevent
@edgaryp
bindEvents: function() {
        this.$button.on("click", this.updateResult)
        // console.log(this);
      },
      updateResult: function() {
        result = $(this).text();
        console.log(result);
        // this.render();
      },
actually just the .bind(this) that solves the problem of not getting anything
vaishnavi prasad
@vaishnaviprasad
Mar 06 2017 05:02
Hi guys
Edgar Pan
@edgaryp
Mar 06 2017 05:02
@andrewchar it works thanks. So $(this) is already pointing to $button so .bind() is not required. Am I right?
CamperBot
@camperbot
Mar 06 2017 05:02
edgaryp sends brownie points to @andrewchar :sparkles: :thumbsup: :sparkles:
:cookie: 460 | @andrewchar |http://www.freecodecamp.com/andrewchar
vaishnavi prasad
@vaishnaviprasad
Mar 06 2017 05:02
i need to go to another page onthe click of a button..
how do I do it?
Andrew Charlebois
@andrewchar
Mar 06 2017 05:03
@edgaryp right. your already stating that .this is the button being clicked
grantknaver
@grantknaver
Mar 06 2017 05:04
any ideas
Andrew Charlebois
@andrewchar
Mar 06 2017 05:06
@vaishnaviprasad you might be better to google how to either make an inline function in a button or make an anchor tag aka. (<a href="#">next page</a>) and set a function to fire when its clicked
vaishnavi prasad
@vaishnaviprasad
Mar 06 2017 05:07
ty @andrewchar
CamperBot
@camperbot
Mar 06 2017 05:07
vaishnaviprasad sends brownie points to @andrewchar :sparkles: :thumbsup: :sparkles:
:cookie: 461 | @andrewchar |http://www.freecodecamp.com/andrewchar
Avery Biskup
@fraknard
Mar 06 2017 05:13
What's everyone's line count for the mutations challenge? I had to take up 30.
Zachary Orona-Calvert
@TheTRUEHoohah
Mar 06 2017 05:13
how do i do the palindromes im lost but i dont want to cheat
Avery Biskup
@fraknard
Mar 06 2017 05:14
Take a walk outside and think about what needs to happen.
How could you modify a string so that before and after you change something about it they either the same or not the same?
Zachary Orona-Calvert
@TheTRUEHoohah
Mar 06 2017 05:15
using the .replace?
Avery Biskup
@fraknard
Mar 06 2017 05:16
They eliminates any unwanted characters, and leaves you with the letters.
Once you only have the letters, how could you test if sides of the strings are the same?
Zachary Orona-Calvert
@TheTRUEHoohah
Mar 06 2017 05:17
the .filter
Avery Biskup
@fraknard
Mar 06 2017 05:17
This took me a long time, but struggling for hours and hours is really good. Just relax, think, take breaks, and test test test.
Think about .reverse() that's what I used.
Johnny
@jtan3
Mar 06 2017 05:19
@TheTRUEHoohah http://regexr.com/ to learn more about regex
ssharma1011
@ssharma1011
Mar 06 2017 05:23

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

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

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

what's wrong with the above code?
Manish Giri
@Manish-Giri
Mar 06 2017 05:24
@ssharma1011 one, you should be returning something, instead of console.log
ssharma1011
@ssharma1011
Mar 06 2017 05:24
that's not an issue..
Manish Giri
@Manish-Giri
Mar 06 2017 05:25
two, checkProp is a variable
ssharma1011
@ssharma1011
Mar 06 2017 05:25
i did it just for testing purpose
Manish Giri
@Manish-Giri
Mar 06 2017 05:25
so you need to use [ ] notation
Vikram
@vikramnr
Mar 06 2017 05:25
var myStr; // Change this line
myStr="FirstLine "\n\ \"SecondLine"\ \r"ThirdLine"; What is that I'm doing wrong??
ssharma1011
@ssharma1011
Mar 06 2017 05:26
@Manish-Giri thanks
CamperBot
@camperbot
Mar 06 2017 05:26
ssharma1011 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4612 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ken Haduch
@khaduch
Mar 06 2017 05:26
@vikramnr - no internal quotation marks, no internal whitespaces. If you post your code surrounded with ` backquotes, it will show up better.
Manish Giri
@Manish-Giri
Mar 06 2017 05:26
@khaduch :wave:
Ken Haduch
@khaduch
Mar 06 2017 05:26
@Manish-Giri - hey there, Manish!
Manish Giri
@Manish-Giri
Mar 06 2017 05:26
@khaduch how's it going?
Ken Haduch
@khaduch
Mar 06 2017 05:26
@Manish-Giri - okay, how about you?
Manish Giri
@Manish-Giri
Mar 06 2017 05:27
@khaduch doing good too
thx
Vikram
@vikramnr
Mar 06 2017 05:27
@khaduch Okay :+1:
grantknaver
@grantknaver
Mar 06 2017 05:28
any ideas guys the function aint firing right
Tricia
@patricia07
Mar 06 2017 05:34
is there something wrong?
var myStr = "I am a \"double quoted \string inside \"double quotes\".";
Ken Haduch
@khaduch
Mar 06 2017 05:35
@patricia07 - it doesn't look quite right - what is this supposed to look like - the final result, I mean?
@patricia07 - maybe you're just missing a quote after the first \"double quoted\" - it is hard to tell unless you post your quotes between backquotes - the ` character
@patricia07 - there should be six quotation marks in the string, four of them should be preceded by the \ - and look like this: \"
just copy the string that the show in the red text, and precede the interior quotation marks with the \ and it should go...
Chaitya Shah
@Chaitya62
Mar 06 2017 05:40
Can any one suggest a better alternative to pouchDB quick search for a web extension that can scale
Zachary Orona-Calvert
@TheTRUEHoohah
Mar 06 2017 05:41

function palindrome(str) {
// Good luck!

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

if ( str == newPalindrome){
return true;
}

else if ( str != newPalindrome){
return false;

}}

palindrome("eye");

im doing the palindrome assignment. What have I done wrong
Chaitya Shah
@Chaitya62
Mar 06 2017 05:41
Can any one suggest a better alternative to pouchDB quick search for a web extension that can scale the database is pouchDB only I need a better alternative to search
Johnny
@jtan3
Mar 06 2017 05:51
@TheTRUEHoohah you need to get rid of all the symbol characters
vaishnavi prasad
@vaishnaviprasad
Mar 06 2017 05:52
Hi guys
I need to display the database(mysql) on the web page(html) using javascript /nodejs only
How can I do this?
Please no PHP
MD. ABDULLAH AR RAQIB
@arraqib
Mar 06 2017 05:55
help 'Sum All Primes'

help 'Sum All Primes'.
```
function sumPrimes(num) {
var arr = [];
var flag = true;

for(var i = 2; i <= num; i++){
for(var j = 2; j < i; j++){
if(i % j === 0){
flag = false;
break;
}
}

if(flag === true){
  arr.push(i);
}

}

return arr.reduce(function(prev, curr){
return prev + curr;
});

}

sumPrimes(10);
``

MD. ABDULLAH AR RAQIB
@arraqib
Mar 06 2017 06:01
Please, help 'Sum All Primes'
function sumPrimes(num) {
  var arr = [];
  var flag = true;

  for(var i = 2; i <= num; i++){
    for(var j = 2; j < i; j++){
      if(i % j === 0){
        flag = false;
        break;
      }
    }

    if(flag === true){
      arr.push(i);
    }
  }


  return arr.reduce(function(prev, curr){
    return prev + curr;
  });

}

sumPrimes(10);
adisesharao
@adisesharao
Mar 06 2017 06:03
please help i think i wrote perfectly but it is not working
in Escape Sequences in Strings
Joseph
@revisualize
Mar 06 2017 06:05
@adisesharao What have you written?
adisesharao
@adisesharao
Mar 06 2017 06:07
var myStr = "FirstLine\n\SecondLine\\r\nThirdLine";
Joseph
@revisualize
Mar 06 2017 06:07
@adisesharao There is no newline after SecondLine
adisesharao
@adisesharao
Mar 06 2017 06:10
if it is wrong at least in my output the second line should go to the another line but i won't go my output is in single line only
Joseph
@revisualize
Mar 06 2017 06:10
@adisesharao What? Show me
@adisesharao What do you have now that you deleted the newline after SecondLine?
NaveenRathor
@NaveenRathor
Mar 06 2017 06:27
what's wrong in my code

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

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

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

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

Joseph
@revisualize
Mar 06 2017 06:28
@NaveenRathor Your function has declared and initialized the variable result to "". You are not modifying result and your function is returning result. Ergo, you're returning "". You need to modify result to be the value of the property from the object that you created.
adisesharao
@adisesharao
Mar 06 2017 06:34
mr joseph my code working but output is wrong
see this
NaveenRathor
@NaveenRathor
Mar 06 2017 06:34
@revisualize i'm not understand
adisesharao
@adisesharao
Mar 06 2017 06:34
var myStr = "FirstLine\n\SecondLine\\rThirdLine";
var myStr = "FirstLine\n\SecondLine\\rThirdLine";
Joseph
@revisualize
Mar 06 2017 06:42
@adisesharao So, that worked?
badalsaibo
@heyDante
Mar 06 2017 06:42
@adisesharao backslash is not inserted after FirstLine
adisesharao
@adisesharao
Mar 06 2017 06:42
ya but output is not getting in 3 lines
Markus Kiili
@Masd925
Mar 06 2017 06:43
@revisualize Did the this business inside the constructor become clear?
badalsaibo
@heyDante
Mar 06 2017 06:44
@adisesharao FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
Just replace the highlighted words with their respected escape sequence.
adisesharao
@adisesharao
Mar 06 2017 06:45
k i will try badal
Joseph
@revisualize
Mar 06 2017 06:46
@adisesharao Look, I can see what you input. I can quote your text and see what you actually entered into the chat window.
@Masd925 Not really. I'm still a little confused by it. But, I'm trying to learn.
Markus Kiili
@Masd925
Mar 06 2017 06:50
@revisualize In order to get it, you need to know that when you do new constr(), the engine makes a new object {} and puts it as value of this when the constructor function is run, and returns the value of this at the end.
You need to know what happens under the hood when a new object is created, in order to understand what a certain constructor does.
Karthik Nallasivan
@furball514
Mar 06 2017 06:58
hey guys i keep getting an error of cannot read setstate of undefined or null on line 55 of js in this pen http://codepen.io/furball/pen/LWNMwr
i tried eveyrhting i vould think of
pls help
Phuc Le
@phuchle
Mar 06 2017 07:01

hi all,

can anybody explain to me what is going on in my code? I tried debugging in node and for the first call, the function only recognizes [1,3,2] as an argument and not the rest, but it works fine for the 2nd call.


function flatten(arr) {
  var arguments = [...arr];

  return arguments.reduce(function(acc, val) {
    return acc.concat( val);
  }, []);
}

flatten([1, 3, 2], [1, [5]], [2, [4]]); // returns [1,3,2]
flatten([[0, 1], [2, 3], [4, 5]]); // returns [0,1,2,3,4,5]
Rohit Sachdeva
@ehrohit
Mar 06 2017 07:02

function palindrome(str) {
// Good luck!
var inputstr=str.toLowerCase();
inputstr= inputstr.replace(/[^\w\s ]/gi, '');
inputstr=inputstr.replace(/\s/g, "") ;
inputstr=inputstr.replace(/
/g, '');
console.log("Input String is "+ inputstr);
var inpArr=[];
var revStr=[];
inpArr= inputstr.split("");
revStr=inpArr.reverse();
var revString= revStr.join('');
console.log("Reverse of String is "+revString);

var comp = inputstr.localeCompare(revString);
console.log("Computed Value is "+ comp);

if (comp===0)
{
return true;}
else
{return false;}
}

palindrome("_eye");
how to join the three replace staements in one ? is it just coma seperated

Markus Kiili
@Masd925
Mar 06 2017 07:06
@phuchle Argument arr only catches the first passed argument from the function call.
adisesharao
@adisesharao
Mar 06 2017 07:07
how i will using compound assignment operator in Appending Variables to Strings because both variables having different names
Markus Kiili
@Masd925
Mar 06 2017 07:07
On the second test call, there is only one argument.
Rohit Sachdeva
@ehrohit
Mar 06 2017 07:07
anybody?
Phuc Le
@phuchle
Mar 06 2017 07:09
@Masd925 thanks I figured it out based on that :)
CamperBot
@camperbot
Mar 06 2017 07:09
phuchle sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3518 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Mar 06 2017 07:11
@ehrohit One regexp with \W and _ is enough. You can compare with just ===
Rohit Sachdeva
@ehrohit
Mar 06 2017 07:12
@Masd925 I don't know why it wasn't running until I put the the third regexp
also how to join all the regexp
Markus Kiili
@Masd925
Mar 06 2017 07:15
@ehrohit You can use [ ] with \W and _
That will target all the non-alphanumerics.
Rohit Sachdeva
@ehrohit
Mar 06 2017 07:16
Cool and how to colate them all consditions in single expression
@Masd925
Markus Kiili
@Masd925
Mar 06 2017 07:17
@ehrohit str = str.replace(/[\W_]/g,"")
Rohit Sachdeva
@ehrohit
Mar 06 2017 07:19
cool @Masd925 will this resolve all the alphanumerics &white space a
Markus Kiili
@Masd925
Mar 06 2017 07:19
Yes.
Only keeps letters and numbers.
Rohit Sachdeva
@ehrohit
Mar 06 2017 07:23
@Masd925 thanks , just last question though
CamperBot
@camperbot
Mar 06 2017 07:23
ehrohit sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3519 | @masd925 |http://www.freecodecamp.com/masd925
Rohit Sachdeva
@ehrohit
Mar 06 2017 07:24
inputstr= inputstr.replace(/[^\w\s ]/gi, '',/\s/g, "",/_/g, ');
Is it possible to write something like this and how
@Masd925
because when I try this the logic stops working
Joseph
@revisualize
Mar 06 2017 07:26

@ehrohit What are you trying to accomplish with this:

inputstr= inputstr.replace(/[^\w\s ]/gi, '',/\s/g, "",/_/g, ');

Rohit Sachdeva
@ehrohit
Mar 06 2017 07:27
@revisualize , I am trying to remove the white spaces , _ and alphanumeric characters from the string
Eric Chung
@chungeric
Mar 06 2017 07:29
Hey guys, having a little trouble wrapping my head around this. Can anyone who's done the Pairwise challenge tell me why this pairwise([0, 0, 0, 0, 1, 1], 1) should return 10?
Joseph
@revisualize
Mar 06 2017 07:29
@ehrohit You're trying to remove the white spaces, underscore and alphanumeric character.
Rohit Sachdeva
@ehrohit
Mar 06 2017 07:29
@revisualize yes
redoz94
@redoz94
Mar 06 2017 07:29
hi guys, need some advice, i've just gotten a job at a local tech company as a community marketing expert, i am currently on course to finish the front end development certificate on FCC. I was wondering, if i successfully transition to a programmer at this firm and work for one/two years, will i be able to go to stanford for a MS in CS without any prior background in programming? Cheers,
_
Joseph
@revisualize
Mar 06 2017 07:30
@ehrohit Why not just use 1 regex statement?
Markus Kiili
@Masd925
Mar 06 2017 07:30
@chungeric Index pairs 0+4 and 1+5 make 10
OGKevin
@OGKevin
Mar 06 2017 07:31
@redoz94 ur better off asking something like this in the general chat instead of the javascript room
Joseph
@revisualize
Mar 06 2017 07:32
@ehrohit /([\w\s_])/g
Eric Chung
@chungeric
Mar 06 2017 07:32
@Masd925 oh, so you can use the same actual numbers, but not the same indices.... right, i thought it was the other way round
@Masd925 Thanks, will give it a go
CamperBot
@camperbot
Mar 06 2017 07:32
chungeric sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3520 | @masd925 |http://www.freecodecamp.com/masd925
Joseph
@revisualize
Mar 06 2017 07:32
@ehrohit Why do you only want to keep the non-alphanumeric characters (excluding _)?
@ehrohit You do realize that for Check Palindrome lesson. You need to keep the alphanumeric characters....
Markus Kiili
@Masd925
Mar 06 2017 07:34
@chungeric Yes, the description is not the best.
RakeshNerkar
@Rakesh18754
Mar 06 2017 07:37

1+"i" = "1i"
1-"i" = NaN

any reason for this?

bcoz string should just get concatenated right
OGKevin
@OGKevin
Mar 06 2017 07:38
@Rakesh18754 1 + "i" works bc it makes a string of 1 but thant doesn't work the other way around
Prashant Acharya
@Prashant-Acharya
Mar 06 2017 07:38
Can anyone help me to solve Diff Two Arrays challenge?
OGKevin
@OGKevin
Mar 06 2017 07:38
@Prashant-Acharya what have you coded so far
Prashant Acharya
@Prashant-Acharya
Mar 06 2017 07:38
``
RakeshNerkar
@Rakesh18754
Mar 06 2017 07:38
@OGKevin so while substracing it looks for a number right,,...so tats y
OGKevin
@OGKevin
Mar 06 2017 07:38
@Rakesh18754 correct
RakeshNerkar
@Rakesh18754
Mar 06 2017 07:39
cool ... @OGKevin Thanks a lot
CamperBot
@camperbot
Mar 06 2017 07:39
rakesh18754 sends brownie points to @ogkevin :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @ogkevin |http://www.freecodecamp.com/ogkevin
Prashant Acharya
@Prashant-Acharya
Mar 06 2017 07:39
function diffArray(arr1, arr2) {
var newArr = [];
for (var x = 0; x < arr1.length; x++){
if (arr1.indexOf(arr2[x]) !== -1){
newArr.push(arr1[x]);
}
}
return newArr;
}
OGKevin
@OGKevin
Mar 06 2017 07:40
@Prashant-Acharya this partially works right ?
i do spot a few issues
NaveenRathor
@NaveenRathor
Mar 06 2017 07:40

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

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

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

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

where i'm going wrong
OGKevin
@OGKevin
Mar 06 2017 07:41
like arr1 is not always the longest array is it ? @Prashant-Acharya
Javier Pons
@JavierPons
Mar 06 2017 07:41
hi guys!
Prashant Acharya
@Prashant-Acharya
Mar 06 2017 07:42
yeah
it is not always the longest array
not always
OGKevin
@OGKevin
Mar 06 2017 07:42
@Prashant-Acharya so that is one thing you will need to fix
@JavierPons :wave:
Prashant Acharya
@Prashant-Acharya
Mar 06 2017 07:43
function diffArray(arr1, arr2) {
  var newArr = [];
    for (var x = 0; x < arr1.length; x++){
      if (arr1.indexOf(arr2[x]) !== -1){
        newArr.push(arr1[x]);
      }
    }
  return newArr;
}
@OGKevin
OGKevin
@OGKevin
Mar 06 2017 07:43
@Prashant-Acharya and u have used index of wrong wait i concluded that to fast let me recheck
Joseph
@revisualize
Mar 06 2017 07:44
@NaveenRathor Your function has declared and initialized the variable result to "". You are not modifying result and your function is returning result. Ergo, you're returning "". You need to modify result to be the value of the property from the object that you created.
Prashant Acharya
@Prashant-Acharya
Mar 06 2017 07:44
ohh yes sorry..
function diffArray(arr1, arr2) {
  var newArr = [];
    for (var x = 0; x < arr1.length; x++){
      if (arr1[x].indexOf(arr2) !== -1){
        newArr.push(arr1[x]);
      }
    }
  return newArr;
}
@OGKevin still not working
Sarfaraz Amin Progga
@SA-P
Mar 06 2017 07:47
@NaveenRathor Also you need to use the bracket notation here. The dot notation won't work in this case.
OGKevin
@OGKevin
Mar 06 2017 07:47
@Prashant-Acharya my bad the way u had index off was correct just loaded the docs i had it confused with another method i apologise
@Prashant-Acharya your if statement however ...
youre pushing if it IS IN THE ARRAY shouldn't it be the other way around
Prashant Acharya
@Prashant-Acharya
Mar 06 2017 07:48
@OGKevin lets try :D
OGKevin
@OGKevin
Mar 06 2017 07:49
@Prashant-Acharya arr.indexOf(value)===-1 means its not in there
Javier Pons
@JavierPons
Mar 06 2017 07:49
Im working in this code. Could somebody give some advices how to carry on..

var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

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

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

  if (contacts == firstName){

    return firstName[i] ;

  }else if (contacts == prop){

   return prop[i];

  }else if (contacts !== firstName){

    return "No such contact";

  }else {

    return "No such contact";
  }
}

}

// Only change code above this line
}

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

Prashant Acharya
@Prashant-Acharya
Mar 06 2017 07:50
@OGKevin yes I got that. now the issue is if first array is not the longest then what should I do ?
Sarfaraz Amin Progga
@SA-P
Mar 06 2017 07:50
@JavierPons try using the hasOwnProperty method.
hasOwnProperty()
Javier Pons
@JavierPons
Mar 06 2017 07:51
@SA-P Im going to check it :)
OGKevin
@OGKevin
Mar 06 2017 07:51
@Prashant-Acharya well you should first find a way to find out wich array is the longest and then continue from there
Prashant Acharya
@Prashant-Acharya
Mar 06 2017 07:52
@OGKevin what about running an if statement. if arr1 is longest run these if not run these
OGKevin
@OGKevin
Mar 06 2017 07:52
@Prashant-Acharya that is one way to do it indeed
Javier Pons
@JavierPons
Mar 06 2017 07:53
@SA-P but I haven't study that one yet..
Ogundele Olumide
@Lumexralph
Mar 06 2017 07:54
@JavierPons you need just a loop to iterate the contacts array .... and why doing this prop[i];? shouldn't it be `firstName[i][prop] ?
@JavierPons Here's an outline that if you follow it step-wise it'll help a great deal in telling you what to do
1. you need a loop to pick each object
    1.1  in the loop you need to 
         1.1.1  check if the objects picked has the firstName property equal to the firstName parameter
                  1.1.1.1 you need to check if it has a property prop
                                      return the value of prop in the object
                 1.1.1.2       return no such property if  1.1.1.1 is false
2.  when your loop is done looking through  contacts return no such contact
Javier Pons
@JavierPons
Mar 06 2017 07:57
@Lumexralph lets go by parts... :) Have I my loop wrong?
Prashant Acharya
@Prashant-Acharya
Mar 06 2017 07:58
function diffArray(arr1, arr2) {
  var newArr = [];
  if(arr1.length >= arr2.length){
    for (var x = 0; x < arr1.length; x++){
      if (arr1.indexOf(arr2[x]) === -1){
        newArr.push(arr1[x]);
      }
    }
  }
  else{
        for (var y = 0; y < arr2.length; y++){
      if (arr2.indexOf(arr1[y]) === -1){
        newArr.push(arr2[y]);
      }
    }    
  }
  return newArr;
}
@OGKevin have a look at this please
OGKevin
@OGKevin
Mar 06 2017 07:59
@Prashant-Acharya looks alright, does it work ?
Prashant Acharya
@Prashant-Acharya
Mar 06 2017 07:59
No. Some do some don't :D
OGKevin
@OGKevin
Mar 06 2017 08:00
give me an example of one that does and one that doesnt ill do some debugging see what i can find
Javier Pons
@JavierPons
Mar 06 2017 08:00
@Lumexralph How I can check if the object picked has the firsName property equal to the first name parameter..?
Prashant Acharya
@Prashant-Acharya
Mar 06 2017 08:00
blob
@OGKevin
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:00
@JavierPons you need a loop
not 2 loops
Sarfaraz Amin Progga
@SA-P
Mar 06 2017 08:02
@JavierPons you could do it with just one loop if you use the hasOwnProperty() method. I suggest studying that a bit. It's pretty helpful.
Javier Pons
@JavierPons
Mar 06 2017 08:02
I ready did one. If Im not wrong the first loop go via every objects from the array.. for (var i = 0; i < contacts.length; i++){
for (var j = 0; j < contacts[i].length; j++){
@SA-P :+1:
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:03
@JavierPons contacts is an array you need a loop, contacts[i] is an object which you don't need a loop for
Pieter Stokkink
@forkerino
Mar 06 2017 08:03
morning
Markus Kiili
@Masd925
Mar 06 2017 08:03
@JavierPons When you have the property key (here stored in parameter prop), there is no need to loop property keys. You can just access the property.
Good morning.
Sarfaraz Amin Progga
@SA-P
Mar 06 2017 08:04
:wave:
Javier Pons
@JavierPons
Mar 06 2017 08:04
@Masd925 Huomenta Markus!
Markus Kiili
@Masd925
Mar 06 2017 08:04
Huomenta.
Javier Pons
@JavierPons
Mar 06 2017 08:05
@Masd925 thats mean that I need only one loop?
Pieter Stokkink
@forkerino
Mar 06 2017 08:05
@Lumexralph Hello!
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:05
@Masd925 @forkerino Good morning
Markus Kiili
@Masd925
Mar 06 2017 08:05
@JavierPons Yes, you just need to get hold of each contact with a loop.
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:05

Huomenta.

what language is that? @Masd925

Markus Kiili
@Masd925
Mar 06 2017 08:06
@Lumexralph Finnish.
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:06
@Masd925 are you one?
Markus Kiili
@Masd925
Mar 06 2017 08:06
Yes.
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:07
that's new for me ...
Javier Pons
@JavierPons
Mar 06 2017 08:07
@Lumexralph @Masd925 Start to work I little bit!
hemanth
@hem04
Mar 06 2017 08:07
Iterate with JavaScript For Loops solution?
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:07
@forkerino how're you bro?
OGKevin
@OGKevin
Mar 06 2017 08:07
@Prashant-Acharya its inconsistent why not use the .filter() method instead :thought_balloon: to remove duplicates from the entire array ?
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:07
@hem04 we don't understand
Javier Pons
@JavierPons
Mar 06 2017 08:14

@Masd925 I have this. What next step that I can't see? function lookUpProfile(firstName, prop){
// Only change code below this line

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

  if (contacts == firstName){

    return contacts[i] ;

  }else if (contacts == prop){

   return firstName[i][prop];

  }else if (contacts == firstName){

    return "No such contact";

  }else {

    return "No such contact";
  }

}

// Only change code above this line
}

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

Pieter Stokkink
@forkerino
Mar 06 2017 08:14
@Lumexralph quite ok. Short night.
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:14
@JavierPons contacts[i] is each object in contacts array
@forkerino why short? :smile:
Markus Kiili
@Masd925
Mar 06 2017 08:18
@Lumexralph Might get banned for answering that question ;)
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:19
@Masd925 :laughing:
@Masd925 was yours short too? :smile:
Pieter Stokkink
@forkerino
Mar 06 2017 08:20
@Lumexralph daughter woke up at 6
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:20
@Masd925 so you see.....
Markus Kiili
@Masd925
Mar 06 2017 08:20
@Lumexralph I sleep like a log nowadays.
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:20
@forkerino i can imagine
Javier Pons
@JavierPons
Mar 06 2017 08:21
@Masd925 How I can return the value that ask.... I can't see it yet... @Lumexralph @forkerino
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:22
@Masd925 how many hours? :smile:
@JavierPons what value?
Anon
@MikeyZee
Mar 06 2017 08:23
Heyy everyone, I am attempting to get a function to run when a page loads according to a variable which is set. Put into context, its a random number guessing game and the user starts the game, selects difficulty of easy (1-50), Medium (1-100) and Hard (1-200). Depending on which difficulty they choose will change the variable to generate my number (this is all done). All I need to do is get the math.random function to run as the page is loaded. Here is some code to elaborate what I am saying
<button onclick="creategennum()">Create New Random Number</button>
let gennum;
  function creategennum() {
  //var qs = new Querystring();
    var diff = getQueryString('diff');
    switch(diff) {
    case "easy":
        var range = 50;
        break;
    case "medium":
        var range = 100;
        break;
    case "hard":
        var range = 200;
        break;
    default:
        var range = null;
    }
    gennum = Math.floor((Math.random()*range) + 1); //random number between 1 and range
    window.alert(gennum)
So currently I have a button which needs to be pressed in order to generate the number, which is kind of... stupid I guess
_
Markus Kiili
@Masd925
Mar 06 2017 08:23
@Lumexralph maybe 6,5 h on weekdays.
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:23
@Masd925 that's not sleeping like a log if you ask me
Javier Pons
@JavierPons
Mar 06 2017 08:23
@Lumexralph if (contacts == firstName){
return  the value of firstName ;
Markus Kiili
@Masd925
Mar 06 2017 08:24
@Lumexralph I meant getting to sleep and the quality.
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:24
@JavierPons your loop needs to pick each objects in the contacts array and you just do that by doing contacts[i] anywhere you need the object in your code
Javier Pons
@JavierPons
Mar 06 2017 08:25
@Lumexralph sorry but I dont understand you
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:25
@Masd925 how many hours do you think is a good sleep?
@JavierPons you have a loop, right?
Javier Pons
@JavierPons
Mar 06 2017 08:26
@Lumexralph yes
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:26
@JavierPons what's your loop doing?
Markus Kiili
@Masd925
Mar 06 2017 08:26
@Lumexralph I think 8 is good. I catch up on weekends.
Javier Pons
@JavierPons
Mar 06 2017 08:27
@Lumexralph I think chec
@JavierPons I thinking every array object
@Lumexralph cheching
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:27
@Masd925 am cheating myself on sleep and am not very cool with it
@JavierPons you needed a loop because contacts is an array of objects, the elements of that array are objects and you needed a loop to pick each object in that array

@JavierPons

@JavierPons Here's an outline that if you follow it step-wise it'll help a great deal in telling you what to do

1. you need a loop to pick each object
    1.1  in the loop you need to 
         1.1.1  check if the objects picked has the firstName property equal to the firstName parameter
                  1.1.1.1 you need to check if it has a property prop
                                      return the value of prop in the object
                 1.1.1.2       return no such property if  1.1.1.1 is false
2.  when your loop is done looking through  contacts return no such contact
Javier Pons
@JavierPons
Mar 06 2017 08:30
@Lumexralph sorry to tell that this time you are not helping a lot. :+1:
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:31
@JavierPons what do you require of me? okay a quick example

@JavierPons

let array = [1, 2, 3 ,4, 5];

how will you print out all the elements in array ?

hemanth
@hem04
Mar 06 2017 08:36
can anyone help me with this task "Iterate Through an Array with a For Loop"?
Reine Alice Iramurikiye
@reinelic
Mar 06 2017 08:36

I am working on javascript algorithm. I am supposed to truncate a string . but i am not sure if I understand what I am asked to do.

https://www.freecodecamp.com/challenges/truncate-a-string

Part of my code is working but I am stuck. Can someone please assist

function truncateString(str, num) {
  // Clear out that junk in your trunk
  var stri = str.slice(0,num).split().join('').split('');
  var lengthi = stri.length-1;
  var sliced= lengthi -3;
   if(str.length > num)
    {
      for(var i= lengthi; i>sliced;i--)
        {
          stri[i]=".";
        }

      return stri.join('');   
    }
    else if (str.length<=num)
    {
      return stri.join('');
    }
   else if (num<=3)
     {

     }
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:37
@hem04
for(let i = 0; i < array.length; i++) {
     console.log(array[i]);
}
its not working .
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:43
@hem04 add the elements in myArr to myTotal in the for loop
David Shin
@datadaveshin
Mar 06 2017 08:43
@hem04 look at the error it gave you...
Anon
@MikeyZee
Mar 06 2017 08:45
Heyy everyone, I am attempting to get a function to run when a page loads according to a variable which is set. Put into context, its a random number guessing game and the user starts the game, selects difficulty of easy (1-50), Medium (1-100) and Hard (1-200). Depending on which difficulty they choose will change the variable to generate my number (this is all done). All I need to do is get the math.random function to run as the page is loaded. Here is some code to elaborate what I am saying
<button onclick="creategennum()">Create New Random Number</button>
let gennum;
  function creategennum() {
  //var qs = new Querystring();
    var diff = getQueryString('diff');
    switch(diff) {
    case "easy":
        var range = 50;
        break;
    case "medium":
        var range = 100;
        break;
    case "hard":
        var range = 200;
        break;
    default:
        var range = null;
    }
    gennum = Math.floor((Math.random()*range) + 1); //random number between 1 and range
    window.alert(gennum)
Javier Pons
@JavierPons
Mar 06 2017 08:49
hello
I have this code. I need some help to fix it.

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

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

  if (contacts.firstName == firstName){

   return firstName ;

  }else if (contacts == prop){

   return firstName[i][prop];

  }else if (contacts !== firstName){

    return "No such contact";

  }else {

    return "No such contact";
  }

}

// Only change code above this line
}

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

Pieter Stokkink
@forkerino
Mar 06 2017 08:50
@Lumexralph I'm looking for a good resource on Python. Any recommendations?
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:51
@forkerino how about online courses using python?
am running though the codacademy course for now,
will go to edx or coursera for more CS courses with python ...... i really don't have much
@forkerino but bro.... Python is life made easier compared to JS so far, let me see if it can challenge my love for JS
Catalin Moraru
@catalinmoraru82
Mar 06 2017 08:54
hi everyone
i need some help with my excecise
David Shin
@datadaveshin
Mar 06 2017 08:55
@forkerino This was one of the best classes I think I ever took.. https://www.coursera.org/learn/interactive-python-1
Catalin Moraru
@catalinmoraru82
Mar 06 2017 08:55
I don't understand what I have to do

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber; // Change this Line
var player = testObj[16]; // Change this Line

and it says: You should be using the variable playerNumber in your bracket notation
Pieter Stokkink
@forkerino
Mar 06 2017 08:55
@datadaveshin @Lumexralph Yeah, I found that class as well, and as a matter of fact it is starting today again, so good time to start.
Javier Pons
@JavierPons
Mar 06 2017 08:55
@Lumexralph I got this till now
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:55
@datadaveshin cool..... those are the type of courses am about taking too
@forkerino we start together ? :smile:
Pieter Stokkink
@forkerino
Mar 06 2017 08:56
@Lumexralph let's do it
David Shin
@datadaveshin
Mar 06 2017 08:56
Yeah, it's a great class
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:57
@JavierPons your're not picking each objects in the contacts array, you need to pick each objects before comparing them in your if statements
David Shin
@datadaveshin
Mar 06 2017 08:57
I"ve taken the first 4 in that series... they are fast-paced but really fun
Javier Pons
@JavierPons
Mar 06 2017 08:57
if ( contacts.firstName == firstName) Its that ok?
ok
@Lumexralph now I think I start to understand ...
Pieter Stokkink
@forkerino
Mar 06 2017 08:58
@datadaveshin good, we're not beginners, so fast paced is good. Thanks for the tip!
CamperBot
@camperbot
Mar 06 2017 08:58
forkerino sends brownie points to @datadaveshin :sparkles: :thumbsup: :sparkles:
:cookie: 52 | @datadaveshin |http://www.freecodecamp.com/datadaveshin
Javier Pons
@JavierPons
Mar 06 2017 08:59
@Lumexralph well. Im lost. Can you say how?
Ogundele Olumide
@Lumexralph
Mar 06 2017 08:59
@JavierPons contacts[i].firstName == firstName
@forkerino are you ready?!
Javier Pons
@JavierPons
Mar 06 2017 09:00
@Lumexralph I was so close ...
Ogundele Olumide
@Lumexralph
Mar 06 2017 09:00
@JavierPons but not there
@JavierPons just remember that contacts[i] is the object in the contacts array
Pieter Stokkink
@forkerino
Mar 06 2017 09:01
@Lumexralph I enrolled. Don't have much time today, but I'm in.
Javier Pons
@JavierPons
Mar 06 2017 09:04
:)
David Shin
@datadaveshin
Mar 06 2017 09:04
@forkerino ah great... you will like the classes then. The first one will have a lot of basics though, just like any programming series. But really, I think these classes were what got me to transition to being a developer... actually, I started developing at my old job using what I learned.
Matt Wiseman
@mrslwiseman
Mar 06 2017 09:04

can someone tell me how I'm going wrong here?

this works;

array[i].charCodeAt(0)

this doesnt:

array[i+1].charCodeAt(0)

please help! thank you!

WiseKodama
@WiseKodama
Mar 06 2017 09:05
Greetings everyone. Does anyone know how I can grab the id from the clicked element?
Ogundele Olumide
@Lumexralph
Mar 06 2017 09:05
@forkerino just did too.....will try to make out time, you went to audit course. right? @datadaveshin
Javier Pons
@JavierPons
Mar 06 2017 09:05
@Lumexralph well, still Im very far
WiseKodama
@WiseKodama
Mar 06 2017 09:05
Since I cant do onclick="place(this)" on codepen.
David Shin
@datadaveshin
Mar 06 2017 09:05
@mrslwiseman is there actually an element in that array at whatever i+1 equals?
setthkyz
@setthkyz
Mar 06 2017 09:05
Can someone check this out and tell me what am i doing wrong ?
Ogundele Olumide
@Lumexralph
Mar 06 2017 09:06
@mrslwiseman array[i+1].charCodeAt(0) doing this if your using a loop will return undefined the last element in an array is array[array.length - 1]
David Shin
@datadaveshin
Mar 06 2017 09:06
@Lumexralph I paid for the classes because I had a pretty decent job at the time.
NaveenRathor
@NaveenRathor
Mar 06 2017 09:06

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

function checkObj(checkProp) {
// Your Code Here
checkProp = myObj;
return myObj[""];
}
myObj.hasOwnProperty("checkProp");
// Test your code by modifying these values
checkObj("gift");

guys what's wrong in my code
WiseKodama
@WiseKodama
Mar 06 2017 09:07
@setthkyz myMax-myMin inside the random and then + the min
Matt Wiseman
@mrslwiseman
Mar 06 2017 09:07
thanks @datadaveshin
CamperBot
@camperbot
Mar 06 2017 09:07
mrslwiseman sends brownie points to @datadaveshin :sparkles: :thumbsup: :sparkles:
:cookie: 53 | @datadaveshin |http://www.freecodecamp.com/datadaveshin
Matt Wiseman
@mrslwiseman
Mar 06 2017 09:07
thanks @Lumexralph
CamperBot
@camperbot
Mar 06 2017 09:07
mrslwiseman sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1258 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Mar 06 2017 09:08
@JavierPons but continue with the understanding you have
Javier Pons
@JavierPons
Mar 06 2017 09:08
@Lumexralph some questions more. If you have patience...
Ogundele Olumide
@Lumexralph
Mar 06 2017 09:08
@JavierPons okay...
Blauelf
@Blauelf
Mar 06 2017 09:09
@NaveenRathor You'll need to use hasOwnProperty in checkObj function, and use for example an if based on its return value
Javier Pons
@JavierPons
Mar 06 2017 09:10
@Lumexralph I got firstName, in the array there are a lot of elements . I have to go via each one. does it means that I have to carry on else if of every element?
WiseKodama
@WiseKodama
Mar 06 2017 09:10
@setthkyz Did you manage?
Ogundele Olumide
@Lumexralph
Mar 06 2017 09:13
@JavierPons that's what your for loop is doing for you, it's picking each object at every iteration
Javier Pons
@JavierPons
Mar 06 2017 09:15
@Lumexralph ok. so whats next I should do?
Ogundele Olumide
@Lumexralph
Mar 06 2017 09:15
@JavierPons let me see your updated code
NaveenRathor
@NaveenRathor
Mar 06 2017 09:15
@Blauelf what I'll define in if statement

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

function checkObj(checkProp) {
// Your Code Here
checkProp = myObj;
myObj.hasOwnProperty("checkProp");

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

Blauelf
@Blauelf
Mar 06 2017 09:16
@NaveenRathor Do not assign to checkProp, and use hasOwnProperty in the condition, with a return in the if and the else path each.
Javier Pons
@JavierPons
Mar 06 2017 09:17
in the beginning of else if Im just trying what should work. here code: https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%0A%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20contacts.length%3B%20i%2B%2B)%7B%0A%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20if%20(contacts%5Bi%5D.firstName%20%3D%3D%3D%20firstName)%7B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20return%20firstName%20%3B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%7Delse%20if%20(contacts%5Bi%5D.firstName%20%3D%3D%20prop)%7B%0A%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20return%20prop%3B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%7Delse%20if%20(contacts%20!%3D%3D%20firstName)%7B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20return%20%22No%20such%20contact%22%3B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%7Delse%20%7B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20return%20%22No%20such%20contact%22%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%7D%0A%20%20%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A
Ogundele Olumide
@Lumexralph
Mar 06 2017 09:19
@JavierPons paste it here
@Blauelf Good morning bro
Javier Pons
@JavierPons
Mar 06 2017 09:20

var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

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

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

  if (contacts[i].firstName === firstName){

   return firstName ;

  }else if (contacts[i].firstName == prop){

   return prop;

  }else if (contacts !== firstName){

    return "No such contact";

  }else {

    return "No such contact";
  }

}

// Only change code above this line
}

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

Blauelf
@Blauelf
Mar 06 2017 09:20
@JavierPons relevant parts only (the function), and use proper code formatting for chat
NaveenRathor
@NaveenRathor
Mar 06 2017 09:22
@Blauelf I have no idea how use it
Ogundele Olumide
@Lumexralph
Mar 06 2017 09:23
@JavierPons you need a nested if statement under your first if statement to
*if contacts[i] has a property prop
  if true return the value of the prop property in the objects
* if not return no such property
Blauelf
@Blauelf
Mar 06 2017 09:23
@JavierPons No reason for returning firstName. Also, prop is not a value for the firstName property, but a property name, if the firstName matches, and that property exists (use hasOwnProperty), you are meant to return its value. If name matches and property does not exist, you are meant to return "No such property". Return "No such contact" only if none of the names matched in the whole array.
Javier Pons
@JavierPons
Mar 06 2017 09:25
@Blauelf ok
@Blauelf @Lumexralph I need a break
Ogundele Olumide
@Lumexralph
Mar 06 2017 09:30
@JavierPons loop break or self break?
Javier Pons
@JavierPons
Mar 06 2017 09:31
@Lumexralph :+1:
Javier Pons
@JavierPons
Mar 06 2017 09:42
@Lumexralph After self break, here again. Trying not become mad
@Blauelf @Lumexralph Whats prop does? Its a variable. What it content?
Blauelf
@Blauelf
Mar 06 2017 09:45
It contains a property name.
WiseKodama
@WiseKodama
Mar 06 2017 09:45
Greetings is there anyway to pass this through html onclick. For example <div onclick="place(this)">
Blauelf
@Blauelf
Mar 06 2017 09:45
@WiseKodama What does your place look like?
Jackalope2K17
@Jackalope2K17
Mar 06 2017 09:46
Hi there! I simply cannot understand the request of the ex "Using Objects for Lookups"
setthkyz
@setthkyz
Mar 06 2017 09:46
Help me, i don't know what am i doing wrong...
WiseKodama
@WiseKodama
Mar 06 2017 09:46
function place(clicked){ for(var x=0;x<tiles.length;x++){ if(state[x] === 0 && tiles[x] === clicked){ tiles[x].style.background = red; state[x] === 1; } } }
@Blauelf
rakeshpuri
@rakeshpuri
Mar 06 2017 09:46
hello im facing problem
Jackalope2K17
@Jackalope2K17
Mar 06 2017 09:46
the example seems having nothing to do with the requeste
rakeshpuri
@rakeshpuri
Mar 06 2017 09:46
help me someone please
i want to know how to solve the stand in line issue
Pieter Stokkink
@forkerino
Mar 06 2017 09:47

@JavierPons if I do

lookUpProfile("Javier", "likes");

prop will be "likes"
if I do

lookUpProfile("Pieter", "languages");

prop will be "languages".
does that clarify it a little bit?

Jackalope2K17
@Jackalope2K17
Mar 06 2017 09:47
how can I nest an object into a function?
rakeshpuri
@rakeshpuri
Mar 06 2017 09:47
hey there
Jor
@joreyesl
Mar 06 2017 09:48
@setthkyz you are missing semicolons ; where the errors are. getGear is fine, but setGear should take a parameter and should assign = it to the variable gear already declared inside the function.
Jackalope2K17
@Jackalope2K17
Mar 06 2017 09:48
there were no examples whatsoever
rakeshpuri
@rakeshpuri
Mar 06 2017 09:48
hello
someone help me with my errors
Javier Pons
@JavierPons
Mar 06 2017 09:48
@forkerino a lot.
Rory Ashton
@RoryAshton
Mar 06 2017 09:49

function titleCase(str)
{
var strArray=str.split(' ');
var newArray;
for(var x=0;x<strArray.length;x++)
{
var letters=strArray[x].split('');
var newWord;
for(var l=0;l<letters.length;l++)
{
if(l===0)
{
newWord+=letters[0].toUpperCase;
}
else
{
newWord+=letters[l].toLowerCase;
}
}
newArray+=newWord.join('');
}
var newStr=newArray.join(' ');
return newStr;
}

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

rakeshpuri
@rakeshpuri
Mar 06 2017 09:49
@JavierPons help
Rory Ashton
@RoryAshton
Mar 06 2017 09:49
Hello, please could I get some help, I am getting a TypeError on newWord.join
it's saying it's not a function
Jackalope2K17
@Jackalope2K17
Mar 06 2017 09:49
@forkerino what's up? I am looking how to nest an object into a function...ex Using Objects for Lookups
Javier Pons
@JavierPons
Mar 06 2017 09:49
@forkerino Im now in a non exit way. What do you recomme
Aliaksandr_Pitkevich
@anfield343
Mar 06 2017 09:49
@RoryAshton give me please full code
Rory Ashton
@RoryAshton
Mar 06 2017 09:50

function titleCase(str)
{
var strArray=str.split(' ');
var newArray;
for(var x=0;x<strArray.length;x++)
{
var letters=strArray[x].split('');
var newWord;
for(var l=0;l<letters.length;l++)
{
if(l===0)
{
newWord+=letters[0].toUpperCase;
}
else
{
newWord+=letters[l].toLowerCase;
}
}
newArray+=newWord.join('');
}
var newStr=newArray.join(' ');
return newStr;
}

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

Javier Pons
@JavierPons
Mar 06 2017 09:50
recommend. Stop and carry on with other exercises. Or that you give me the solution?
Jor
@joreyesl
Mar 06 2017 09:50
@rakeshpuri look at at the array methods, .push() and .shift()
@RoryAshton you are missing the () at the end of toUpperCase() and toLowerCase()
Aliaksandr_Pitkevich
@anfield343
Mar 06 2017 09:51
@RoryAshton
str.toLowerCase()
Blauelf
@Blauelf
Mar 06 2017 09:52
@WiseKodama The onclick="place(this)" should work. Not sure what tiles and state contains in your code.
Rory Ashton
@RoryAshton
Mar 06 2017 09:52
@anfield343 Oh yes, thank you! I am still getting the error, though
CamperBot
@camperbot
Mar 06 2017 09:52
roryashton sends brownie points to @anfield343 :sparkles: :thumbsup: :sparkles:
:cookie: 19 | @anfield343 |http://www.freecodecamp.com/anfield343
Javier Pons
@JavierPons
Mar 06 2017 09:52
@forkerino Im now in a non exit way. What do you recommend. Stop and carry on with other exercises. Or that you give me the solution? This it the exercise of all course that I have been without possibility to resolve. @Blauelf
h1tag
@h1tag
Mar 06 2017 09:53
@joreyesl hey, can you point me to documentation about a topic you told me about before, which is when an array is passed to function, doing this var arr1 = arr will be a reference to arr not an actual copy of it
setthkyz
@setthkyz
Mar 06 2017 09:54
@joreyesl I did add semicolons but i still don't get what should i do with setGear can you explain it to me again http://prntscr.com/eglpgv
Blauelf
@Blauelf
Mar 06 2017 09:56
@WiseKodama Read your browser's Javascript console. First, you have the this on only one tile, also you assign red, and that's where your script crashes, should be "red".
Jackalope2K17
@Jackalope2K17
Mar 06 2017 09:56
Hi there! I am looking how to nest an object into a function...ex. Using Objects for Lookups
Pieter Stokkink
@forkerino
Mar 06 2017 09:56
@JavierPons Just leave the exercise alone for some time and come back to it later. Often the solution will come as soon as you let it go.
see you all later!
WiseKodama
@WiseKodama
Mar 06 2017 09:56
oh my goodness... forgot the quotes
@Blauelf Thanks. I had it on all the pieces but put it one to test
CamperBot
@camperbot
Mar 06 2017 09:56
wisekodama sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 3765 | @blauelf |http://www.freecodecamp.com/blauelf
Javier Pons
@JavierPons
Mar 06 2017 09:56
@forkerino thank you
Rory Ashton
@RoryAshton
Mar 06 2017 09:57

``` (shift+enter for line break)
var code = "formatted";

function titleCase(str)
{
var strArray=str.split(' ');
var newArray;
for(var x=0;x<strArray.length;x++)
{
var letters=strArray[x].split('');
var newWord;
for(var l=0;l<letters.length;l++)
{
if(l===0)
{
newWord+=letters[0].toUpperCase();
}
else
{
newWord+=letters[l].toLowerCase();
}
}
newArray+=newWord.join('');
}
var newStr=newArray.join(' ');
return newStr;
}

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

Jor
@joreyesl
Mar 06 2017 09:57
@setthkyz in the setGear you are supposed to assign the value that gets passed in to the private variable.
Ex: Person class where I can set and get the name.
var Person = function() {
  var name;
  this.getName = function() {
    return name;
  };

  this.setName = function(n) {
     name = n;
  };
}
Rory Ashton
@RoryAshton
Mar 06 2017 09:57
Sorry, meant to add that I am getting a TypError saying that newWord.join is not a funciton
Any help would be appreciated :)
Dan Couper
@DanCouper
Mar 06 2017 09:59
It isn't a function, there is no such thing as string.join, and you seem to be trying to join undefined as well, which will not work
Blauelf
@Blauelf
Mar 06 2017 09:59
@WiseKodama The browser's Javascript console is pretty useful ;)
WiseKodama
@WiseKodama
Mar 06 2017 09:59
I always forget about that one! Thanks again
Rory Ashton
@RoryAshton
Mar 06 2017 09:59
@DanCouper But newWord is an array of letters
Jackalope2K17
@Jackalope2K17
Mar 06 2017 10:00
please, someone help me
I am looking how to nest an object into a function...ex Using Objects for Lookups
please
Dan Couper
@DanCouper
Mar 06 2017 10:01
@RoryAshton letters is an array of letters. newWord is undefined.
var letters = strArray[x].split('');
var newWord;
Rory Ashton
@RoryAshton
Mar 06 2017 10:01
@DanCouper ah ok, how do I fix it then
Dan Couper
@DanCouper
Mar 06 2017 10:02
You've got far too many variables, it's a bit confusing, I'll just have a look
rakeshpuri
@rakeshpuri
Mar 06 2017 10:02
ohk
Rory Ashton
@RoryAshton
Mar 06 2017 10:02
@DanCouper haha, ok thank you :)
CamperBot
@camperbot
Mar 06 2017 10:02
roryashton sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 534 | @dancouper |http://www.freecodecamp.com/dancouper
Jor
@joreyesl
Mar 06 2017 10:02

@fortMaximus I dont think I posted any documentation on the subject. Just gave you my own explanation about it. I supposed you can google it to get more info. I did a quick search and found this post that gives an example.

One thing that I will clarify, in the post it says that arrays are passed by reference. This is not entirely accurate. There is no true pass by reference in JS. Everything is passed by value, it just happens to be that for an array that value is the reference to it.

Jackalope2K17
@Jackalope2K17
Mar 06 2017 10:03
image.png
what is missing here?
plase someone help me
Blauelf
@Blauelf
Mar 06 2017 10:04

@Jackalope2K17 Gitter chat uses markdown, you can post code properly formatted using backticks

You are not changing result. Assign to it, using lookup and val on the right side of the assignment.

Jackalope2K17
@Jackalope2K17
Mar 06 2017 10:05
thank you1 @Blauelf ! let me try
rakeshpuri
@rakeshpuri
Mar 06 2017 10:05
@joreyesl im still facing problems
CamperBot
@camperbot
Mar 06 2017 10:05
jackalope2k17 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 3766 | @blauelf |http://www.freecodecamp.com/blauelf
setthkyz
@setthkyz
Mar 06 2017 10:05
I should add 3 to every number in oldArray and here is my solution

var oldArray = [1,2,3,4,5];

// Only change code below this line.
var addThree = oldArray.map(function(val){return val + 3;});
var newArray = oldArray;

so why it isn't working?
rakeshpuri
@rakeshpuri
Mar 06 2017 10:05

function nextInLine(arr, item) {
// Your code here
arr.push(item);
arr.shift(arr[0]);
return arr[0]; //ge 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));

Blauelf
@Blauelf
Mar 06 2017 10:05
@setthkyz What's addThree? Is it part of the task? Shouldn't newArray be a mapped oldArray?
setthkyz
@setthkyz
Mar 06 2017 10:06
no i add it
added
rakeshpuri
@rakeshpuri
Mar 06 2017 10:06
@Blauelf can u please solve it

function nextInLine(arr, item) {
// Your code here
arr.push(item);
arr.shift(arr[0]);
return arr[0]; //ge 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));

setthkyz
@setthkyz
Mar 06 2017 10:06
@Blauelf aaa i get it now thanks
CamperBot
@camperbot
Mar 06 2017 10:06
setthkyz sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 3767 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Mar 06 2017 10:07
@rakeshpuri shift ignores arguments, you can call it as arr.shift(). It returns the element it removes, don't ignore that, but return it.
rakeshpuri
@rakeshpuri
Mar 06 2017 10:07
ohk
let me sees
Minoy
@minoy
Mar 06 2017 10:07

Hello,
I am working on the Ceaser's Cipher challenge. Following is the current code -

function rot13(str) { // LBH QVQ VG!
 var i = 0;
  var arr = [];
  while (i < str.length)
    {
        arr.push(str.charCodeAt(i) - 13);
      i++;
    }

  z = arr.toString();
  //return z;
  k = String.fromCharCode(z);
  return k;

}

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

I am not getting any output or error message. Any ideas? I am able to return 'z' but not 'k'.

rakeshpuri
@rakeshpuri
Mar 06 2017 10:07
see*

function nextInLine(arr, item) {
// Your code here
arr.push(item);
arr.shift();
return arr;
}

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

still facing problem @Blauelf
Jackalope2K17
@Jackalope2K17
Mar 06 2017 10:08
<result>
<result>,
Blauelf
@Blauelf
Mar 06 2017 10:09

@minoy You cannot String.fromCharCode with a string as its argument, use String.fromCharCode.apply(null, arr) for transforming an array of numbers.

For A..M, it's +13, for N..Z, it's -13, for everything else, don't change anything.

@rakeshpuri Don't ignore the result of arr.shift()
Jackalope2K17
@Jackalope2K17
Mar 06 2017 10:09
'<result>'
rakeshpuri
@rakeshpuri
Mar 06 2017 10:10
thanks buddy
@Blauelf
Blauelf
@Blauelf
Mar 06 2017 10:10
@Jackalope2K17 Backticks (`)? `inline code` => inline code
```js
var myCode = "code block";
```
=>
var myCode = "code block";
Radek
@radekjohn
Mar 06 2017 10:11
Hi,
Does anybody know why this runs OK on repl.it but freezes on FCC?
function permAlone(str) {
    var arr = [];
    var perm = [];
    var permCut = [];
    arr = str.split("");

    function swap(a, b) {
        var tmp = arr[a];
        arr[a] = arr[b];
        arr[b] = tmp;
    }

    function generate(n) {
        if (n === 1) {
            perm.push(arr.join());
        }
        else {
            for (var i = 0; i !== n; i++) {
                generate(n - 1);
                swap(n % 2 ? 0 : i, n - 1);
            }
        }
    }
    generate(arr.length);
    return perm;
}
permAlone('aab');
h1tag
@h1tag
Mar 06 2017 10:12
@joreyesl yea, you didn't. I was expecting it be to be mentioned in some of the MDN documentations and I didn't find it there (in the arguments object doc). It's weird that it's not mentioned there.
Dan Couper
@DanCouper
Mar 06 2017 10:12
@RoryAshton hookay, you've got all the ingredients there, but to fix:
  1. Keep var strArr. That's fine
  2. Change var newArr; to var newArr = []; - you can now push your title cased words into that new array.
  3. Keep var letters =
  4. Get rid of newWord, isn't needed.
  5. In the if (l === 0), at that point, you have a seperate array of letters (letters). You don't need to += or anything, you can literally just do letters[0] = letters[0].toUpperCase();
  6. In the same vein, in the else, you can do letters[l] = letters[l].toLowerCase();
  7. At this point, the current word is successfully converted: so instead of newArray+=newWord.join('');, you push the joined letters to newArr - newArr.push(letters.join('')).
  8. You don't need newStr: literally just return newArr.join(' ')
h1tag
@h1tag
Mar 06 2017 10:13
@joreyesl thanks for taking the time :)
CamperBot
@camperbot
Mar 06 2017 10:13
fortmaximus sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 569 | @joreyesl |http://www.freecodecamp.com/joreyesl
Dan Couper
@DanCouper
Mar 06 2017 10:14
@RoryAshton Also I would call newArr something like wordsArr or just words, just something more descriptive rather than generic
Shreyash Baba Payasam
@shreyash015
Mar 06 2017 10:14
Hello guys
I am trying to solve a codeeval problem using JavaScript
someone who's a ninja/pro can you please help me out?
Dan Couper
@DanCouper
Mar 06 2017 10:16
you need to post code
Shreyash Baba Payasam
@shreyash015
Mar 06 2017 10:16
yep was waiting for someone to rreply
Dan Couper
@DanCouper
Mar 06 2017 10:16
someone can probably help
rakeshpuri
@rakeshpuri
Mar 06 2017 10:16
post @shreyash015
Jackalope2K17
@Jackalope2K17
Mar 06 2017 10:16
@Blauelf sorry, I have a keyboard where backticks are not printed now I found them <result>
Shreyash Baba Payasam
@shreyash015
Mar 06 2017 10:17
anyway havent started the code yet but this is the problem to bb solved:
https://www.codeeval.com/browse/78/
so what i want to know is how do i write JavaScript code that can take a text file as input and read it line by line?
and arrange the given numbers in the text file into an array :(
Blauelf
@Blauelf
Mar 06 2017 10:18
@Jackalope2K17 Not printed? It's Shift+´ for me :D
Dan Couper
@DanCouper
Mar 06 2017 10:19
@shreyash015 split. Eg 'h,e,l,l,o'.split(',') would give ['h','e','l','l','o']
Shreyash Baba Payasam
@shreyash015
Mar 06 2017 10:20
@DanCouper, yes but how do i write code that reads an external file?
Dan Couper
@DanCouper
Mar 06 2017 10:21
Do you need to? Is that necessary to pass the challenge?
Is it not assuming away the reading the file bit
JS itself has no way to load files, it's not built into the language
Shreyash Baba Payasam
@shreyash015
Mar 06 2017 10:22
well it says the following: "Your program should accept as its first argument a path to a filename."