These are chat archives for FreeCodeCamp/HelpJavaScript

7th
Jul 2017
CallMeOrange
@EgnaroDev
Jul 07 2017 00:20
guys what do you think of my designs? for Random Quote Machine
Need to fix with scrolling horizontal.. EDITED fixed it
Simon Cordova
@gbsimon87
Jul 07 2017 00:27
Anybody in London looking for a developing job?
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 00:33
@MCTwoDigitZero That totally fits for the theme. :yellow_heart:
CallMeOrange
@EgnaroDev
Jul 07 2017 00:33
@saifsmailbox98 thanks bro
CamperBot
@camperbot
Jul 07 2017 00:33
mctwodigitzero sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 730 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
CallMeOrange
@EgnaroDev
Jul 07 2017 00:33
Need to fix box, think that is last thing to do
Too big for small screen
@saifsmailbox98 A question
$(document).ready(function(){
  $("html, body").on("click", function(){
    $(".quote").html("Testing");
  });
});
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 00:34
@MCTwoDigitZero Yeah, not too responsive.
CallMeOrange
@EgnaroDev
Jul 07 2017 00:34
Yeah
So I click on something then Testing will show up
Works both $("html, body").on("click", function(){ and $("body").on("click", function(){
Do I need html,?
Mask
@Dentist1112
Jul 07 2017 00:35
blob
why am i wrong?
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 00:35
@MCTwoDigitZero it's okay to use, body only as the rest of the html is not rendered.
CallMeOrange
@EgnaroDev
Jul 07 2017 00:36
@saifsmailbox98 If I click on some html elements with $("body") then it wont show up?
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 00:36
@Dentist1112 save the replaced string.
CallMeOrange
@EgnaroDev
Jul 07 2017 00:37
if so, I should use $("html, body")
Hm...
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 00:38
@MCTwoDigitZero best way is to try, as I haven't ever tried that on html.
CallMeOrange
@EgnaroDev
Jul 07 2017 00:38
I tested it, both works
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 00:38
@MCTwoDigitZero great
CallMeOrange
@EgnaroDev
Jul 07 2017 00:38
I should stick with html, body
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 00:38
@MCTwoDigitZero it's okay to use body.
CallMeOrange
@EgnaroDev
Jul 07 2017 00:39
Yeah but I think html, body is better/ properly way
@saifsmailbox98 You saw my project right? do you know how to fix box begin too big on small screen?
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 00:40
@MCTwoDigitZero are you using bootstrap?
CallMeOrange
@EgnaroDev
Jul 07 2017 00:40
yeah
You can see my html code
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 00:40
@MCTwoDigitZero then checkout how columns work.
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 00:41
@MCTwoDigitZero try only html
CallMeOrange
@EgnaroDev
Jul 07 2017 00:41
I heard of something that you can use col-md-6 col-xs-12
@saifsmailbox98 alright
Gurpreet SIngh
@Gurpreet3131
Jul 07 2017 00:42
how to link 2 js files without using html?
CallMeOrange
@EgnaroDev
Jul 07 2017 00:42
html works
Mask
@Dentist1112
Jul 07 2017 00:42
@saifsmailbox98 thanks
CamperBot
@camperbot
Jul 07 2017 00:42
dentist1112 sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 731 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 00:42
@MCTwoDigitZero Yes, try that on the quote box, check out the official bootstrap docs
@MCTwoDigitZero yes all three of them would work, as html is the parent of body.
CallMeOrange
@EgnaroDev
Jul 07 2017 00:43
Ah
Gurpreet SIngh
@Gurpreet3131
Jul 07 2017 00:44
Anyone can you help me out?? how to link 2 js files without using html
CallMeOrange
@EgnaroDev
Jul 07 2017 00:44
Tried col-md-12 and col-xs-6 but nothing changes but this is no time to worry about it
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 00:45
@MCTwoDigitZero columns need to be under a row.
CallMeOrange
@EgnaroDev
Jul 07 2017 00:46
Yeah I already set them under a row
<div class="container-fluid">
  <div class="row">
    <div class="col-md-12">
      <h2 class="title">Random Quote Machine</h2>
stalin
@stalintouch
Jul 07 2017 00:47
``
CallMeOrange
@EgnaroDev
Jul 07 2017 00:47
wrong code
<div class="container-fluid">
  <div class="row">
    <div class="col-md-12 col-xs-6">
      <div class="box">
        <h2>QUOTE</h2>
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 00:47
@MCTwoDigitZero There are some cheatsheet videos on youtube over bootstrap 3
@MCTwoDigitZero make sure there is no width fixed to class box
@stalintouch :arrow_heading_down:
CamperBot
@camperbot
Jul 07 2017 00:48
:bulb: to format code use backticks! ``` more info
CallMeOrange
@EgnaroDev
Jul 07 2017 00:49
@saifsmailbox98 oh.. will remove width
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 00:50
:+1:
Time to go to bed. Bye.
:zzz:
CallMeOrange
@EgnaroDev
Jul 07 2017 00:50
@saifsmailbox98 Bye
Long Nguyen
@longnt80
Jul 07 2017 00:51
@MCTwoDigitZero you shouldn't set height for .box too
@MCTwoDigitZero not a good practice
@MCTwoDigitZero you should let the element inside box to expand the height
CallMeOrange
@EgnaroDev
Jul 07 2017 00:54
@longnt80 I removed then some height of picture and button come out of that box
So can I use padding?
Long Nguyen
@longnt80
Jul 07 2017 00:54
@MCTwoDigitZero yes
CallMeOrange
@EgnaroDev
Jul 07 2017 00:55
@longnt80 Ok on small screen, button went out of that box in the right, how do I fix that?
Long Nguyen
@longnt80
Jul 07 2017 00:55
@MCTwoDigitZero let me take a look
If screen size was iphone's screen size then spinner and button come out of that box too
Is there a way to stop elements coming out of that box?
Long Nguyen
@longnt80
Jul 07 2017 00:58
@MCTwoDigitZero ok, first thing: remove all the margin of .quote and .btn
CallMeOrange
@EgnaroDev
Jul 07 2017 00:58
done
Long Nguyen
@longnt80
Jul 07 2017 01:00
@longnt80 also remove margin-right on .SF
CallMeOrange
@EgnaroDev
Jul 07 2017 01:00
okay
Long Nguyen
@longnt80
Jul 07 2017 01:01
@MCTwoDigitZero for resizing the image, you only need to set the width or the height
stalin
@stalintouch
Jul 07 2017 01:01

Hello all, I need a javascript pro here, anybody who can help. Im trying to complete this algorithm challenge

Implement a function pipe() that takes several functions as arguments and returns a new
function that will pass its argument to the first function, then pass the result to the second, then
pass the result of the second to the third, and so on, finally returning the output of the last
function. In other words, calling pipe(foo, bar, baz)(1, 2, 3) would be equivalent to
calling baz(bar(foo(1,2,3)))

CallMeOrange
@EgnaroDev
Jul 07 2017 01:01
Ok
Long Nguyen
@longnt80
Jul 07 2017 01:01
so you can remove height of .SF
stalin
@stalintouch
Jul 07 2017 01:01
please anybody please
its driving me nuts
CallMeOrange
@EgnaroDev
Jul 07 2017 01:02
@longnt80 I used height and removed width
Long Nguyen
@longnt80
Jul 07 2017 01:02
that's fine
@MCTwoDigitZero now everything is inside the box and we can start style them again
jasonrest
@jasonrest
Jul 07 2017 01:03
I can print out to the webpage just fine listing the results however when I try to prepend the results into the <li>. not going to smoothly.
no error in codepen or local but just listing data.query.search[i].title repeatedly. I know its something simple...
https://codepen.io/jasonrest/pen/QgBWMV?editors=0011
CallMeOrange
@EgnaroDev
Jul 07 2017 01:03
@longnt80 with margins?
Long Nguyen
@longnt80
Jul 07 2017 01:03
@MCTwoDigitZero where do you want the Button to be?
CallMeOrange
@EgnaroDev
Jul 07 2017 01:03
bottom right
Long Nguyen
@longnt80
Jul 07 2017 01:03
@MCTwoDigitZero not with margin
@MCTwoDigitZero ok, in that case, position: absolute is the best solution
Jan Shah
@JanShah
Jul 07 2017 01:04
@jasonrest add jquery
CallMeOrange
@EgnaroDev
Jul 07 2017 01:04
it came out of that box
Long Nguyen
@longnt80
Jul 07 2017 01:05
@MCTwoDigitZero put position: relative; for .box
CallMeOrange
@EgnaroDev
Jul 07 2017 01:05
ah
jasonrest
@jasonrest
Jul 07 2017 01:05
@CentropyIT its already there.
Long Nguyen
@longnt80
Jul 07 2017 01:05
then
jasonrest
@jasonrest
Jul 07 2017 01:05
i thought
Jan Shah
@JanShah
Jul 07 2017 01:06
@jasonrest it wasn't when I checked
Long Nguyen
@longnt80
Jul 07 2017 01:06
@MCTwoDigitZero then
.btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
}
Jan Shah
@JanShah
Jul 07 2017 01:06
and worked as soon as I added it
jasonrest
@jasonrest
Jul 07 2017 01:06
@CentropyIT :o one sec
Jan Shah
@JanShah
Jul 07 2017 01:06
@jasonrest the results aren't coming out right, but there is content in li's
CallMeOrange
@EgnaroDev
Jul 07 2017 01:06
@longnt80 button is still in same place
jasonrest
@jasonrest
Jul 07 2017 01:07
@CentropyIT yeah. which was my main problem on my local text editor
any idea why its doing that.
CallMeOrange
@EgnaroDev
Jul 07 2017 01:08
@longnt80 oops, added bottom and right to .box
but not too close to box
@longnt80 bottom: 5em; right: 7em;
Long Nguyen
@longnt80
Jul 07 2017 01:10
you can change that to your preference
CallMeOrange
@EgnaroDev
Jul 07 2017 01:10
okay
thats what I used
@longnt80 so I can use top, right, bottom, left instead of margins?
Long Nguyen
@longnt80
Jul 07 2017 01:11
@MCTwoDigitZero now add padding-bottom: 10em; to .box so
so that the button stay under the image
CallMeOrange
@EgnaroDev
Jul 07 2017 01:12
what about this? padding: 1em;
keep it both?
Long Nguyen
@longnt80
Jul 07 2017 01:13
@MCTwoDigitZero ok, that's ok
Jan Shah
@JanShah
Jul 07 2017 01:13

@MCTwoDigitZero if you add

<img class="img-fluid" src="yourImage">

you can get rid of .SF and the picture will fit the box perfectly

CallMeOrange
@EgnaroDev
Jul 07 2017 01:14
I dont want it to fit the box :/
Long Nguyen
@longnt80
Jul 07 2017 01:14
@CentropyIT I think he wants the picture on one side
Jan Shah
@JanShah
Jul 07 2017 01:14
it will fit any box you put it in.
<div class="col-sm-6"><img class="img-fluid" src="yourImg.jpg" alt="Simpson Family"></div>
looks perfect, half the page when it's large, full width when it's small

or simply

<div class="col-6">

to force half width all the way

Long Nguyen
@longnt80
Jul 07 2017 01:17
@MCTwoDigitZero what @CentropyIT suggested is good, create columns inside .box to separate the image and the quote+btn
CallMeOrange
@EgnaroDev
Jul 07 2017 01:18
I'll try
Create columns inside .box?
in css?
surferpilgrim
@surferpilgrim
Jul 07 2017 01:18
can you pass an array as the expression in a switch statement?(code below is from the mdn)
switch (expression) {
  case value1:
    //Statements executed when the result of expression matches value1
    [break;]
  case value2:
    //Statements executed when the result of expression matches value2
    [break;]
  ...
  case valueN:
    //Statements executed when the result of expression matches valueN
    [break;]
  [default:
    //Statements executed when none of the values match the value of the expression
    [break;]]
}
Jan Shah
@JanShah
Jul 07 2017 01:18
<div class="box">
        <h2>QUOTE</h2>
        <div class="col-6"><img class="img-fluid" src=
Long Nguyen
@longnt80
Jul 07 2017 01:18
@MCTwoDigitZero using bootstrap column
CallMeOrange
@EgnaroDev
Jul 07 2017 01:19
@longnt80 Can I try to have an image on the left first?
Jan Shah
@JanShah
Jul 07 2017 01:19
amended code will give you that on all screen sizes
above
@MCTwoDigitZero
@surferpilgrim you can pass in a range of values case 1: case 2: case 3: etc
CallMeOrange
@EgnaroDev
Jul 07 2017 01:20
oh @CentropyIT thanks, I thought that would resize an image..
CamperBot
@camperbot
Jul 07 2017 01:20
mctwodigitzero sends brownie points to @centropyit :sparkles: :thumbsup: :sparkles:
:cookie: 452 | @centropyit |http://www.freecodecamp.com/centropyit
Jan Shah
@JanShah
Jul 07 2017 01:21
@MCTwoDigitZero it's boostrap 4, awesome for sorting out layout problems because of it's expanded capabilities
CallMeOrange
@EgnaroDev
Jul 07 2017 01:21
I see
Jan Shah
@JanShah
Jul 07 2017 01:21
you should check out some of the documentation on divs etc, you'll like it
CallMeOrange
@EgnaroDev
Jul 07 2017 01:21
alright
Stephen James
@sjames1958gm
Jul 07 2017 01:22
@surferpilgrim It is possible to use an array as the expression, but since arrays are compared by reference not be the contents the utility seems limited
Long Nguyen
@longnt80
Jul 07 2017 01:22
@MCTwoDigitZero put the quote and button in another column
CallMeOrange
@EgnaroDev
Jul 07 2017 01:23
with col-md-12?
<div class="container-fluid">
  <div class="row">
    <div class="col-md-12">
      <div class="box">
        <h2>QUOTE</h2>
        <div class="col-md-3"><img src="https://s-media-cache-ak0.pinimg.com/736x/61/16/35/6116351e2a9b3b353dd4c03797150fc6--les-simpson-homer-simpson.jpg" alt="Simpson Family" class="SF"></div>
        <h2 class="quote"><i class="fa fa-cog fa-spin"></i>...</h2>
        <button class="btn btn-primary">Quote</button>
      </div>
    </div>
  </div>
</div>
Thats what I have right now
By another column, do you mean adding div element around it with bootstrap columns?
<div class="col-md-12">
        <h2 class="quote"><i class="fa fa-cog fa-spin"></i>...</h2>
        <button class="btn btn-primary">Quote</button>
        </div>
Button is actually in right place where I wanted it to be be
But spinner, just need to move it
Long Nguyen
@longnt80
Jul 07 2017 01:27
@MCTwoDigitZero something like this:
<div class="box">
        <h2>QUOTE</h2>
        <div class="row">
          <div class="col-md-3"><img src="https://s-media-cache-ak0.pinimg.com/736x/61/16/35/6116351e2a9b3b353dd4c03797150fc6--les-simpson-homer-simpson.jpg" alt="Simpson Family" class="SF"></div>
          <div class="col-md-9">
            <h2 class="quote"><i class="fa fa-cog fa-spin"></i>...</h2>
            <button class="btn btn-primary">Quote</button>
          </div>
        </div>
      </div>
CallMeOrange
@EgnaroDev
Jul 07 2017 01:27
@longnt80 I removed padding-bottom, it was too big
Looks like that what I did
silver537
@silver537
Jul 07 2017 01:28
H2 should be inside the new column.
CallMeOrange
@EgnaroDev
Jul 07 2017 01:28
except row is under h2 element
silver537
@silver537
Jul 07 2017 01:28
Nvm
Idk what I'm talking about
CallMeOrange
@EgnaroDev
Jul 07 2017 01:28
lol
silver537
@silver537
Jul 07 2017 01:28
Don't listen to me. Hehehe
CallMeOrange
@EgnaroDev
Jul 07 2017 01:30
@longnt80 Oh that worked
Button and spinner is in good place
Long Nguyen
@longnt80
Jul 07 2017 01:33
@MCTwoDigitZero maybe col-md-3 can be changed to col-3?
CallMeOrange
@EgnaroDev
Jul 07 2017 01:33
hm..
@longnt80 thanks for getting me this far
CamperBot
@camperbot
Jul 07 2017 01:34
mctwodigitzero sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 429 | @longnt80 |http://www.freecodecamp.com/longnt80
surferpilgrim
@surferpilgrim
Jul 07 2017 01:35
is it possible to return an array using a switch statement
CallMeOrange
@EgnaroDev
Jul 07 2017 01:35
@longnt80 same
Long Nguyen
@longnt80
Jul 07 2017 01:35
I add min-height to .box
shivam gupta
@shivamg11000
Jul 07 2017 01:35
@surferpilgrim you can return anything in js
CallMeOrange
@EgnaroDev
Jul 07 2017 01:35
oh
surferpilgrim
@surferpilgrim
Jul 07 2017 01:35
@shivamg11000 it truly is a great language
CallMeOrange
@EgnaroDev
Jul 07 2017 01:35
only difference is button
Long Nguyen
@longnt80
Jul 07 2017 01:36
oh just change to your preferences
shivam gupta
@shivamg11000
Jul 07 2017 01:36
@surferpilgrim you will surely know after somel ater timer after much practise
Long Nguyen
@longnt80
Jul 07 2017 01:36
@MCTwoDigitZero I think you're good to go
CallMeOrange
@EgnaroDev
Jul 07 2017 01:36
@longnt80 yeah, Im thinking of removing picture and button...
Long Nguyen
@longnt80
Jul 07 2017 01:36
let's pull some quote to it
CallMeOrange
@EgnaroDev
Jul 07 2017 01:36
Just quotes and clicking anywhere on html maybe?
Long Nguyen
@longnt80
Jul 07 2017 01:37
@MCTwoDigitZero you don't like the pic anymore?
CallMeOrange
@EgnaroDev
Jul 07 2017 01:37
Its good but looks bad in the box
I think without it and button would be better
Long Nguyen
@longnt80
Jul 07 2017 01:38
@MCTwoDigitZero wait, actually we're not quite done yet
Ednor
@ednor
Jul 07 2017 01:41
Hello guys, can someone tell me how to make hello a variable so I can continue with the challenge ?

function reverseString(str) {
  return str;
}

reverseString("hello");
Long Nguyen
@longnt80
Jul 07 2017 01:43
@MCTwoDigitZero good to go now:
https://codepen.io/longnt80/pen/pwOjEV
Gurpreet SIngh
@Gurpreet3131
Jul 07 2017 01:43
hi I want to access a function in a js file and I am creating a variable and using require for it, this is my code
```
var algoInfo = require('../models/algoInfo');
why is it not working?
giving error , require not found
Long Nguyen
@longnt80
Jul 07 2017 01:45
@MCTwoDigitZero since you mentioned removing the image, I think the better idea would be set a Simpson image as background for the whole page instead
CallMeOrange
@EgnaroDev
Jul 07 2017 01:46
@longnt80 Yeah like Simpson texture
Long Nguyen
@longnt80
Jul 07 2017 01:46
@MCTwoDigitZero yes
CallMeOrange
@EgnaroDev
Jul 07 2017 01:46
Are you leaving soon?
Forget it, when Im done with it, I'll show you
Long Nguyen
@longnt80
Jul 07 2017 01:47
@MCTwoDigitZero you should keep the button thoough because removing it might cause confusing for user
CallMeOrange
@EgnaroDev
Jul 07 2017 01:47
Yeah I thought same thing but like adding a icon?
mouse icon maybe?
Long Nguyen
@longnt80
Jul 07 2017 01:47
if you remove the button, you need to write a note so user know that they can click anywhere to load new quote
CallMeOrange
@EgnaroDev
Jul 07 2017 01:47
Yeah
That way too
Long Nguyen
@longnt80
Jul 07 2017 01:48
ok
CallMeOrange
@EgnaroDev
Jul 07 2017 01:48
Well after quotes, If I think it is not enough I might add picture back
Long Nguyen
@longnt80
Jul 07 2017 01:48
ok
@MCTwoDigitZero I'm gonna be working on something else, so I just leave you with it, ok
show me when you're done with it
CallMeOrange
@EgnaroDev
Jul 07 2017 01:50
Sure
Marlon
@borgatajunky
Jul 07 2017 02:05
function addTwoDigits(n) {return n%10 + Math.floor(n/10)}
Can someone explain why this works for 2 digits and not 3 or 4? I have gone to the calculator and just became more confused. I'm guessing this is recursion. If this doesn't work for more than two digits, what's the formula for going up in numbers? Is there an easy way of memorizing this phenomena lol?
jasonrest
@jasonrest
Jul 07 2017 02:07
how do I get these titles to populate inside of a ul as an <li>?
$(document).ready(function(){

  $('#submit').click(function(){
    var searchTerm = $('#searchTerm').val();

    //api url with search input
    var url = "https://en.wikipedia.org/w/api.php?action=query&titles=" + searchTerm + "&prop=revisions&rvprop=content&format=json&callback=?";

    $.ajax({
      type:"GET",
      url:url,
      data: {action: 'query', list: 'search', srsearch: searchTerm, format: 'json'},
      dataType:'jsonp',
      success: function(data){
        console.log(data.query.search[0].title);
        for(i=0;i<data.query.search.length;i++){
                $('#output').append(data.query.search[i].title);
        }
    },
      error:function(errorMessage){
      alert("Error");
    }     
    }); 
  });
    });
i tried
$('#output').append("<li>data.query.search[i].title</li>");
Tijana Jung
@elsalvadordali
Jul 07 2017 02:21
@jasonrest you can use $('element').html(whatever);
jasonrest
@jasonrest
Jul 07 2017 02:22
@elsalvadordali so do i have to put empty <li> on the page. with an id in order to target them. the example i saw.... the guy was able to just populate the ul with items.
Tijana Jung
@elsalvadordali
Jul 07 2017 02:23
I think you wouldn't need an empty li
Scott Rhoades
@srhoades
Jul 07 2017 02:25
anyone mind looking at my codepen? I can not figure out a JS issue.
SaiChand Duppala
@saichandd
Jul 07 2017 02:25
yep @elsalvadordali is right, you just need to write them as strings in that 'whatever' part
Tijana Jung
@elsalvadordali
Jul 07 2017 02:26
Post it Scott
Tijana Jung
@elsalvadordali
Jul 07 2017 02:26
What's the issue?
Scott Rhoades
@srhoades
Jul 07 2017 02:27
image.png
Paul Christian L. Catoera
@poncatoera
Jul 07 2017 02:27
can anybody explain this to me?
```
function noisy(f) {
  return function(arg) {
    console.log("calling with", arg);
    var val = f(arg);
    console.log("called with", arg, "- got", val);
    return val;
  };
}
noisy(Boolean)(0);
// → calling with 0
// → called with 0 - got false
how come it took 0 as arg when it was not set?
Stephen James
@sjames1958gm
Jul 07 2017 02:32
@poncatoera you are returning a function which gets called with (0)
noisy(Boolean) returns a function
Bennpierce4077
@Bennpierce4077
Jul 07 2017 02:32
m
Diego Mayer
@Chrono79
Jul 07 2017 02:33
@poncatoera Boolean(0) returns false
Paul Christian L. Catoera
@poncatoera
Jul 07 2017 02:33
@sjames1958gm is arg automatically the arguments of a function?
Stephen James
@sjames1958gm
Jul 07 2017 02:34
@poncatoera no you are defining the parameter to be arg.
it is just like any other function
mitron6
@mitron6
Jul 07 2017 02:34
@poncatoera no, arg just happens to be the name of the argument in the function returned by noisy.
Stephen James
@sjames1958gm
Jul 07 2017 02:35
@srhoades The last line should be )};
mitron6
@mitron6
Jul 07 2017 02:35
@poncatoera The main thing to know is that functions can return other functions.
Paul Christian L. Catoera
@poncatoera
Jul 07 2017 02:35
ohhh now i get it
so after calling noisy() it returned a function and took 0 as the argument
mitron6
@mitron6
Jul 07 2017 02:36
@poncatoera Yup
Paul Christian L. Catoera
@poncatoera
Jul 07 2017 02:36
okay thanks @mitron6 @sjames1958gm
CamperBot
@camperbot
Jul 07 2017 02:36
poncatoera sends brownie points to @mitron6 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 762 | @mitron6 |http://www.freecodecamp.com/mitron6
:star2: 8004 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Scott Rhoades
@srhoades
Jul 07 2017 02:36
thanks @sjames1958gm
CamperBot
@camperbot
Jul 07 2017 02:36
srhoades sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8005 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Paul Christian L. Catoera
@poncatoera
Jul 07 2017 02:38
anybody read this book eloquentjs?
Diego Mayer
@Chrono79
Jul 07 2017 02:38
@poncatoera use http://www.pythontutor.com/javascript.html#mode=edit to see the work flow
I think that I dinked up my api call
Paul Christian L. Catoera
@poncatoera
Jul 07 2017 02:40
@Chrono79 thanks
CamperBot
@camperbot
Jul 07 2017 02:40
poncatoera sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4462 | @chrono79 |http://www.freecodecamp.com/chrono79
AlliBun
@AlliBun
Jul 07 2017 02:40
but can't find the issue
Diego Mayer
@Chrono79
Jul 07 2017 02:42
@AlliBun that api doesn't support https
if you try that url in the browser you'll see that
you have to check developer tools to see that kind of errors
CallMeOrange
@EgnaroDev
Jul 07 2017 02:46
Hm had same font for my random quote machine
Tijana Jung
@elsalvadordali
Jul 07 2017 02:51
Alright, I got a stupid question. I'm trying to use .innerHTML to add <li>'s to a <ul>. But when I write ul.innerHTML(whatever), it says that the ul is undefined. But it's in my html, and my js runs after the page loads! Why is it undefined?
CallMeOrange
@EgnaroDev
Jul 07 2017 02:51
how to type ?
”*
Tijana Jung
@elsalvadordali
Jul 07 2017 02:52
Use a backslash before the quotation mark @MCTwoDigitZero
Ken Haduch
@khaduch
Jul 07 2017 02:52
@elsalvadordali - you have to have a variable that points to your <ul> element - there is not automatically a variable created for your <ul> - do you have your code on CodePen or somewhere?
Tijana Jung
@elsalvadordali
Jul 07 2017 02:54
@khaduch Okay. I was just curious because document.body worked, but document.body.ul or just ul didn't...
Guderian Raborg
@hypercuber
Jul 07 2017 02:54
How come this does not work when I put it in Atom editor
    <div id="box-container">
      <div id="box-1"></div>
      <div id="box-2"></div>
    </div>

#box-container {
  display: flex;
  flex-direction: row-reverse;
}

#box-1 {
  background-color: dodgerblue;
  width: 50%;
  height: 50%;
}

#box-2 {
  background-color: orangered;
  width: 50%;
  height: 50%;
}
Tijana Jung
@elsalvadordali
Jul 07 2017 02:56
@hypercuber I think width doesn't work as intended in flexbox. https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Guderian Raborg
@hypercuber
Jul 07 2017 02:58
@elsalvadordali I will check out the link. Thanks! :)
CamperBot
@camperbot
Jul 07 2017 02:58
hypercuber sends brownie points to @elsalvadordali :sparkles: :thumbsup: :sparkles:
:cookie: 298 | @elsalvadordali |http://www.freecodecamp.com/elsalvadordali
Veronica Eulenberg
@HappyViki
Jul 07 2017 02:59
Lol this is funny XD http://bit.ly/IqT6zt
Guderian Raborg
@hypercuber
Jul 07 2017 03:01
@HappyViki :)
Veronica Eulenberg
@HappyViki
Jul 07 2017 03:02
I’m trying to make it not show up.
function addTogether(a) {
  if (arguments[0] && arguments[1]) { 
    if (arguments[0] === Number(arguments[0]) && arguments[1] === Number(arguments[1])) {
      return arguments[0] + arguments[1];
    }
  } else {
    return function(b) {
      if (a === Number(a) && b === Number(b)) {
        return a + b;
      }
    };
  }
}

addTogether("http://bit.ly/IqT6zt");
//console.log(addTogether("http://bit.ly/IqT6zt"));
Ken Haduch
@khaduch
Jul 07 2017 03:03
@elsalvadordali - you can try something like this:
var ullist = document.getElementsByTagName("UL");
ullist[0].innerHTML= "<li>first list item</li>";
CallMeOrange
@EgnaroDev
Jul 07 2017 03:15
@khaduch hey can you take a look at this? $(".quote").html(myQuote[myQuote(Math.floor(Math.random()*myQuote.length))].quote);
Never mind, fixed it
Ken Haduch
@khaduch
Jul 07 2017 03:16
@MCTwoDigitZero - ok... :)
CallMeOrange
@EgnaroDev
Jul 07 2017 03:18
@khaduch How do I get random quotes with a loop?
Instead of Math.floor and Math.random
Ken Haduch
@khaduch
Jul 07 2017 03:19
@MCTwoDigitZero - I don't know what you mean? Math.random is going to generate random numbers, what are you thinking about doing in a loop?
CallMeOrange
@EgnaroDev
Jul 07 2017 03:20
Well maybe loop wont work but if I have JSON object
How do I get same quote with same author?
If they both have random numbers?
Add character with + operator attached to myQuote[random...].quote+.. or create if statements is what I thought of
Ken Haduch
@khaduch
Jul 07 2017 03:22
@MCTwoDigitZero - are you getting quotes from a quote server using an API? Or is this your own internal list of quotes? What does your quote structure look like? Did you do a separate list of quotes and authors?
CallMeOrange
@EgnaroDev
Jul 07 2017 03:23
my own lists
...
{
      quote: "Don’t make me run. I’m full of chocolate.",
      character: " - Üter Zorker"
    }
  ];
Like that
maybe like this? $(".quote").html(myQuote[(Math.floor(Math.random()*myQuote.length))].quote+myQuote[0].character);
Ken Haduch
@khaduch
Jul 07 2017 03:26
@MCTwoDigitZero - generate the random number and save it. You have to use the samenumber to access both the quote and the author, so you would want to have quotes[randomNumber].quote and quotes[randomNumber].character using the same value of randomNumber for each. So generate the number once, use it via a variable to access your data.
CallMeOrange
@EgnaroDev
Jul 07 2017 03:26
okay
Baibhav Gautam
@baibhavx
Jul 07 2017 03:27
@baibhavx
Guys how is my Simon game? Appreciate any feedback/advices. Thank you!
https://codepen.io/baibhavx/full/zzRpQX/
CamperBot
@camperbot
Jul 07 2017 03:27
sorry baibhavx, you can't send brownie points to yourself! :sparkles: :sparkles:
CallMeOrange
@EgnaroDev
Jul 07 2017 03:27
I'll try to create a variable that contain random numbers then use it with myQuotes[...].quote
2895388807
@2895388807
Jul 07 2017 03:30

function queue(arr, item) {
// 请把你的代码写在这里

return item; // 请修改这一行
}

// 初始化测试数据
var testArr = [1,2,3,4,5];

// 控制台输出
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // 你可以修改这一行来测试你的代码
console.log("After: " + JSON.stringify(testArr));

这一题研究了半天也做不出来
写一个函数 queue ,用一个数组arr和一个数字item作为参数。数字item添加到数组的结尾,然后移出数组的第一个元素,最后队列函数应该返回被删除的元素。
adamfaraj
@adamfaraj
Jul 07 2017 03:31
how do i access the parent element of an element?
var button = document.getElementsByClassName('delete');
var parent = document.getElementsByClassName('delete').parentNode;
this isn't working
Ken Haduch
@khaduch
Jul 07 2017 03:31
@baibhavx - your Simon game looks pretty good, but it seems to be a little "jumpy" on the playback. For example, clicking the same color twice in a sequence doesn't really display the button click twice. And it seems to be really quick to start the sequence again on the playback.
Baibhav Gautam
@baibhavx
Jul 07 2017 03:33
Thanks @khaduch yeah I should make the experience more enjoyable and less confusing
CamperBot
@camperbot
Jul 07 2017 03:33
baibhavx sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3073 | @khaduch |http://www.freecodecamp.com/khaduch
CallMeOrange
@EgnaroDev
Jul 07 2017 03:34
@khaduch I got it but only once
var randomNum = (Math.floor(Math.random()*myQuote.length));
  var randomQuote = myQuote[randomNum].quote+myQuote[randomNum].character;
  console.log(randomQuote);
  $("html, body").on("click", function() {
    $(".quote").html(randomQuote);
I could do this instead $(".quote").html(myQuote[randomNum].quote+myQuote[randomNum].character);
adamfaraj
@adamfaraj
Jul 07 2017 03:36
button.parentNode;
this isn't working either
Ken Haduch
@khaduch
Jul 07 2017 03:36
@adamfaraj - try this:
var button = document.getElementsByClassName('delete');
var parent = document.getElementsByClassName('delete')[0].parentNode;
Nick Janne
@njanne19
Jul 07 2017 03:36
Hey all, I'm about to start the Game of Life challenge, but I don't really know how to setup the html for it. I understand the rules of game of life, but I don't understand how to render the cells for it. Tips?
CallMeOrange
@EgnaroDev
Jul 07 2017 03:36
Game of Life is going to be hard
I meant Game of Life looks hard to code
adamfaraj
@adamfaraj
Jul 07 2017 03:37
@khaduch my man!
Ken Haduch
@khaduch
Jul 07 2017 03:37
@MCTwoDigitZero - yes, you need to generate a new random number for each click, so you should move that random number generating inside somewhere that is activated by the click.
adamfaraj
@adamfaraj
Jul 07 2017 03:37
@khaduch should've know that. check out my code
 button[i].addEventListener('click', myFunction, false);
lol. thanks @khaduch
CamperBot
@camperbot
Jul 07 2017 03:37
adamfaraj sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3074 | @khaduch |http://www.freecodecamp.com/khaduch
CallMeOrange
@EgnaroDev
Jul 07 2017 03:38
@khaduch oh, so I cant use a variable that contain it?
Oh nvm I get what you are saying
Ken Haduch
@khaduch
Jul 07 2017 03:40
@MCTwoDigitZero - you need to have the value in a variable so that you can use it twice, to access both the quote and the character, but you have to generate a new one for each click otherwise you get the same quote over and over. So you do something like this:

  //console.log(randomQuote); - this won't work here
  $("html, body").on("click", function() {
     var randomNum = (Math.floor(Math.random()*myQuote.length));
     var randomQuote = myQuote[randomNum].quote+myQuote[randomNum].character;
    $(".quote").html(randomQuote); 
  }
Jan Shah
@JanShah
Jul 07 2017 03:40
@njanne19 you can create divs with an absolute left and top value that represent the xy coordinates of your grid
I used canvas with react
CallMeOrange
@EgnaroDev
Jul 07 2017 03:41
@khaduch Yeah did that
Ken Haduch
@khaduch
Jul 07 2017 03:41
@MCTwoDigitZero - okay, I hope it is working... I'm going to be signing off so good luck with that project!
CallMeOrange
@EgnaroDev
Jul 07 2017 03:42
@khaduch No problem, it should work but doesn't, I'll figure it out thanks
CamperBot
@camperbot
Jul 07 2017 03:42
mctwodigitzero sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3075 | @khaduch |http://www.freecodecamp.com/khaduch
CallMeOrange
@EgnaroDev
Jul 07 2017 03:44
ah forgot to add .quote and .character..
Nick Janne
@njanne19
Jul 07 2017 03:50
@CentropyIT What do you mean absolute left and top value
If I do use the canvas then I wouldn't use divs tho right?
Jan Shah
@JanShah
Jul 07 2017 03:51

position:absolute;
top: (yvalue)
left: (xvalue) <<css

if you use canvas then you're using xy values, no divs

adamfaraj
@adamfaraj
Jul 07 2017 03:55
how do i access both the parents?
<div>
  <button class='delete'>Delete this div</button>
</div>

<div>
  <button class='delete'>Delete this div too</button>
</div>
var button = document.getElementsByClassName('delete');
var parent = button[0].parentNode;
var myFunction = function(){
  console.log(button);
  console.log(parent);
  parent.parentNode.removeChild(parent);
}

for (var i = 0; i < button.length; i++) {
    button[i].addEventListener('click', myFunction, false);
}
adamfaraj
@adamfaraj
Jul 07 2017 04:00
i realize that parent is only being assigned to the first button in the array
but how can i access both of them?
Jan Shah
@JanShah
Jul 07 2017 04:04
@adamfaraj if the variable button is an array, you should be able to iterate over it's values and do the same job without adding much
adamfaraj
@adamfaraj
Jul 07 2017 04:07
@CentropyIT how would i accomplish that?
Jan Shah
@JanShah
Jul 07 2017 04:11

@adamfaraj

var myFunction = function(event){
  console.log(event.target.parentNode);
}

try this to start you off

var button = document.getElementsByClassName('delete');
var myFunction = function(event){
  event.target.parentNode.removeChild(event.target);
}

for (var i = 0; i < button.length; i++) {
    button[i].addEventListener('click', myFunction, false);
}
this works as a complete solution
Munkhmanlai
@munkhmanlai
Jul 07 2017 04:22

Using Objects for Lookups

Objects can be thought of as a key/value storage, like a dictionary. If you have tabular data, you can use an object to "lookup" values rather than a switch statement or an if/else chain. This is most useful when you know that your input data is limited to a certain range.

Here is an example of a simple reverse alphabet lookup:

var alpha = {
  1:"Z",
  2:"Y",
  3:"X",
  4:"W",
  ...
  24:"C",
  25:"B",
  26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"

var value = 2;
alpha[value]; // "Y"

Instructions

Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.

phoneticLookup("alpha") should equal "Adams"
phoneticLookup("bravo") should equal "Boston"
phoneticLookup("charlie") should equal "Chicago"
phoneticLookup("delta") should equal "Denver"
phoneticLookup("echo") should equal "Easy"
phoneticLookup("foxtrot") should equal "Frank"
phoneticLookup("") should equal undefined
You should not use case, switch, or if statements


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

  // Only change code below this line


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




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

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

I know my code is missing something but what though? Help anyone

i feel like i should connect var lookup with val?
2895388807
@2895388807
Jul 07 2017 04:34

function myTest(val) {
// 请只修改这条注释以下的代码

if (val <= 50 && val >= 25) {
return "yes";
}

// 请只修改这条注释以上的代码
return "No";
}

// 你可以修改这一行来测试你的代码
myTest(50);
seems like right, but it can pass the test.

Moisés Man
@moigithub
Jul 07 2017 04:35
which test fails?? what message u get on red ? @2895388807
CallMeOrange
@EgnaroDev
Jul 07 2017 05:13
@moigithub you on?
M-C-Haker
@M-C-Haker
Jul 07 2017 05:18
anyone want to point me in the right direction...?

`
function chunkArrayInGroups(arr, size) {
var newArr = [];
for (i= 0; i < size; i++) {
newArr.push(arr.slice(size - size, size));

}
return newArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);`

just keep getting the first array right but then it just repeats.
Marlon
@borgatajunky
Jul 07 2017 05:25
Try a while loop.
you'd do well to create another var aswell
Marlon
@borgatajunky
Jul 07 2017 05:31

function chunkArrayInGroups(arr, size) {
var newArr = [];
var counter = 0;

while(counter < arr.length){
newArr.push(arr.slice(counter, counter+size));
counter +=size;
}
return newArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

Joseph
@revisualize
Jul 07 2017 05:32
@borgatajunky you should use a for loop for that lesson.
Marlon
@borgatajunky
Jul 07 2017 05:32
what do ya know lol. thanks bud
Joseph
@revisualize
Jul 07 2017 05:34
I'm a Senior Network Systems Administrator with 10 years of experience in professional IT with a focus on Healthcare IT.
So, I think I know quite a bit.
Marlon
@borgatajunky
Jul 07 2017 05:35
no i think u read that wrong
i didnt mean it that way lol
now that i reread it I can see how it may have sounded lol I really do appreciate any help and insight my man
"what do ya know" not "what do YOU know" apologies for misunderstanding
CallMeOrange
@EgnaroDev
Jul 07 2017 05:36
@revisualize Want to take a look at my random quote machine?
There is an issue I need to fix but later :/
Joseph
@revisualize
Jul 07 2017 05:38

@borgatajunky

var counter = 0;
while(counter < arr.length){
   newArr.push(arr.slice(counter, counter+size));
   counter +=size;
}

This code ... is what a for loop is.

@borgatajunky see
for (var counter = 0; counter < arr.length; counter += size;){
   newArr.push(arr.slice(counter, counter+size));
}
Marlon
@borgatajunky
Jul 07 2017 05:39
I do. Thanks again
Joseph
@revisualize
Jul 07 2017 05:40
@borgatajunky see
for (var i = 0; i < arr.length; i += size;){
   newArr.push(arr.slice(i, i+size));
}
@borgatajunky If you can figure out how many times something could loop before processing... for
Marlon
@borgatajunky
Jul 07 2017 05:42
thought it was the other way around. thanks again
Joseph
@revisualize
Jul 07 2017 05:42
@borgatajunky If you don't know how many iterations until a condition will be true.. while
@borgatajunky If you need to do something once and you don't know how many iterations until a condition will be true: do...while
Marlon
@borgatajunky
Jul 07 2017 05:43
gotcha
Joseph
@revisualize
Jul 07 2017 05:44
@borgatajunky A lot of people don't understand the difference
Marlon
@borgatajunky
Jul 07 2017 05:44
forums like this are a huge asset
gentlemen like you with ten years experience still willing to help us noobs out is awesome
thanks again
Joseph
@revisualize
Jul 07 2017 05:46
I worked for McKesson as a Network Admin before I went to college
Just a little company.
Bradley Sands
@sandsbe
Jul 07 2017 05:52
I am getting my absolute butt kicked doing the Advanced Algorithm Scripting challenges. Particularly Exact Change, Inventory Update, and No Repeats. Besides MDN, what is a good source of documentation to really understand some for these "advanced" methods/functions/etc.? Any tips appreciated.
M-C-Haker
@M-C-Haker
Jul 07 2017 05:53
@revisualize so i was all about the for loop for this excersize and completely understood what we're doing here, but upon reviewing the hints (which i do after solving to see different solutions) i see they are citing a while loop as the "advanced" solution. I'm trying to understand the difference between for a while loops and litter better and want to know you opinion on whether it is still more appropriate to use a for loop in this situation because i suppose logically makes sense to do so?
here's what they had

function chunkArrayInGroups(arr, size) {
// Break it up.
var newArr = [];
var i = 0;

while (i < arr.length) {
newArr.push(arr.slice(i, i+size));
i += size;
}
return newArr;
}
chunkArrayInGroups(["a", "b", "c", "d"], 2);

Marlon
@borgatajunky
Jul 07 2017 05:56
thats the same thing I got and posted above. I thought the while loop was preferred there. @revisualize has me rethinking everything I thought I knew. I would also like to learn more about the best practicing here
M-C-Haker
@M-C-Haker
Jul 07 2017 05:58
I mean I agree with him and that's the direction i was slowly heading. But agreed i'm really just looking for feedback on best practices from someone with actual real world experience rather than text-book answers. Also, just because something is more difficult doesn't mean it's better, which this may just amount to.
Bradley Sands
@sandsbe
Jul 07 2017 05:58
@QuincyLarson bananas! Also, good luck with the editor(s) search. Love the content FCC has on Medium.
Marlon
@borgatajunky
Jul 07 2017 05:59
agreed.
codewars and codefights are good for learning best practices in my very little experience.
@M-C-Haker good luck buddy
Bradley Sands
@sandsbe
Jul 07 2017 06:02
Good for learning or drills once you get the understanding? I don't see how I can crank through all of these challenges and then hit such major roadblocks.
M-C-Haker
@M-C-Haker
Jul 07 2017 06:03
@borgatajunky yeah i just heard about those a couple weeks ago, just kind of getting into all this. thanks for the tip. best of luck to you too. I don't think we're getting that answer tonight lol
CamperBot
@camperbot
Jul 07 2017 06:03
m-c-haker sends brownie points to @borgatajunky :sparkles: :thumbsup: :sparkles:
:cookie: 251 | @borgatajunky |http://www.freecodecamp.com/borgatajunky
M-C-Haker
@M-C-Haker
Jul 07 2017 06:04
@sandsbe how far along are you?
edmundgjj
@edmundgjj
Jul 07 2017 06:05
Does anyone know why I get NaN when I console.log? I put an Array of numbers into Math.max function.
var word = "The quick brown fox jumped over the lazy dog";

var newword = word.split(" ");

var wordLength = [];

for (i=0; i<newword.length; i++) {
  wordLength.push(newword[i].length);
}

console.log(wordLength);

var longestWord = Math.max(wordLength);

console.log(longestWord);
Bradley Sands
@sandsbe
Jul 07 2017 06:05
Midway through Advanced Algos. Also have the projects to finish to complete the Front End Certificate.
Claudio Restifo
@Marmiz
Jul 07 2017 06:08

@M-C-Haker In this exercise a for or while are virtually identical since you know how the array is structured.
But In general remember that the more you write the more you are likely to commit an error... so often the best approach is to let "the machine figure it out".

In a for loop you are dictating how many times the iteration should occur. But what if you miscalculated? A wild parameter get passed (obviously not in this exercise, but in a real world scenario could happen) that you didn't consider...

So with a while you are letting the machine figure out how many times it should loop.

This means that when you'll have to debug you have one less thing to worry about: "what if I messed up the loop?"

Make sense?
M-C-Haker
@M-C-Haker
Jul 07 2017 06:09
@sandsbe damn i was hoping I could tell you it gets easier as you go but you're further along than me. Not alone in that feeling though, some things jump out at me and I know exactly or least what I'm trying to do to solve... others not so much. Was hoping it would go away haha
Marlon
@borgatajunky
Jul 07 2017 06:10
@Marmiz ty
CamperBot
@camperbot
Jul 07 2017 06:10
borgatajunky sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 987 | @marmiz |http://www.freecodecamp.com/marmiz
Bradley Sands
@sandsbe
Jul 07 2017 06:11
NOPE. Planning to do a full rehash of the building blocks once I'm done.
M-C-Haker
@M-C-Haker
Jul 07 2017 06:12
@Marmiz sure does. In general, and i'm not sure if you can speak to this but i'll give it ago, irl programming are you writing more for loops, while loops or a good amount of both?
seems like while is preferred is possible?
Bradley Sands
@sandsbe
Jul 07 2017 06:18
@Marmiz Have you checked out the Hints in the challenges after you complete them? They usually have a few different versions of how to solve the answer, from brute-force beginner to elegant advanced. I'd see how often the "experts" use one over the other. I haven't seen many while loops used IMO, although I definitely use them, probably too often.
Claudio Restifo
@Marmiz
Jul 07 2017 06:18

@M-C-Haker there is not a defined answer. Each tool for its usage.
What you have to understand is how/why the methods differ... or in other words how/why they have been created in the first place. What was the need to made them.

That said, nowadays ES6 introduced many new native methods for looping, so you'll see way more map - reduce - filter .... than for.
while is still used a lot for recursive functions.

But don't worry too much about that. Learn that you have a tool, and it exist... then the program needs to work.
The "it can be done better" is something that will always be true, no matter how many times you refactor it

Bradley Sands
@sandsbe
Jul 07 2017 06:19
Maybe the question was from @M-C-Haker
Claudio Restifo
@Marmiz
Jul 07 2017 06:24

@sandsbe elegance comes with an "elegant" way of thinking how to solve a problem.
A lot of time I see some senior's solution and I think to myself: "I didn't thought about that...at all!".

The "thinking about it" comes with practice :)
It's normal that when you start you have more "brute" solutions, but as long as they work they are fine ^^

Alan Alickovic
@alan2207
Jul 07 2017 06:25
@edmundgjj var longestWord = Math.max.apply(null, wordLength); will work
jasonrest
@jasonrest
Jul 07 2017 06:25
Im trying to put a break between the title output and the snippet.
how can I put a break between these... while in jquery on this line... $('#output').prepend("<li><a href = "+ data.query.search[i].title + "> </a><p>"+data.query.search[i].snippet +"</p></li>");
$(document).ready(function(){

  $('#submit').click(function(){
    var searchTerm = $('#searchTerm').val();

    //api url with search input
    var url = "https://en.wikipedia.org/w/api.php?action=query&titles=" + searchTerm + "&prop=revisions&rvprop=content&format=json&callback=?";

    $.ajax({
      type:"GET",
      url:url,
      data: {action: 'query', list: 'search', srsearch: searchTerm, format: 'json'},
      dataType:'jsonp',
      success: function(data){
        console.log(data.query.search[0].title);
        console.log(data);
        for(i=0;i<data.query.search.length;i++){
        $('#output').prepend("<li><a href = "+ data.query.search[i].title + "> </a><p>"+data.query.search[i].snippet +"</p></li>");

        } 
    },
      error:function(errorMessage){
      alert("Error");
    }     
    }); 
  });
    });
Dan Couper
@DanCouper
Jul 07 2017 06:45
Put the a tag inside a p tag. Or use CSS and give the a tag display:block
@jasonrest
M-C-Haker
@M-C-Haker
Jul 07 2017 06:49
@Marmiz thanks for the response, i enjoy hearing different opinions and thoughts on prgramming to get different perspectives on things.
CamperBot
@camperbot
Jul 07 2017 06:49
m-c-haker sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 988 | @marmiz |http://www.freecodecamp.com/marmiz
Baibhav Gautam
@baibhavx
Jul 07 2017 06:49
Hey guys check out Simon Game. Finally got my front end certification. Please give feedback/advice
https://codepen.io/baibhavx/full/zzRpQX/
jasonrest
@jasonrest
Jul 07 2017 06:52
@DanCouper this is so weird. i did the css method. the text is not appearing as it should. maybe I am misunderstanding what data I am getting.
https://codepen.io/jasonrest/pen/QgBWMV?editors=0110
makalohri
@makalohri
Jul 07 2017 07:02
@knrt10 thank you
CamperBot
@camperbot
Jul 07 2017 07:02
makalohri sends brownie points to @knrt10 :sparkles: :thumbsup: :sparkles:
:cookie: 450 | @knrt10 |http://www.freecodecamp.com/knrt10
bitcoinabdi
@bitcoinabdi
Jul 07 2017 07:09
goodevening folks
i need help with interjmediate algorithims
Dan Couper
@DanCouper
Jul 07 2017 07:12
@jasonrest two things to fix first: there is nothing inside the a tag, it is just a tag with an href. And there are extra spaces that will break it a href = should be a href=
(there is a space each side of the =, they shouldn't be there)
jasonrest
@jasonrest
Jul 07 2017 07:14
@DanCouper ok i fixed the spaces but this is what's inside the a tag..... data.query.search[i].title. right?
Dan Couper
@DanCouper
Jul 07 2017 07:30
That you've put in as the href - href=data.query..., so you're just saying that this is an anchor, that is the link, which is assume is not what you want
jasonrest
@jasonrest
Jul 07 2017 07:33
@DanCouper well it kind of is. if i am thinking correctly.
i want the title to appear as a link back to the wikipedia article. and the paragraph to be the description
wait.
wait im sorry. you're right. i need some sleep
Dan Couper
@DanCouper
Jul 07 2017 07:35
Yup, I think you want the title to be the text wrapped in the anchor tag, the link would be different
<a href="link.to.article.html">title.of.article</a>
Also, I would wrap the whole a tag in an h1 (or h2 or 3 or whatever), as it's the title of that section
Viktor Tiutiun
@vittorioVT
Jul 07 2017 07:47
@edmundgjj this will correct var longestWord = Math.max(...wordLength);// we are using operator spred
Aydar
@Aydar350
Jul 07 2017 07:47
Hi there! can you help me with this code:
function testSize(num) {
if (num < 5) { return "Tiny"; }
else if (num < 10) { return "Small";}
else if (num < 15) { return "Medium";}
else if (num < 20) { return "large";}
else if (num >= 20){ return "Huge";}
else { return "Nothing"; }
testSize(15);
it doesn't pass me. Always says that: testSize(15) should return "Large"
but it return "Large" already
Marianissimus
@Marianissimus
Jul 07 2017 07:49
@Aydar350 i guess your function is not closed
Aydar
@Aydar350
Jul 07 2017 07:49

@Marianissimus function testSize(num) {
// Only change code below this line
if (num < 5) { return "Tiny"; }
else if (num < 10) { return "Small";}
else if (num < 15) { return "Medium";}
else if (num < 20) { return "large";}
else if (num >= 20){ return "Huge";}
else { return "Nothing"; }
// Only change code above this line

}
// Change this value to test
testSize(0);

Marianissimus
@Marianissimus
Jul 07 2017 07:50
function name() {if () {} }
Aydar
@Aydar350
Jul 07 2017 07:50
it was closed, I just edited there
Michiel
@MichielHuijse
Jul 07 2017 07:50
@Aydar350 you can also use the markup tool to write code
makes it easier to read :)
Marianissimus
@Marianissimus
Jul 07 2017 07:51
@Aydar350 it works now, doesn't it?
Aydar
@Aydar350
Jul 07 2017 07:51
@MichielHuijse didn't know that, thanks!
CamperBot
@camperbot
Jul 07 2017 07:51
aydar350 sends brownie points to @michielhuijse :sparkles: :thumbsup: :sparkles:
:cookie: 277 | @michielhuijse |http://www.freecodecamp.com/michielhuijse
Aydar
@Aydar350
Jul 07 2017 07:51
@Marianissimus no
Marianissimus
@Marianissimus
Jul 07 2017 07:52
@Aydar350 what error do you get?
Aydar
@Aydar350
Jul 07 2017 07:52
testSize(15) should return "Large"
testSize(17) should return "Large"
Screen Shot 2017-07-07 at 1.52.41 PM.png
Marianissimus
@Marianissimus
Jul 07 2017 07:53
so large should be at (if num <= 15) ?
print screen the challenge conditions, please
Sweet Coding :)
@SweetCodingInc
Jul 07 2017 07:54
@jasonrest I made some changes to your code.. Take a look
Your's was mostly correct
Aydar
@Aydar350
Jul 07 2017 07:54
Screen Shot 2017-07-07 at 1.53.58 PM.png
@Marianissimus still doesn't work
Marianissimus
@Marianissimus
Jul 07 2017 07:55
@Aydar350 i guess it's a bloody typo: try Large, with capital L
Aydar
@Aydar350
Jul 07 2017 07:56
Ohh!
Thanks!
Marianissimus
@Marianissimus
Jul 07 2017 07:56
fcc can be quite strict on that issue. in the future, just copy-paste the strings you need to return
Aydar
@Aydar350
Jul 07 2017 07:57
@Marianissimus it works now, thank you
CamperBot
@camperbot
Jul 07 2017 07:57
aydar350 sends brownie points to @marianissimus :sparkles: :thumbsup: :sparkles:
:cookie: 424 | @marianissimus |http://www.freecodecamp.com/marianissimus
Marianissimus
@Marianissimus
Jul 07 2017 07:57
you're welcome
Finn Pegler
@FinnPegler
Jul 07 2017 08:00

Hi, given an array like

['r##', '###', '#a#']

or

['d##', '##g', '#o#']

I am trying to find out which animal is the correct one (Dog, Rat or Pig). Code is below, the part that I know is wrong is the for each character that is not # (arr1[i].charAt(0)!=="#" == "p").

function check3(arr){
for (var i = 0; i < 3; i++){
if (arr1[i].charAt(0)!=="#" == "p" && arr1[i].charAt(1)!=="#" == "i" && arr1[i].charAt(2)!=="#" == "g"){word1 = "pig"}
if (arr1[i].charAt(0)!=="#" == "d" && arr1[i].charAt(1)!=="#" == "o" && arr1[i].charAt(2)!=="#" == "g"){word1 = "dog"}
if (arr1[i].charAt(0)!=="#" == "r" && arr1[i].charAt(1)!=="#" == "a" && arr1[i].charAt(2)!=="#" == "t"){word1 = "rat"}
}
}
arr1 = ['r##', '###', '###', '10'];
check3(arr1);
CamperBot
@camperbot
Jul 07 2017 08:00
:bulb: to format code use backticks! ``` more info
Marianissimus
@Marianissimus
Jul 07 2017 08:01
@FinnPegler wow, what's this? )!=="#" == "p" &
you need some operators, man. > || or &&
how to do this
Finn Pegler
@FinnPegler
Jul 07 2017 08:03
@Marianissimus I am trying to say "for each character that is not #". How do I say that? So for each character I only want to check if it is equal to a letter if it is not #
Marianissimus
@Marianissimus
Jul 07 2017 08:04
@FinnPegler you don't actually need that, do you? does this work> ? if arr[i].[0] === "p"
@FinnPegler if it's equal to "p", it wont be equal to "#", so why check both conditions?
Victor Popescu
@VicPopescu
Jul 07 2017 08:07
@FinnPegler well, you can iterate a string the same as you iterate an array, so you can do a for loop for each string in your array and there you check. I should avoid statics like charAt(0);
Marianissimus
@Marianissimus
Jul 07 2017 08:07
also, you need to somehow group your conditions in pairs of 2: if ( (thiscondition1 && thatcondition2) && (thiscondition3 && thatcondition4) )
Finn Pegler
@FinnPegler
Jul 07 2017 08:07

I do need something along those lines, because, for instance with this line,

if (arr1[i].charAt(0)!=="#" == "r" && arr1[i].charAt(1)!=="#" == "a" && arr1[i].charAt(2)!=="#" == "t"){word1 = "rat"}

and this array

arr1 = ['r##', '#a#', '###', '10'];

All three && conditions won't be met because a != #

Marianissimus
@Marianissimus
Jul 07 2017 08:09
@FinnPegler this still shouldn't work> !=="#" == "r".
Victor Popescu
@VicPopescu
Jul 07 2017 08:09
@FinnPegler agree with @Marianissimus , you can't realy do that
Finn Pegler
@FinnPegler
Jul 07 2017 08:09
@Marianissimus I understand that. I even mentioned in my original question that I know it is wrong, and asked for another way around it
Victor Popescu
@VicPopescu
Jul 07 2017 08:10
@FinnPegler do nested if's or a switch
Finn Pegler
@FinnPegler
Jul 07 2017 08:10
@VicPopescu I will try a for loop on each string and see how it goes
What is a switch?
Victor Popescu
@VicPopescu
Jul 07 2017 08:11
@FinnPegler and inside that for you do a nested if, something like `if this char is !== #, then go ahead and check if it is a or b or whatever
Finn Pegler
@FinnPegler
Jul 07 2017 08:11
Yep cool thanks, think I can give it a go
Victor Popescu
@VicPopescu
Jul 07 2017 08:11
@FinnPegler good luck
ioakeimo
@ioakeimo
Jul 07 2017 08:18
Hello everyone. I'm looking for some help on something specific. Anyone has experience with html modals+canvas and javascript animation frames?
Ahmed Majdi
@AhmedMJ
Jul 07 2017 08:29
Thanks @renelis @abhisekp @Rafase282 for your help with Algorithm: Falsy Bouncer
CamperBot
@camperbot
Jul 07 2017 08:29
ahmedmj sends brownie points to @renelis and @abhisekp and @rafase282 :sparkles: :thumbsup: :sparkles:
:star2: 3354 | @abhisekp |http://www.freecodecamp.com/abhisekp
:cookie: 413 | @renelis |http://www.freecodecamp.com/renelis
:star2: 1567 | @rafase282 |http://www.freecodecamp.com/rafase282
doridarien
@doridarien
Jul 07 2017 09:37
does anyone use linter jscs package in atom editor?can tell me how to config? Thanks.
korzo
@korzo
Jul 07 2017 09:53
@doridarien as far as I know jscs is abandoned and it merged with ESLint
@doridarien If jscs pugin doesn't work, try ESLint plugin
doridarien
@doridarien
Jul 07 2017 10:00
@korzo thanks for reply. I tried to install esLint but getting some error while installing it. so i gave up.
CamperBot
@camperbot
Jul 07 2017 10:00
:cookie: 223 | @korzo |http://www.freecodecamp.com/korzo
doridarien sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
korzo
@korzo
Jul 07 2017 10:04
@doridarien I tried Atom only once, but ESLint was working fine. Do you remember the error message?
doridarien
@doridarien
Jul 07 2017 10:06
@korzo yes it was npm WARN eslint-config-airbnb@15.0.2 requires
@korzo would you kind enough to guide me how to install it? if you still remember.
korzo
@korzo
Jul 07 2017 10:11
@doridarien Sure. Take a look at this video. If it doesn't work i will install atom and take a look at it.
https://www.youtube.com/watch?v=dEaUikT1-R0
doridarien
@doridarien
Jul 07 2017 10:13
@korzo I actually follow this video but didnt work for me.
korzo
@korzo
Jul 07 2017 10:13
@doridarien Ok, just a moment, I will install Atom and take a look at it. Wha't s your OS?
doridarien
@doridarien
Jul 07 2017 10:14

@korzo ├── UNMET PEER DEPENDENCY eslint@4.1.1
├─┬ eslint-config-rallycoding@3.2.0
│ └── UNMET PEER DEPENDENCY eslint@3.19.0
├── UNMET PEER DEPENDENCY eslint-plugin-import@^2.6.1
└── UNMET PEER DEPENDENCY eslint-plugin-jsx-a11y@6.0.2

npm WARN eslint-config-airbnb@15.0.2 requires a peer of eslint@^3.19.0 but none was installed.
npm WARN eslint-config-airbnb@15.0.2 requires a peer of eslint-plugin-jsx-a11y@^5.1.1 but none was installed.
npm WARN eslint-config-airbnb@15.0.2 requires a peer of eslint-plugin-import@^2.6.1 but none was installed.
npm WARN eslint-config-airbnb-base@11.2.0 requires a peer of eslint@^3.19.0 but none was installed.
npm WARN eslint-config-airbnb-base@11.2.0 requires a peer of eslint-plugin-import@^2.2.0 but none was installed.
npm WARN eslint-plugin-import@1.16.0 requires a peer of eslint@2.x - 3.x but none was installed.

@korzo mine is linux
korzo
@korzo
Jul 07 2017 10:23
@doridarien I'm on Windows right now. Atom is installed, I'm going to try linter-eslint
doridarien
@doridarien
Jul 07 2017 10:23
@korzo Thank you
CamperBot
@camperbot
Jul 07 2017 10:23
:warning: doridarien already gave korzo points
doridarien sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
Jun
@kysnazz
Jul 07 2017 10:26
//How to change animated width??
//EX
<div id = "fill"></div>

#fill {
  width:1px;
  height:145px;
  position:relative;
  bottom:-150px;
  background-color:#adc2eb;
}

$("#fill").animate({width:"485px"},1000);
//How can i change back #fill width to  1px ?
IsmailHusseinCR
@IsmailHusseinCR
Jul 07 2017 10:29
let dog = {
  name: "Spot",
  numLegs: 2,
  numArms: 2,
  sayLegs: function() {console.log( "This dog has " + this.numLegs + this.numArms+ " limbs.");}
};

dog.sayLegs();
can somebody help me how to add these
javascript adds 2+ 2
and returns 22
korzo
@korzo
Jul 07 2017 10:31
@doridarien during the package installation I got popup asking me to install dependencies. Did you get the same?
did you install dependencies?
doridarien
@doridarien
Jul 07 2017 10:32
did you get that inside Atom ?
@korzo no
abraham anak agung
@padunk
Jul 07 2017 10:33
@IsmailHusseinCR what is the final result?
IsmailHusseinCR
@IsmailHusseinCR
Jul 07 2017 10:33
final result @padunk is : This dog has 22 limbs.
but i think javascript just sees it as a string
and so it just adds a string and a string
doridarien
@doridarien
Jul 07 2017 10:36
@korzo if I click dependencies , it show that me eslint is out of date.
IsmailHusseinCR
@IsmailHusseinCR
Jul 07 2017 10:37
@padunk ive tried to parse it into a number but doesnt work also ; like Number(this.numLegs)
abraham anak agung
@padunk
Jul 07 2017 10:38
@IsmailHusseinCR do you want the result become This dog has 4 limbs?
IsmailHusseinCR
@IsmailHusseinCR
Jul 07 2017 10:38
yes @padunk
abraham anak agung
@padunk
Jul 07 2017 10:39
just add (this.arms + this.legs)
korzo
@korzo
Jul 07 2017 10:39
@doridarien Then try to update it. for me ESLint works fine. I'm trying to find why it's not working for you
IsmailHusseinCR
@IsmailHusseinCR
Jul 07 2017 10:39
if i add this.arm+ this.leg
i just get 4
doridarien
@doridarien
Jul 07 2017 10:39
@korzo so I tried to install eslint in terminal "pm install eslint --save-dev" but this also gives me errors.
IsmailHusseinCR
@IsmailHusseinCR
Jul 07 2017 10:39
not the text within it @padunk
doridarien
@doridarien
Jul 07 2017 10:40
@korzo something like this..npm WARN eslint-config-airbnb@15.0.2 requires a peer of eslint@^3.19.0 but none was installed.
IsmailHusseinCR
@IsmailHusseinCR
Jul 07 2017 10:40
sayLegs: function() {console.log( "This dog has " + this.numLegs + this.numArms + " limbs.");}
cuz this is adding it right
abraham anak agung
@padunk
Jul 07 2017 10:40
@IsmailHusseinCR no, i mean add () in your number
IsmailHusseinCR
@IsmailHusseinCR
Jul 07 2017 10:41
ahhh
thats weird tho
why doesnt Number(this.numLegs) etc work
abraham anak agung
@padunk
Jul 07 2017 10:42
this.numLegs is already a Number
IsmailHusseinCR
@IsmailHusseinCR
Jul 07 2017 10:44
alright thanks @padunk
CamperBot
@camperbot
Jul 07 2017 10:44
ismailhusseincr sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 375 | @padunk |http://www.freecodecamp.com/padunk
korzo
@korzo
Jul 07 2017 10:45
@doridarien does ESLint work in terminal?
doridarien
@doridarien
Jul 07 2017 10:46
@korzo How can i check?
korzo
@korzo
Jul 07 2017 10:47
@doridarien do you have installed ESLint locally or globally?
@doridarien either eslint yourfile.js or ./node_modules/.bin/eslint yourfile.js
doridarien
@doridarien
Jul 07 2017 10:49
@korzo I installed locally
@korzo I installed in my project directory from terminal
korzo
@korzo
Jul 07 2017 10:50
@doridarien then try ./node_modules/.bin/eslint yourfile.js in terminal
@korzo Sorry, I forget to mention that at first you need config file
./node_modules/.bin/eslint --init
shivam gupta
@shivamg11000
Jul 07 2017 10:53
what does the keyword which does in terminal
doridarien
@doridarien
Jul 07 2017 10:53
@korzo its asking me some questions.
@korzo Which file(s), path(s), or glob(s) should be examined? What is this?
korzo
@korzo
Jul 07 2017 10:54
@doridarien yes. it will create configuration file
doridarien
@doridarien
Jul 07 2017 10:56
@korzo Im getting error again

@korzo npm WARN eslint-config-airbnb@15.0.2 requires a peer of eslint@^3.19.0 but none was installed.
npm WARN eslint-config-airbnb@15.0.2 requires a peer of eslint-plugin-jsx-a11y@^5.1.1 but none was installed.
npm WARN eslint-config-airbnb@15.0.2 requires a peer of eslint-plugin-import@^2.6.1 but none was installed.
npm WARN eslint-config-airbnb-base@11.2.0 requires a peer of eslint@^3.19.0 but none was installed.
npm WARN eslint-config-airbnb-base@11.2.0 requires a peer of eslint-plugin-import@^2.2.0 but none was installed.
npm WARN eslint-plugin-import@1.16.0 requires a peer of eslint@2.x - 3.x but none was installed.

Automatic Configuration failed. No files were able to be parsed.
Error: Automatic Configuration failed. No files were able to be parsed.
at configureRules (/home/darien/CodePractice/MeteorReact_Project/score-keep/node_modules/eslint/lib/config/config-initializer.js:149:15)
at processAnswers (/home/darien/CodePractice/MeteorReact_Project/score-keep/node_modules/eslint/lib/config/config-initializer.js:257:18)
at inquirer.prompt.then.secondAnswers (/home/darien/CodePractice/MeteorReact_Project/score-keep/node_modules/eslint/lib/config/config-initializer.js:422:26)

alpox
@alpox
Jul 07 2017 10:56
@shivamg11000 which npm tells you where the executable which will be executed when you use the command npm resides
shivam gupta
@shivamg11000
Jul 07 2017 10:57
@alpox I want to remove completly npm
alpox
@alpox
Jul 07 2017 10:57
@shivamg11000 what os?
shivam gupta
@shivamg11000
Jul 07 2017 10:57
ubuntu
alpox
@alpox
Jul 07 2017 10:57
Try
sudo apt-get remove npm
shivam gupta
@shivamg11000
Jul 07 2017 10:58
when I use npm -v it shows the version
@alpox '
after doing that
alpox
@alpox
Jul 07 2017 11:00
How did you install it?
shivam gupta
@shivamg11000
Jul 07 2017 11:01
@alpox I dont remeber
korzo
@korzo
Jul 07 2017 11:01
@doridarien you should exclude node-modules from eslint
abraham anak agung
@padunk
Jul 07 2017 11:03
anyone know what is PUT method is? what is the difference with POST?
alpox
@alpox
Jul 07 2017 11:03
@shivamg11000 and why do you want to remove it?
shivam gupta
@shivamg11000
Jul 07 2017 11:04
@alpox well I am removing all , reactjs , react-dom, node, mpn, nvm, babel
Then I will start from npm and install it
npm*
doridarien
@doridarien
Jul 07 2017 11:05

@korzo UNMET PEER DEPENDENCY eslint@4.1.1
├── UNMET PEER DEPENDENCY eslint-plugin-import@^2.6.1
├── UNMET PEER DEPENDENCY eslint-plugin-jsx-a11y@6.0.2
└── eslint-plugin-react@7.1.0

npm WARN eslint-config-airbnb@15.0.2 requires a peer of eslint@^3.19.0 but none was installed.
npm WARN eslint-config-airbnb@15.0.2 requires a peer of eslint-plugin-jsx-a11y@^5.1.1 but none was installed.
npm WARN eslint-config-airbnb@15.0.2 requires a peer of eslint-plugin-import@^2.6.1 but none was installed.
npm WARN eslint-config-airbnb-base@11.2.0 requires a peer of eslint@^3.19.0 but none was installed.
npm WARN eslint-config-airbnb-base@11.2.0 requires a peer of eslint-plugin-import@^2.2.0 but none was installed.
npm WARN eslint-plugin-import@1.16.0 requires a peer of eslint@2.x - 3.x but none was installed.

@korzo getting this same error.
alpox
@alpox
Jul 07 2017 11:07
@shivamg11000 why removing them all? I understand the removal of react etc. But for that you can just remove the nodemodules folder. For installing a new npm you can update it with npm install - g npm
That command makes npm replace itself
shivam gupta
@shivamg11000
Jul 07 2017 11:07
@alpox bcs I installed the latest one instead of the latest stable one
alpox
@alpox
Jul 07 2017 11:09
Node 8.0 should work nicely. The latest stable will be installed of npm with the command i showed.
If you want to use different versions of node you can use the module n or nvm to change node versions on the fly
doridarien
@doridarien
Jul 07 2017 11:09
@korzo however im getting red box on top right corner in atom editor
shivam gupta
@shivamg11000
Jul 07 2017 11:10
@alpox I will start with learning npm
doridarien
@doridarien
Jul 07 2017 11:10
@korzo Error running esLint
alpox
@alpox
Jul 07 2017 11:11
@doridarien depending on how the extension is made you maybe have to install eslint globally
@doridarien npm install -g eslint
doridarien
@doridarien
Jul 07 2017 11:15
@alpox yes I've tried that.
korzo
@korzo
Jul 07 2017 11:23
@doridarien did you tried it on some other project?
I tried it on clean VM from the start (node.js, Atom, linter-eslint, new project, eslint --init) and it works :(
Stephen James
@sjames1958gm
Jul 07 2017 11:25
@padunk the theory is that post is for create and put is for update, whether that is true is per API implementation
doridarien
@doridarien
Jul 07 2017 11:26
@korzo Thank's okay. Thank u so much for trying. I don't really need it anyway. ill try to figure it out someother day.
CamperBot
@camperbot
Jul 07 2017 11:26
:cookie: 224 | @korzo |http://www.freecodecamp.com/korzo
doridarien sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
doridarien
@doridarien
Jul 07 2017 11:26
@korzo ill try one more time and give up. :worried:
shivam gupta
@shivamg11000
Jul 07 2017 11:27
@alpox I have downloaded the nodejs file from its site, how to make it install , maybe some command like make
alpox
@alpox
Jul 07 2017 11:30
@shivamg11000 on ubuntu you would usually install node through sudo apt-get install nodejs. Else you could hope thed have a. deb file
shivam gupta
@shivamg11000
Jul 07 2017 11:30
@alpox which version will instal with sud apt
alpox
@alpox
Jul 07 2017 11:30
@shivamg11000 Don't build it from source
shivam gupta
@shivamg11000
Jul 07 2017 11:31
@alpox why?
alpox
@alpox
Jul 07 2017 11:32
@shivamg11000 Hmm seems to be a rather old one..
@shivamg11000 Why? because it 1. won't be easily removable anymore (not sure about that) and 2. it takes DAMN LONG
I believe building nodejs from source takes half a day
shivam gupta
@shivamg11000
Jul 07 2017 11:35
@alpox k
alpox
@alpox
Jul 07 2017 11:35
@shivamg11000 What i would do on an ubuntu to install it would be:
sudo apt-get install npm (if its not already installed)
Then sudo npm install -g npm (Update npm)
Then sudo npm install -g n
This installs a node version manager
shivam gupta
@shivamg11000
Jul 07 2017 11:35
installed node -v says v2.4.6
alpox
@alpox
Jul 07 2017 11:36
And then you can do n stable which installs (or uses if already installed) the latest stable version
of node
@shivamg11000 Thats darn old :D
shivam gupta
@shivamg11000
Jul 07 2017 11:36
srry v-4.2.6
alpox
@alpox
Jul 07 2017 11:37
Yea thats what i expected but its still too old
Therefore my list of what i would do
To get the best versions of them all
shivam gupta
@shivamg11000
Jul 07 2017 11:42
@alpox I did all the steps
now when I enter node -v -> nothing
npm -v -> 3.5.3
nvm -> nothing
nodejs -v -> v4.2.6
alpox
@alpox
Jul 07 2017 11:44
@shivamg11000 All the steps?
shivam gupta
@shivamg11000
Jul 07 2017 11:44
yes
alpox
@alpox
Jul 07 2017 11:44
Which was your last step
shivam gupta
@shivamg11000
Jul 07 2017 11:45
n stable
alpox
@alpox
Jul 07 2017 11:45
And that did something? :D
What is the output of it
shivam gupta
@shivamg11000
Jul 07 2017 11:45
@alpox I dont find it there is a lot of output here
alpox
@alpox
Jul 07 2017 11:46
you can clear the console and n stable again
tundeiness
@tundeiness
Jul 07 2017 11:46
hey guys, i need help. I'm trying to store images in an array from an online link. How should I go about it? is the example below the proper way? var Pictures = [ "https://image.ibb.co/f6nak5/tyrion_lannister_FILEminimizer.jpg" class="images" alt="tyrion_lannister_FILEminimizer" border="0", "https://image.ibb.co/d2q0JQ/ned_stark_FILEminimizer.jpg" alt="ned_stark_FILEminimizer" border="0", "https://image.ibb.co/fhyqk5/cersei_lannister_FILEminimizer.jpg" alt="cersei_lannister_FILEminimizer" border="0", "https://image.ibb.co/ehuhXk/syrio_forel_FILEminimizer.jpg" alt="syrio_forel_FILEminimizer" border="0", "https://image.ibb.co/j1iLJQ/tyrion_FILEminimizer.jpg" alt="tyrion" border="0", "https://image.ibb.co/gJy1sk/lord_varys_FILEminimizer.jpg" alt="lord_varys_FILEminimizer" border="0", "https://image.ibb.co/iOLmQ5/arya_stark_FILEminimizer.jpg" alt="arya_stark_FILEminimizer" border="0", 'https://s15.postimg.org/5zood37wn/rodrik-cassel_FILEminimizer.jpg' border='0' alt='postimage', 'https://s18.postimg.org/jpu03fl3p/tyrion_FILEminimizer.jpg' border='0' alt='postimage', "Daenerys.jpg", "Jorah.jpg", "tyrion.jpg", "https://s14.postimg.org/lhrh6wjfh/lord-varys-ollena_FILEminimizer.jpg' border='0' alt='postimage'", 'https://s3.postimg.org/kzpg77cof/lord-varys_FILEminimizer.jpg' border='0' alt='postimage', 'https://s4.postimg.org/n7gdiqk49/Littlefinger_FILEminimizer.jpg' border='0' alt='postimage', 'https://s9.postimg.org/bszqrcgmj/daenerys_targaryen_game_of_thrones_FILEminimize.png' border='0' alt='postimage', 'https://s21.postimg.org/sas75b84z/jaime-lannister_FILEminimizer.jpg' border='0' alt='postimage', 'https://s8.postimg.org/a56qmimg1/ramsay-bolton_FILEminimizer.jpg' border='0' alt='postimage', 'https://s13.postimg.org/wt81t71vn/bran-stark_FILEminimizer.jpg' border='0' alt='postimage', 'https://s13.postimg.org/47gbhjkcz/tywin-lannister_FILEminimizer.jpg' border='0' alt='postimage', 'https://s8.postimg.org/ppx58a7kx/sandor-the-hound-clegane_FILEminimizer.jpg' border='0' alt='postimage', 'https://s18.postimg.org/jpu03fl3p/tyrion_FILEminimizer.jpg' border='0' alt='postimage', 'https://s2.postimg.org/vvtdd7owl/arya-stark_FILEminimizer.jpg' border='0' alt='postimage', 'https://s29.postimg.org/jjzxcruyr/daario-naharis_FILEminimizer.jpg' border='0' alt='postimage', 'https://s16.postimg.org/4vei5gbi9/tyrion-lannister-daenerys_FILEminimizer.jpg' border='0' alt='postimage'];
shivam gupta
@shivamg11000
Jul 07 2017 11:47
@alpox that command flooded the screen with Permission denied and so on
alpox
@alpox
Jul 07 2017 11:47
@tundeiness This cannot be right. Why do you have html attributes in there?
@shivamg11000 Aha well so there was an error
It couldn't be executed
@shivamg11000 then try sudo n stable
Ogundele Olumide
@Lumexralph
Jul 07 2017 11:49
@tundeiness is there an API for images
shivam gupta
@shivamg11000
Jul 07 2017 11:49
@alpox
Is there a difference between node and nodejs
tundeiness
@tundeiness
Jul 07 2017 11:49
@alpox they were pasted on postimage.io since I can't use image directly on codepen.io
alpox
@alpox
Jul 07 2017 11:49
@shivamg11000 Not really - though everything just uses the name node if it wants to call node
tundeiness
@tundeiness
Jul 07 2017 11:50
@Lumexralph nope...this isn't one
shivam gupta
@shivamg11000
Jul 07 2017 11:50
npm -v gives 3.5.2
node -v gives v8.0.0
nodejs -v givves v4.2.6
alpox
@alpox
Jul 07 2017 11:50
@shivamg11000 But try the command i showed sudo n stable because your previous execution had errors. (permission denied)
@shivamg11000 Yup thats fine now
@shivamg11000 nodejs is not needed
It will just be ignored
you can probably uninstall it with sudo apt-get remove nodejs
im not sure why they added the js there >.<
tundeiness
@tundeiness
Jul 07 2017 11:51
@Lumexralph codepen does not allow direct images and I was trying create an array of images using postimage.io as link.
@Lumexralph maybe github is better as a repository
shivam gupta
@shivamg11000
Jul 07 2017 11:52
@alpox I think node -v8.0.0 is the latest but not the stable one
node -v

now npm -v says

No such file or directory

Stephen James
@sjames1958gm
Jul 07 2017 11:54
7.7.3 is the current stable at least according to nvm
alpox
@alpox
Jul 07 2017 11:54
You have the stable official release
shivam gupta
@shivamg11000
Jul 07 2017 11:54
@sjames1958gm how to install nodejs , npm stable versions
alpox
@alpox
Jul 07 2017 11:54
@shivamg11000 If you want LTS latest stable release you can do: sudo n lts
Ogundele Olumide
@Lumexralph
Jul 07 2017 11:55
@tundeiness try it out
Stephen James
@sjames1958gm
Jul 07 2017 11:55
Well I used n in the past, but switched to nvm because cloud9 used it.
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash this will install nvm
then
nvm install stable
tundeiness
@tundeiness
Jul 07 2017 11:56
@Lumexralph okay...but how do I store save it in github
shivam gupta
@shivamg11000
Jul 07 2017 11:56
nodejs installed v6
npm is not installed
@alpox
alpox
@alpox
Jul 07 2017 11:57
@shivamg11000 ?
Did you uninstall npm?
shivam gupta
@shivamg11000
Jul 07 2017 11:57
@alpox npm -v -> command not fund
nope
alpox
@alpox
Jul 07 2017 11:57
Or did npm come with the apt-get install?
Ogundele Olumide
@Lumexralph
Jul 07 2017 11:57
@tundeiness can you use github for that? not tried it before....
shivam gupta
@shivamg11000
Jul 07 2017 11:58
@alpox I dont know
alpox
@alpox
Jul 07 2017 11:58
@shivamg11000 sudo apt-get install npm was the one installing it
So i wonder how it came away
tundeiness
@tundeiness
Jul 07 2017 11:58
@Lumexralph I think so...someone gave me a heads up about it.
alpox
@alpox
Jul 07 2017 11:58
Maybe you have to try that one again
shivam gupta
@shivamg11000
Jul 07 2017 11:58
I am on master in installing packages on ubuntu
no*
I think when uninstalled nodejs, it was removed with that
npm -v
alpox
@alpox
Jul 07 2017 12:00
@shivamg11000 Probably yes. which is weird though. Some apt-get crap :D
Ogundele Olumide
@Lumexralph
Jul 07 2017 12:00
@tundeiness then tell the person to tell you how..... to create an array of url links and using it in your code? I can only think of using module for that
shivam gupta
@shivamg11000
Jul 07 2017 12:00
with installing npm , nodejs also instlled
alpox
@alpox
Jul 07 2017 12:00
@shivamg11000 I guess you'd have to install npm again with sudo apt-get install npm and update it with sudo npm install -g npm
nodejs installed with npm?=
Man is apt-get crap
shivam gupta
@shivamg11000
Jul 07 2017 12:00
I think so
tundeiness
@tundeiness
Jul 07 2017 12:01
@Lumexralph hmmm. what's the syntax for module?
alpox
@alpox
Jul 07 2017 12:01
@shivamg11000 I guess you'd have to leave it on the system then
I don't know why it should do that... its just dumb
Ogundele Olumide
@Lumexralph
Jul 07 2017 12:01
@tundeiness you can create a module that exports the array and you can require that file/code in your main code and then use the links but don't know if codepen will allow, I hate codepen though
shivam gupta
@shivamg11000
Jul 07 2017 12:02
@alpox it shows npm -v3.5.2
after updating
alpox
@alpox
Jul 07 2017 12:02
@shivamg11000 Or maybe it uses nodejs for using it as its own version of node to be able to run :D
@shivamg11000 Okay alrigh
Then you have to install the node manager again - either nvm or n
sudo npm install -g n
Ogundele Olumide
@Lumexralph
Jul 07 2017 12:03
@tundeiness the idea of module is just getting data from another JS script to your script, but don't know if codepen would allow
shivam gupta
@shivamg11000
Jul 07 2017 12:04
@alpox after that
nvm -v command not found
alpox
@alpox
Jul 07 2017 12:04
@shivamg11000 Yea its n
shivam gupta
@shivamg11000
Jul 07 2017 12:04
Why the devs have made the installing the ware like thi
alpox
@alpox
Jul 07 2017 12:04
If you did that
@shivamg11000 I said nvm or n :D they are 2 things which do the same thing
You therefore now have https://www.npmjs.com/package/n
And you can install the latest stable with sudo n lts
shivam gupta
@shivamg11000
Jul 07 2017 12:05
command pls
for npm
alpox
@alpox
Jul 07 2017 12:05
?
sudo npm install -g nvm?
n and nvm do the same btw
shivam gupta
@shivamg11000
Jul 07 2017 12:06
how to check it succeded
nvm -v
alpox
@alpox
Jul 07 2017 12:06
If it succeeded you got no error
tundeiness
@tundeiness
Jul 07 2017 12:07
@Lumexralph okay
shivam gupta
@shivamg11000
Jul 07 2017 12:07
npm WARN deprecated nvm@0.0.4: This is NOT the correct nvm. Visit http://nvm.sh and use the curl command to install it.
/usr/local/bin/nvm -> /usr/local/lib/node_modules/nvm/bin/nvm
+ nvm@0.0.4
added 1 package in 2.336s
@alpox
why installing software is hard
on ubuntu
alpox
@alpox
Jul 07 2017 12:08
@shivamg11000 You installed nvm now yes
shivam gupta
@shivamg11000
Jul 07 2017 12:08
then
alpox
@alpox
Jul 07 2017 12:08
Its not hard :-)
Its just unusual for people coming from a GUI
shivam gupta
@shivamg11000
Jul 07 2017 12:08
I am on linux from 6 months
alpox
@alpox
Jul 07 2017 12:08
Well you get used to it
sudo nvm install lts
shivam gupta
@shivamg11000
Jul 07 2017 12:09
still its hard to install packages whether its git ot pip or anythin other
alpox
@alpox
Jul 07 2017 12:09
Hmm i kinda like it
Much more than through a GUI
I don't have much trouble with it
Its just a few commands
shivam gupta
@shivamg11000
Jul 07 2017 12:09
well it boots up faster
in 5 sec
shutdowns in 2s
alpox
@alpox
Jul 07 2017 12:10
yea
shivam gupta
@shivamg11000
Jul 07 2017 12:10
It says This is not the package you are looking for: please go to http://nvm.sh
alpox
@alpox
Jul 07 2017 12:11
Oh
Ah
Yea right i forgot the nvm on npm is only a stub
To tell you that nvm is not installable through npm
But i wonder why not just use n
Do you for some reason need nvm over n?
shivam gupta
@shivamg11000
Jul 07 2017 12:12
@alpox nope only nodejs and npm
alpox
@alpox
Jul 07 2017 12:12
@shivamg11000 Well then you can just do sudo n lts
That should install the latest stable node
shivam gupta
@shivamg11000
Jul 07 2017 12:13
same thing npm -v 3.5.2
alpox
@alpox
Jul 07 2017 12:13
Yea npm
But you were installing node
node -v
shivam gupta
@shivamg11000
Jul 07 2017 12:13
node is installed
v6.11.0
alpox
@alpox
Jul 07 2017 12:13
Ah yes thats the stable one
Now for the proper npm version
sudo npm install -g npm
Should be 5.0.1
i hope
It will anyways install the right version for you
shivam gupta
@shivamg11000
Jul 07 2017 12:14
same thing
v3.5.2
alpox
@alpox
Jul 07 2017 12:15
Alright
Seems that is the recommended one then
Stephen James
@sjames1958gm
Jul 07 2017 12:15
@alpox I only switched to nvm because I was using cloud9 and they use nvm
alpox
@alpox
Jul 07 2017 12:15
I believe i installed the latest
Stephen James
@sjames1958gm
Jul 07 2017 12:15
npm should get installed with node.
alpox
@alpox
Jul 07 2017 12:15
@sjames1958gm Ah alright. I for some reason also have nvm installed, but i would go with n next time
@sjames1958gm Yes, it is. The question was more the version
Stephen James
@sjames1958gm
Jul 07 2017 12:16
ah, ok
shivam gupta
@shivamg11000
Jul 07 2017 12:16
now what for npm stable version
alpox
@alpox
Jul 07 2017 12:16
I run npm 5.0.1 with node 8.0.0
@shivamg11000 You got your npm stable version
shivam gupta
@shivamg11000
Jul 07 2017 12:16
but its 5.1.0
alpox
@alpox
Jul 07 2017 12:16
Where do you see that
shivam gupta
@shivamg11000
Jul 07 2017 12:17
I remeber its v-5 something
from somewhere
alpox
@alpox
Jul 07 2017 12:17
@shivamg11000 Looks to me like its the latest
Not lts
Zack Novosad
@zacknovosad
Jul 07 2017 12:18

Could use some help on this one:

So I think I'm misunderstanding how .filter() works. I thought that as long as the value met the conditions you put into the callback function it would append to the new array but in my code the callback is just being evaluated down to the value and it's saying that the value isn't a function...Which makes sense but I can't figure out how to stop it.

Any help here?

https://www.freecodecamp.com/challenges/seek-and-destroy

function removeValues(value, arg) {
  if(value != arg) {
    return value;
  }
}

function destroyer(arr) {
  console.log(arr);
  filtered = [];

  for(var i = 0; i < arr.length; i++) {
    for(var j = 1; j < arguments.length; j++) {
      filtered = arr.filter(removeValues(arr[i], arguments[j]));
    }
  }

  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
alpox
@alpox
Jul 07 2017 12:18
@shivamg11000 But oh well, then try sudo npm install -g npm@latest
That oughta do it
shivam gupta
@shivamg11000
Jul 07 2017 12:19
still the same thing
alpox
@alpox
Jul 07 2017 12:19
@shivamg11000 Can you show the output of the installation?
I don't believe its the same thing as long as there is no error :D
shivam gupta
@shivamg11000
Jul 07 2017 12:20
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
+ npm@5.1.0
updated 1 package in 8.616s
alpox
@alpox
Jul 07 2017 12:20
@shivamg11000 It installed 5.1.0
maybe restart your computer once
shivam gupta
@shivamg11000
Jul 07 2017 12:20
but npm -v shows
3.5.2
alpox
@alpox
Jul 07 2017 12:21
which npm
@zacknovosad arr.filter(removeValues(arr[i], arguments[j])); is no valid use of .filter. You are right, you have to give a callback function, but what you give to filter is the return value of a call to removeValues - which is either undefined or value
And undefined or an item of the array are no valid callback functions ;-)
alpox
@alpox
Jul 07 2017 12:27
@zacknovosad Also, filter already loops through the array. No need for a forloop to loop over the array in addition
shivam gupta
@shivamg11000
Jul 07 2017 12:28
ok now I have the stable npm and node , ty
alpox
@alpox
Jul 07 2017 12:28
:thumbsup:
Zack Novosad
@zacknovosad
Jul 07 2017 12:28
@alpox Thanks for the reply!
It just clicked . Thanks again!
CamperBot
@camperbot
Jul 07 2017 12:28
zacknovosad sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1235 | @alpox |http://www.freecodecamp.com/alpox
shivam gupta
@shivamg11000
Jul 07 2017 12:28
@alpox now can you give me all the commands to install node and npm stable one , so I can copy and paste it somewhere
alpox
@alpox
Jul 07 2017 12:29
@shivamg11000
sudo apt-get install npm
sudo npm install -g npm@latest
sudo npm install -g n
sudo n lts
shivam gupta
@shivamg11000
Jul 07 2017 12:29
ty @alpox
CamperBot
@camperbot
Jul 07 2017 12:29
shivamg11000 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1236 | @alpox |http://www.freecodecamp.com/alpox
alpox
@alpox
Jul 07 2017 12:30
@shivamg11000 np
shivam gupta
@shivamg11000
Jul 07 2017 12:30
what
alpox
@alpox
Jul 07 2017 12:31
@shivamg11000 Hm?
np == no problem :-)
shivam gupta
@shivamg11000
Jul 07 2017 12:31
@alpox ok tg
Bomee
@Bomulacious
Jul 07 2017 12:40
https://www.freecodecamp.com/challenges/falsy-bouncer As a first step I'm thinking of making it an array first (correct me if I'm wrong), when I do, how could I know up to which point is the first element? How do I differentiate it from the rest arguments(which have now turned to an array element)?
Diego Mayer
@Chrono79
Jul 07 2017 12:42
@Bomulacious try posting some code so we can understand what you meant there
your function's argument already is an array, if you want to create another array so you compare one against the other that won't work (at least not in this case)
Bomee
@Bomulacious
Jul 07 2017 12:44
@Chrono79 sorry! I meant to post this link https://www.freecodecamp.com/challenges/seek-and-destroy
i didn't write any code because I coudl'nt figure out the process yet
alpox
@alpox
Jul 07 2017 12:45
@Bomulacious The first parameter, which is already an array, is stored in the variable arr
Diego Mayer
@Chrono79
Jul 07 2017 12:45
@Bomulacious ok, now that's a different story ;)
alpox
@alpox
Jul 07 2017 12:45
@Bomulacious You can read the rest of the arguments from the arguments object - from index 1 up
Diego Mayer
@Chrono79
Jul 07 2017 12:45
to get the other arguments you need to use arguments object, there is a link there to MDN docs about them
IggySmith
@IggySmith
Jul 07 2017 12:50
Would somebody mind explaining this differently to me please
image.png
Muhammad Umair Atiq
@UmairAtiq
Jul 07 2017 12:51
var myStr="Firstline\n\SecondLine\\rThirdLine";
myStr should have encoded text with the proper escape sequences and no spacing. ???
alpox
@alpox
Jul 07 2017 12:51
@IggySmith It wants you to take each input numbers and multiply the variable product with them.
Ravi Kishore Thella
@ravikishorethella
Jul 07 2017 12:51
@UmairAtiq no spacing?
Diego Mayer
@Chrono79
Jul 07 2017 12:51
@UmairAtiq FirstLine
IggySmith
@IggySmith
Jul 07 2017 12:52
@alpox so i*= ?
alpox
@alpox
Jul 07 2017 12:52
@IggySmith The tweak is that the numbers are given to you in a two-dimensional array. (Means it is kind of a matrix of numbers)
you have to loop over the rows and columns of the two-dimensional array to get the single numbers
Muhammad Umair Atiq
@UmairAtiq
Jul 07 2017 12:52
@Chrono79 still not solve
@ravikishorethella yes
alpox
@alpox
Jul 07 2017 12:52
@IggySmith Probably not i. They want you to multiply to product, not to i
Diego Mayer
@Chrono79
Jul 07 2017 12:53
@UmairAtiq check the order for the escaped sequences
Ravi Kishore Thella
@ravikishorethella
Jul 07 2017 12:53
@UmairAtiq you need to use one more \ before and after SecondLine
Muhammad Umair Atiq
@UmairAtiq
Jul 07 2017 12:53
image.png
alpox
@alpox
Jul 07 2017 12:53
@IggySmith The example code on the left shows you how you can loop over the two-dimensional array
Diego Mayer
@Chrono79
Jul 07 2017 12:53
@ravikishorethella he used it, try quoting him, the chat hides it
Muhammad Umair Atiq
@UmairAtiq
Jul 07 2017 12:54
@ravikishorethella still not slove
Ravi Kishore Thella
@ravikishorethella
Jul 07 2017 12:54
@Chrono79 sorry, I didn't see that
Diego Mayer
@Chrono79
Jul 07 2017 12:54
@UmairAtiq I still see Firstline, change the l to L
Ravi Kishore Thella
@ravikishorethella
Jul 07 2017 12:54
@UmairAtiq FirstLine not Firstline
Muhammad Umair Atiq
@UmairAtiq
Jul 07 2017 12:55
@Chrono79 oh thanks got it :)
CamperBot
@camperbot
Jul 07 2017 12:55
umairatiq sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4463 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 07 2017 12:55
@UmairAtiq check more info below too, so you see how to format your code for the chat
CamperBot
@camperbot
Jul 07 2017 12:55
:bulb: to format code use backticks! ``` more info
Muhammad Umair Atiq
@UmairAtiq
Jul 07 2017 12:55
@ravikishorethella thanks
CamperBot
@camperbot
Jul 07 2017 12:55
umairatiq sends brownie points to @ravikishorethella :sparkles: :thumbsup: :sparkles:
:cookie: 917 | @ravikishorethella |http://www.freecodecamp.com/ravikishorethella
Ravi Kishore Thella
@ravikishorethella
Jul 07 2017 12:55
@UmairAtiq :thumbsup:
IggySmith
@IggySmith
Jul 07 2017 12:55
@alpox kudos. thanks. light bulb moment lol
CamperBot
@camperbot
Jul 07 2017 12:55
iggysmith sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1237 | @alpox |http://www.freecodecamp.com/alpox
Diego Mayer
@Chrono79
Jul 07 2017 12:56
:+1:
alpox
@alpox
Jul 07 2017 12:56
@IggySmith :D :thumbsup:
Pedro Almeida
@pmqa
Jul 07 2017 13:31
hey guys, what’s the best way to filter an array to a new array of objects based on a condition and return only a property of the objects?
with es6
Diego Mayer
@Chrono79
Jul 07 2017 13:31
@pmqa filter and map
or reduce and concat
Pedro Almeida
@pmqa
Jul 07 2017 13:32
map replicates the array, if the condition is not met it always returns an undefined
  • checking reduce *
Diego Mayer
@Chrono79
Jul 07 2017 13:33
filter().map()
filter does the filtering there, not map
map is so you return only a property of the objects
Pedro Almeida
@pmqa
Jul 07 2017 13:34
oh I get it, but wouldn’t map return an undefined for the other properties?
Diego Mayer
@Chrono79
Jul 07 2017 13:34
reduce and concat seems faster tho
bilaal-s
@bilaal-s
Jul 07 2017 13:34
Getting the error: not all code paths return a value. I am posting this c# in the hopes someone understands, apologies... theres no active c# room i can access and it is pretty basic logic
using System;

public class Kata
{
  public static long FindNextSquare(long num)
  {
    double checkInt = Math.Sqrt(num);
    if (checkInt % 1 != 0) {
      return -1; 
    } else {
    double nextSquare = num;
    double checkInt2;
    do {
        nextSquare = Math.Sqrt(nextSquare);
        nextSquare += 1;
        Math.Pow(nextSquare, 2);
        checkInt2 = Math.Sqrt(nextSquare);
        if (checkInt2 % 1 == 0) {
          return (long)nextSquare;
        }
      } while (checkInt2 % 1 != 0);
    }
  }
}
is my do while infinite or something? the thing with c# is every mnethod has to return something
Diego Mayer
@Chrono79
Jul 07 2017 13:35
@pmqa paste an example of the array, so I can understand you better
@bilaal-s I don't know c#, but the error there maybe it's related to you haven't a return after the while
checkInt2 is undefined, but do while should work, at least 1 time doesn't it?
Pedro Almeida
@pmqa
Jul 07 2017 13:37
thanks for the direction @Chrono79 I want to figure it out myself, though. can’t be lazy :)
CamperBot
@camperbot
Jul 07 2017 13:37
pmqa sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4464 | @chrono79 |http://www.freecodecamp.com/chrono79
NicholasGalarza
@NicholasGalarza
Jul 07 2017 13:37
@bilaal-s I know Java which is pretty darn close to c#, I'm trying to understand what is going on here so give me a few lol.
bilaal-s
@bilaal-s
Jul 07 2017 13:38
@NicholasGalarza cool! shall i give you the link for the codewars challenge?
NicholasGalarza
@NicholasGalarza
Jul 07 2017 13:38
@bilaal-s oh cool! I'll check it out!
bilaal-s
@bilaal-s
Jul 07 2017 13:39
@Chrono79 yeah exactly the do while should work! that's why i cant figure it out, unfortunately, codewars doesnt have a console x(
Diego Mayer
@Chrono79
Jul 07 2017 13:39
@bilaal-s couldn't you use repl.it?
bilaal-s
@bilaal-s
Jul 07 2017 13:39
@Chrono79 ill try that now
@Chrono79 gracias for the idea
CamperBot
@camperbot
Jul 07 2017 13:40
bilaal-s sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4465 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 07 2017 13:40
:+1:
IggySmith
@IggySmith
Jul 07 2017 13:45
image.png
Can somebody point out where I went wrong please
NicholasGalarza
@NicholasGalarza
Jul 07 2017 13:47

@bilaal-s So since the problem statement is requires you to just find the next square, I think you are making your solution a tad too complicated because of all of the value transfers in your code.
It is confusing for me to trace but I can give you an idea on what to do
So you can just iterate through a for loop making the sent in parameter (num) your starting value and you can make the conditional to terminate the loop something like: Math.sqrt(num) % 1 == 0. So as soon as that conditional is hit, you would return the value of num since that would be the next square.

Now, in your code, I noticed that you are squaring your number which isn't necessary (unless you were logging those values to see when a square value will pop up). I still cannot say why you code is going in a infinite loop though... hmm

Diego Mayer
@Chrono79
Jul 07 2017 13:48
@bilaal-s I have a solution for that Kata in javascript, it seems far easier than that
NicholasGalarza
@NicholasGalarza
Jul 07 2017 13:48
@Chrono79 Yeah, he is overthinking it lol.
Marianissimus
@Marianissimus
Jul 07 2017 13:48
@IggySmith prop is not a string in if.hasOwnProperty(prop)
Diego Mayer
@Chrono79
Jul 07 2017 13:48
I have problems to convert it to C# tho, with the casting and such :P
bilaal-s
@bilaal-s
Jul 07 2017 13:50
@NicholasGalarza @Chrono79 I really do complicate things xD i hope i will get better with time, thank you for the idea, will try the for loop method. you should see my solution for some of the intermediate challeneges, over 100 lines xD
CamperBot
@camperbot
Jul 07 2017 13:50
bilaal-s sends brownie points to @nicholasgalarza and @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: bilaal-s already gave chrono79 points
:cookie: 289 | @nicholasgalarza |http://www.freecodecamp.com/nicholasgalarza
Diego Mayer
@Chrono79
Jul 07 2017 13:51
@bilaal-s my solution doesn't even use a loop ;)
NicholasGalarza
@NicholasGalarza
Jul 07 2017 13:51
euuuu fancy!
bilaal-s
@bilaal-s
Jul 07 2017 13:51
@Chrono79 jheeze haha
NicholasGalarza
@NicholasGalarza
Jul 07 2017 13:51
Is it one of those tasty O(1) solutions? :D
Diego Mayer
@Chrono79
Jul 07 2017 13:52
yes
NicholasGalarza
@NicholasGalarza
Jul 07 2017 13:52
hawt! xD
Diego Mayer
@Chrono79
Jul 07 2017 13:53
If the parameter is itself not a perfect square, than -1 should be returned. You may assume the parameter is positive.
you don't need a loop there
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 13:56
@IggySmith Line 36 :hasOwnProperty() must be passed with the variable prop and not the string "prop". Also, return "No such contact" once the search in done(that is, after the for loop), Line 37 to access the property use the contacts array, not contact. Line 34 define i with var.
IggySmith
@IggySmith
Jul 07 2017 14:00
always with the typos... thanks @saifsmailbox98 @Marianissimus
CamperBot
@camperbot
Jul 07 2017 14:00
iggysmith sends brownie points to @saifsmailbox98 and @marianissimus :sparkles: :thumbsup: :sparkles:
:cookie: 428 | @marianissimus |http://www.freecodecamp.com/marianissimus
:cookie: 732 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Moisés Man
@moigithub
Jul 07 2017 14:20
Math.Pow(nextSquare, 2); what this line does ??
does it changes the value of nextSquare ?? @bilaal-s
Zack Novosad
@zacknovosad
Jul 07 2017 14:21
When using filter() should the callback function return values? I'm asking because my understanding of filter() is such that it just appends whatever value is returned from the callback function to the new array...or is that wrong?
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 14:22
@zacknovosad callback should return true or false
@zacknovosad the filter(), iterates over the elements and if the callback returns true that element will get pushed to the final array.
Zack Novosad
@zacknovosad
Jul 07 2017 14:23
@saifsmailbox98 Ok cool. I'm assuming if its true it gets appended
@saifsmailbox98 ok yeah
@saifsmailbox98 thank you
CamperBot
@camperbot
Jul 07 2017 14:23
zacknovosad sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 734 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Cole Maly
@malycole
Jul 07 2017 14:33
is there a way to make characters lowercase using regex in JS? or am I just stuck using a function?
Zack Novosad
@zacknovosad
Jul 07 2017 14:33
@saifsmailbox98 is there a way to compare the element its iterating on to another value for example:
```
Jan Shah
@JanShah
Jul 07 2017 14:33
why do you want to use regex? @malycole
Zack Novosad
@zacknovosad
Jul 07 2017 14:34
function removeValues(value, arg) {
  var flag = false;
  if(value != arg) {
    flag = true;
  }
  return flag;
}
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 14:34
@zacknovosad yes, with another values of the same array?
Zack Novosad
@zacknovosad
Jul 07 2017 14:34
where value is the element in the array
and arg is a completely different variable
Cole Maly
@malycole
Jul 07 2017 14:35
@CentropyIT I've always struggled with regex and I'm really trying to understand it so it doesnt seem so mystical
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 14:35
@zacknovosad yeah, you can compare with whatever you want to.
Jan Shah
@JanShah
Jul 07 2017 14:36
@malycole I've used it a few times, it doesn't get easier unless you use it regularly and very easy to forgt. There is a way to change to lowercase
Saif Ur Rahman
@saifsmailbox98
Jul 07 2017 14:36
@zacknovosad look there are only two parameters in the definition, but three values are being passed on to the function, to access those extra values checkout https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments
Cole Maly
@malycole
Jul 07 2017 14:37
@CentropyIT ok, the challenge I'm working wants everything in spinal case so it would be really easy to just force everything to lowercase but I feel like that is a more brute force approach and would take up more time than a regex expression
Jan Shah
@JanShah
Jul 07 2017 14:38
@malycole you could probably do it in regex, but better off using toUpperCase and toLowerCase