These are chat archives for FreeCodeCamp/HelpJavaScript

14th
Aug 2017
luccifer00
@luccifer00
Aug 14 2017 00:00

https://codepen.io/luccifer00/pen/YxxjxE?editors=0011

i am getting crazy with this .... why i can not get the rest of the results on my new div created?? is the loop wrong set??

i am always getting the last array
Stephen James
@sjames1958gm
Aug 14 2017 00:22
@luccifer00 You need to append, to your created div, not just set it
@luccifer00 You could do html += data[1][i]+ "<br>"+ data[2][i]+" <a href="+data[3][i]+">Read more</a>";
Then set innerHTML after the loop - not sure if that is the styling you want.
@luccifer00
      var html = "";
      for (var i =0; i<data[1].length;i++){
        document.body.appendChild(div);
        div.setAttribute('id', 'article') ;
       div.setAttribute('class', 'jumbotron');
        html += data[1][i]+ "<br>"+ data[2][i]+" <a href="+data[3][i]+">Read more</a>";
     }
      div.innerHTML = html;
Tai Jones
@taiJones00
Aug 14 2017 00:35
@jimtryon so um. What are we buying? XD
Ginger
@GingerChew
Aug 14 2017 00:57
I'm really getting stuck on this diff two arrays campsite project. I'm trying to get it to compare the two arrays but I can't figrue out how to identify which of the arrays has the wrong word...
I'm looking at the docs for .filter() .splice() and .indexOf() but I'm not sure how they all fit together?
Stephen James
@sjames1958gm
Aug 14 2017 00:59
You can filter one array removing values that are in the other (use indexOf to search the other array)
Then do the same swapping the two arrays and then concat the two results
Ginger
@GingerChew
Aug 14 2017 01:01
hmmmmm, okay, I'll try and do that
@sjames1958gm thanks!
CamperBot
@camperbot
Aug 14 2017 01:01
gingerchew sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8311 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 14 2017 01:04
@GingerChew good luck
Ginger
@GingerChew
Aug 14 2017 02:00
So here's what I got figured out so far
function diffArray(arr1, arr2) {
  var newArr = [];
  // Same, same; but different.
  var trashCan = [];
  var arrLength = Math.max(arr1.length,arr2.length);

  function present1(val) {
    return arr1.indexOf(val);
  }
  newArr = arr2.filter(present1);

  return newArr;
}

diffArray(
  ['diorite', 'andesite', 'grass', 'dirt', 'pink wool', 'dead shrub'],
  ['diorite', 'andesite', 'grass', 'dirt', 'dead shrub']
);
it returns elements starting from andesite to dead shrub
I'm not sure what I'm doing that is making it not return diorite
Ken Haduch
@khaduch
Aug 14 2017 02:41
@GingerChew - you want to return the array values that do not exist in both arrays, correct? So you really have to compare both arrays against each other, because if an element is on array1 and not array2 (or vice versa) then you won't be searching for it with a search of only one array. You should get two filters of arr1 vs arr2, and then arr2 vs arr1, and combine the two. And you want your .filter() to return a true or false result - the .indexOf method is going to return numeric values, most of which will be coerced to true...
Ken Haduch
@khaduch
Aug 14 2017 03:03
@GingerChew - the reason why you aren't returning diorite is that your arr1.indexOf("diorite") is going to return the index value 0, which will be equivalent to a false value, so it will not keep that particular array element. It is the wrong way to be using .indexOf, but that is why it is not keeping diorite and keeping everything else.
LovingVi
@LovingVi
Aug 14 2017 03:15

'''
function destroyer() {
var arr;
arr = arguments[0].filter(function(val){
return val !== argumrnts[1] && val !== arguments[2];
})
return arr;
}

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

CamperBot
@camperbot
Aug 14 2017 03:15
:bulb: to format code use backticks! ``` more info
Ken Haduch
@khaduch
Aug 14 2017 03:18
@LovingVi - details on code posting format can be found here in the forum.
@LovingVi - looks like misspelled "arguments" in your line that starts with return
and you might have to be careful if there are more than three values in arguments, or less than 3 values, because you are hardcoding that use of the arguments array.
LovingVi
@LovingVi
Aug 14 2017 03:22
So I have to confirm how many arguments of this function first ?
Ken Haduch
@khaduch
Aug 14 2017 03:24
@LovingVi - you should write your code to take the length of the arguments array into account by some means, yes. Just as you write a for loop to work with an array to use arr.length as a test condition, similar things can be done with arguments to build code that will work with any number of elements in the arguments array.
Ruchika Sharma
@ruchika90
Aug 14 2017 03:35
@Manish-Giri ty it works
CamperBot
@camperbot
Aug 14 2017 03:35
ruchika90 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6408 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ken Haduch
@khaduch
Aug 14 2017 03:37
@sandsbe - Were you just looking for comments or did you have any particular questions? The pomodoro timer seems to be working pretty well, one thing that is missing is a sound at the end of the timer periods. Unless you are sitting there watching the clock, you wouldn't know that the time was up for either work or break?
hillsie
@Hillsie
Aug 14 2017 04:02
Hi there , wondering what solutions you have for titleCase problem. here’s mine
function titleCase(str) {
    var titleCase = str.toLowerCase().split(" ");
    for(var i = 0; i < titleCase.length; i++){
        titleCase[i]=(titleCase[i][0].toUpperCase() + titleCase[i].slice(1, titleCase[i].length));
    }
  return (titleCase.join(" "));
}
console.log(titleCase("this is a lowercase string to convert to title case"));
console.log(titleCase("THIS IS MY UPPERCASE STRING TO CONVER TO TITLE CASE"));
console.log(titleCase("THIS'll test UPPercase, lowercase, commas and apostrophies"));
Bradley Sands
@sandsbe
Aug 14 2017 04:06
@khaduch honestly, its been about 2 weeks since I finished a project so I just wanted to brag and maybe get some feedback.
Regarding the sound, it wasn't a user story, but you're not the first person to mention that.
Moisés Man
@moigithub
Aug 14 2017 04:06
return str.toLowerCase().replace(/(^|\s)[a-z]/g, t=>t.toUpperCase())
@Hillsie
LovingVi
@LovingVi
Aug 14 2017 04:06

I dont know how to ergodic this arr , and return the element that not equal to arguments[1]...arguments[i];
for example

function destroyer(arr) {
  var x = arguments.length;

  return arr;
}

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

I want get [1,5,1]

Bradley Sands
@sandsbe
Aug 14 2017 04:06
Do you think it's a key learning aspect of the exercise?
heroiczero
@heroiczero
Aug 14 2017 04:07
@sandsbe Well it works, and it does fullfill the user story. Not the prettiest, but good job :+1: What counts is that it works :+1:
Bradley Sands
@sandsbe
Aug 14 2017 04:08
@heroiczero HA. Isn't that why designers and developers are two separate jobs?? Honestly, all my stuff is super ugly, thank goodness for Bootstrap!
CamperBot
@camperbot
Aug 14 2017 04:08
sandsbe sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1606 | @heroiczero |http://www.freecodecamp.com/heroiczero
heroiczero
@heroiczero
Aug 14 2017 04:11
@LovingVi you can make the arguments into an array and use filter https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
Claudio Restifo
@Marmiz
Aug 14 2017 04:11
@LovingVi i see you used arguments, have you got the full documentation?
It's fairly easy to create an array of arguments.
Once you have that, all you have to do is to check if arr and the new argument arr share some values
hillsie
@Hillsie
Aug 14 2017 04:12
@moigithub Thanks. I guess regular expressions is one way of doing it.
CamperBot
@camperbot
Aug 14 2017 04:12
hillsie sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3581 | @moigithub |http://www.freecodecamp.com/moigithub
heroiczero
@heroiczero
Aug 14 2017 04:14
@Hillsie you could also use forEach or map instead of a for loop
Tai Jones
@taiJones00
Aug 14 2017 04:17
What's the hardest JavaScript project out of the first four
hillsie
@Hillsie
Aug 14 2017 04:20
@heroiczero :thumbsup:
Bradley Sands
@sandsbe
Aug 14 2017 04:25
Anyone know how to make a new directory in node?
Claudio Restifo
@Marmiz
Aug 14 2017 04:28
@sandsbe what you mean "in node"?
the standard command in bash/shell to make a new directory from the command line is
mkdir <dir name>
Make sure to have the correct path as well
Bradley Sands
@sandsbe
Aug 14 2017 04:29
@Marmiz . Thanks. So, "standard command in bash/shell" means nothing to me at this point. Is there a list somewhere of commands or things I should know?
CamperBot
@camperbot
Aug 14 2017 04:29
sandsbe sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1020 | @marmiz |http://www.freecodecamp.com/marmiz
Claudio Restifo
@Marmiz
Aug 14 2017 04:33
@sandsbe bash/shell is the unix-linux command line from terminal. If you are a Window user it uses a different command language called DOS.
Depending on your system, look up online and find a list of basic command to learn to use the computer from command line instead of using the mouse and standard interface.
But those are not connected to Node, so I'm not sure what are you asking exactly
Bradley Sands
@sandsbe
Aug 14 2017 04:35
Got it. I'm in the "node" section of the fCC program, hence my thinking it was Node. It asks you to work in an environment from Cloud9, pretty cool.
Claudio Restifo
@Marmiz
Aug 14 2017 04:49

@sandsbe Cloud9 is an IDE, or to make it simple is a dev environment already set up for you... It's way more useful for compiled languages like C/C++.
But still I remember the first time I started working on backend.... it felt good, like a "real programmer" :)

Have fun and happy coding :D

none
@shayne2013
Aug 14 2017 04:55
well
Bradley Sands
@sandsbe
Aug 14 2017 05:00
thanks @Marmiz
CamperBot
@camperbot
Aug 14 2017 05:00
sandsbe sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:warning: sandsbe already gave marmiz points
mithun
@dmithun
Aug 14 2017 05:08

function rot13(str) { // LBH QVQ VG!

var s = str.split('');

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

        s[i] = String.fromCharCode( s[i].charCodeAt(0)-13);
}
return s.join(" ");

}

help me guys
heroiczero
@heroiczero
Aug 14 2017 05:11
@dmithun you have to -13 or +13 depending on you letter
@dmithun see the unicode in decimal from here: http://unicodelookup.com/
@dmithun [A-Z] is 65 to 90
mithun
@dmithun
Aug 14 2017 05:13
how to add +13 @heroiczero
i understand it, but don't know how to do it?????????
heroiczero
@heroiczero
Aug 14 2017 05:16
@dmithun so you want to do three conditions
@dmithun
1.) if it is a special character like a . or ? you just want to return it.
2.) If it is the charCode-13>=65 you can subtract -13.
prakash chandra yadav
@prakashyadav008
Aug 14 2017 05:20
hey everyone a little help here
heroiczero
@heroiczero
Aug 14 2017 05:21
3.) else you want to +13
prakash chandra yadav
@prakashyadav008
Aug 14 2017 05:21
how do i append a "canvas" element inside a "figure" html element
mithun
@dmithun
Aug 14 2017 05:26
@heroiczero thankx for the help :)
CamperBot
@camperbot
Aug 14 2017 05:26
dmithun sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1608 | @heroiczero |http://www.freecodecamp.com/heroiczero
Gulsvi
@gulsvi
Aug 14 2017 05:34

@prakashyadav008 Your code is close. Change this code:

  document.getElemntById("icons").innerHTML = '<canvas id="clear-day" width=64 height=64></canvas>';
  var icons = new Skycons({"color": "black"});
  icons.set("clear-day", Skycons.CLEAR_DAY);
  icons.play();

To:

  document.getElementById("icons").innerHTML = '<canvas id="clear-day" width=64 height=64></canvas>';
  var icons = new Skycons({"color": "black"});
  icons.add(document.getElementById("clear-day"), "clear-day");
  icons.play();
prakash chandra yadav
@prakashyadav008
Aug 14 2017 05:35
document.getElementById("icons").innerHTML = '<canvas id="clear-day" width=64 height=64></canvas>';
  var icons = new Skycons({"color": "black"});
  icons.set("clear-day", Skycons.CLEAR_DAY);
  icons.play();
this works @SkyC0der
Gulsvi
@gulsvi
Aug 14 2017 05:35
small typo with getElemntById and .set, should probably be .add though both will likely work. Plus "clear-day" will work on most browsers, but document.getElementById("clear-day") is more accurate
prakash chandra yadav
@prakashyadav008
Aug 14 2017 05:36
var canv = document.createElement("canvas");
  canv.id = "clear-day";
  canv.width = 64;
  canv.height = 64;
  document.getElementById("icons").appendChild(canv);
and this too @SkyC0der
.set was given by the skyicons documentation
Gulsvi
@gulsvi
Aug 14 2017 05:37
.set is for changing existing icons

From the docs:

// want to change the icon? no problem:
skycons.set("icon1", Skycons.PARTLY_CLOUDY_NIGHT);

prakash chandra yadav
@prakashyadav008
Aug 14 2017 05:38
ill be changing the icon depending on the weather summary so i think .set will work better
Gulsvi
@gulsvi
Aug 14 2017 05:41
Okay, if you want to have a default icon that gets overwritten when you get the weather, your final code would be:
document.getElementById("icons").innerHTML = '<canvas id="clear-day" width="64" height="64"></canvas>';
  var icons = new Skycons({"color": "black", "resizeClear": true});
  icons.set(document.getElementById("clear-day"), "clear-day");
  icons.play();
There is no need to create a canvas element and append it to your icons div when you're already adding a <canvas> element with the innerHTML method in the first line above
So, this code is not needed:
var canv = document.createElement("canvas");
  canv.id = "clear-day";
  canv.width = 64;
  canv.height = 64;
  document.getElementById("icons").appendChild(canv);
^^ That's the same as:
document.getElementById("icons").innerHTML = '<canvas id="clear-day" width="64" height="64"></canvas>';
Jefferson
@jeffersonnnn
Aug 14 2017 06:26
hi guys, can i get help with the mutations bon fire? Here is my code

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

}
mutation(["hello", "hey"]);
Markus Kiili
@Masd925
Aug 14 2017 06:31
@jeffersonnnn Can you return true based on the first looped character?
mithun
@dmithun
Aug 14 2017 06:41

function rot13(str) { // LBH QVQ VG!

var s = str.split('');

for (var i = 0; i < s.length; i++) {
    if(s[i].charCodeAt(0)>=77){
      s[i] = String.fromCharCode( s[i].charCodeAt(0)-13);
    }
  else if(s[i].charCodeAt(0)<77){
     s[i] = String.fromCharCode( s[i].charCodeAt(0)+13);
  }


}
return s.join(" ").replace(/[^a-zA-Z ]/g, "");

}

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

kumquatfelafel
@kumquatfelafel
Aug 14 2017 06:42
@dmithun you don't want to get rid of punctuation, e.g. you just don't want to change it.
iirc
Markus Kiili
@Masd925
Aug 14 2017 06:42
@dmithun First you need to test whether the character is at range A-Z, and change the charcode only if it is.
kumquatfelafel
@kumquatfelafel
Aug 14 2017 06:43
:point_up:
Markus Kiili
@Masd925
Aug 14 2017 06:43
@kumquatfelafel Morning.
kumquatfelafel
@kumquatfelafel
Aug 14 2017 06:43
hey :)
technically, it's 3 here, but fell asleep at 8:30 so.... i'll take it :laughing:
(morning)
LovingVi
@LovingVi
Aug 14 2017 06:47
Hello, I have some confusion about my
kumquatfelafel
@kumquatfelafel
Aug 14 2017 06:47
ask away :)
LovingVi
@LovingVi
Aug 14 2017 06:49

Hello, I have some confusion about my code,

function where(arr, num) {
  arr.splice(1,0,num);
  function sort(a,b){
    return a - b;
  }   
  arr.sort();
  var index;
  for(var i = 0;i < arr.length;i++){
    if(arr[i] == num){ 
      index = i; 
      break;
    }
  }
  return index;
}
where([5, 3, 20, 3], 5);

I want getthe index of the element first appears, but that "break" dosen't working......

kumquatfelafel
@kumquatfelafel
Aug 14 2017 06:52
@LovingVi https://repl.it/KIkm Try running this (ignore stuff at top)
Now try running this. https://repl.it/KIkm/1
Markus Kiili
@Masd925
Aug 14 2017 06:55
@LovingVi The default sort is not numerical sort.
Manish Giri
@Manish-Giri
Aug 14 2017 06:55
@LovingVi arr.sort();
you should know
this sorts by unicode values
kumquatfelafel
@kumquatfelafel
Aug 14 2017 06:55
:point_up: :point_down:
Manish Giri
@Manish-Giri
Aug 14 2017 06:56
it doesn't sort integers, by default.
lol
@kumquatfelafel :sparkles:
Brett Burtson
@bburtson
Aug 14 2017 06:57
@LovingVi does it not work for you to return from within the body of your for loop?
if(arr[i] ==num) return i;
i dont know if that supports or implementation here but it will exit the loop an return control to the caller
kumquatfelafel
@kumquatfelafel
Aug 14 2017 06:58
And it's not aware of your defined function, sort(a,b). You have to pass that into the sort function in order to get it to sort in that specific way.
Brett Burtson
@bburtson
Aug 14 2017 07:03
@Masd925 where do you work?
Markus Kiili
@Masd925
Aug 14 2017 07:04
@bburtson Small software company in Finland.
Brett Burtson
@bburtson
Aug 14 2017 07:04
@Masd925 I remember seeing you in here like 4 months ago
Markus Kiili
@Masd925
Aug 14 2017 07:04
@bburtson ok.
Brett Burtson
@bburtson
Aug 14 2017 07:05
@Masd925 your profile shows you crazy active you spend alot of time here
@Masd925 You just like to help?
kumquatfelafel
@kumquatfelafel
Aug 14 2017 07:05
@bburtson returning inside works fine too. You're basically guaranteed to find the value since it has been added to array at start of function. Sure, someone might haphazardly change that at a later point (but that would pretty much require rewriting entire for loop anyway)
LovingVi
@LovingVi
Aug 14 2017 07:05
0.0 I know!!!It seems that I have to learn more about the basics......
kumquatfelafel
@kumquatfelafel
Aug 14 2017 07:05
@Manish-Giri my calling as a crossing guard. :p
Markus Kiili
@Masd925
Aug 14 2017 07:06
@bburtson Yeah. Mostly looking for heated arguments over some petty JS details.
Brett Burtson
@bburtson
Aug 14 2017 07:06
@Masd925 well that sounds like a waste of your time lol
@Masd925 I suppose not if you enjoy it lol
@Masd925 or are you the peace keeper
kumquatfelafel
@kumquatfelafel
Aug 14 2017 07:07
Helping others often drags up interesting concepts and keeps the brain active
Markus Kiili
@Masd925
Aug 14 2017 07:07
@bburtson Arguments with clever people is the highest form of education.
Helping people is nice too.
Brett Burtson
@bburtson
Aug 14 2017 07:09
@Masd925 Hmm, i disagree... >: ] DING DING argument started.
@Masd925 jk
kumquatfelafel
@kumquatfelafel
Aug 14 2017 07:09

Helping people is nice too...
@Masd925 Hmm, i disagree

Well you're heartless then! :o

:p

Brett Burtson
@bburtson
Aug 14 2017 07:10
@kumquatfelafel personal foul "out of context"
kumquatfelafel
@kumquatfelafel
Aug 14 2017 07:10
< escalation
Brett Burtson
@bburtson
Aug 14 2017 07:10
@kumquatfelafel ;)
Can any of you guys give me an analogy ... in the most laymans of fashions
"Time and space complexity"
Brett Burtson
@bburtson
Aug 14 2017 07:12
I mean => as if you were talking to a child... or perhaps a farmer who left school at grade 5 to farm like my granfasther
I want it from you guys tho
because its interactive and more funny
and it will adhere to the brain much better
Markus Kiili
@Masd925
Aug 14 2017 07:14
@bburtson How the cost of execution of some code depends on the size of the input data. You can calculate it for number of relevant steps (~time) or used memory (space).
Brett Burtson
@bburtson
Aug 14 2017 07:14
Okay.. so
if i could give you a rediculous example and you tell me if im on the right track
so
hmmm
Wait
welp maybe not answer me this @Masd925 is there a point in an apps developmet life cycle, or a particular part of an application in which we are focusing on time and space complexity more often?
Brett Burtson
@bburtson
Aug 14 2017 07:19
or is it part of our practice all the time as developers because the high level understanding is that we are trying to keep our code robust and efficient? right?
or is it simply to get past the interview and never talk about it again
and howcome my converstaions never last
Markus Kiili
@Masd925
Aug 14 2017 07:21
@bburtson Usually avoiding stupid algorithms that slow down the code is enough. Sometimes efficiency is so important that you need to use efficient algorithms, so it is good to undestand about efficiency too.
Brett Burtson
@bburtson
Aug 14 2017 07:22
Markus would you be willing to peek at my porfolio and tell me if it looks like th portfolio of somone who is hired easily for an entry level career at worst?
Markus Kiili
@Masd925
Aug 14 2017 07:23
@bburtson Don't know anything about recruiting things, so someone else is better.
Brett Burtson
@bburtson
Aug 14 2017 07:24
@Masd925 Of course, Appreciate it.
@Masd925 What technologies do you work with in your current job if you dont mind me prying
Markus Kiili
@Masd925
Aug 14 2017 07:25
@bburtson JS and AngularJS and HTML5/CSS3.
Brett Burtson
@bburtson
Aug 14 2017 07:28
@Masd925 let me ask you this if i scaffold a new project with ng new from the cli what version of angular would i be using
latest stable?
Manish Giri
@Manish-Giri
Aug 14 2017 07:29
if your cli is the latest version
your app would be the 4.x version
Brett Burtson
@bburtson
Aug 14 2017 07:31
@Manish-Giri thanks man
CamperBot
@camperbot
Aug 14 2017 07:31
bburtson sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6411 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Aug 14 2017 07:31
@bburtson :+1:
Brett Burtson
@bburtson
Aug 14 2017 07:31
1.12
1.1.2
derp
1.2.2
Manish Giri
@Manish-Giri
Aug 14 2017 07:31
lol
Brett Burtson
@bburtson
Aug 14 2017 07:31
guess its time to google unless you know offhand
1.2.2 is latest?
Markus Kiili
@Masd925
Aug 14 2017 07:33
@bburtson I think 1.6.4
Then there is the new Angular which is completely different from AngularJS 1.x.x
versions 2+
Brett Burtson
@bburtson
Aug 14 2017 07:34
is the @Component({})
decorators
Brett Burtson
@bburtson
Aug 14 2017 07:34
just reading taht @Manish-Giri
Manish Giri
@Manish-Giri
Aug 14 2017 07:34
1.0.0-beta.28.3 is the latest of 88 releases
Brett Burtson
@bburtson
Aug 14 2017 07:36
image.png
are there any project configuration files that would tell me what version on angular these apps i made are this is crazy
making apps dont even know what versions im using
Claudio Restifo
@Marmiz
Aug 14 2017 07:38
It's written in your package.json
Brett Burtson
@bburtson
Aug 14 2017 07:38
OMG looking lol sec
  "dependencies": {
    "@angular/animations": "^4.0.0",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "ngx-bootstrap": "^1.8.0",
    "rxjs": "^5.4.1",
    "zone.js": "^0.8.14"
  }
ding ding ding i think its safe to say its v 4
nice thanks @Marmiz
CamperBot
@camperbot
Aug 14 2017 07:40
bburtson sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1021 | @marmiz |http://www.freecodecamp.com/marmiz
Morchid Chellali
@Morched23MJ
Aug 14 2017 07:45
Is the algorithm 'Roman Numeral Converter' too long, or I'm taking the long way?
Brett Burtson
@bburtson
Aug 14 2017 07:48
@Masd925 your tribute page is pretty awesome
Chris Juchtmans
@kjuchtmans
Aug 14 2017 08:18
a wonderfully sunny morning to all coders! :wave:
Alexander Domikov
@AlexanderDom
Aug 14 2017 08:19
thanks Chris you too :)
LovingVi
@LovingVi
Aug 14 2017 08:22
···js
function rot13(str) { // LBH QVQ VG!
  var arr = [];
  for(var i = 0; i < str.length;i++){
    if(/[A-Za-z]+/.test(str[i])){
      arr[i] = str.charCodeAt(i)-13;
    }else{
      arr[i] = str.charCodeAt(i);
    }
  }
  var STR = "";
  for(var n =0 ; n < arr.length;n++){
    STR += String.fromCharCode(arr[n]);
  }
  return STR;
}

rot13("SERR PBQR PNZC");
the result is "F8EE C5DE CAM6",but the answer is "FREE CODE CAMP"
kumquatfelafel
@kumquatfelafel
Aug 14 2017 08:24
Note that the letters that are failing come early in the alphabet.
You need to make those guys wrap back around, or they'll go to earlier values in the ascii table.
Chris Juchtmans
@kjuchtmans
Aug 14 2017 08:25

"Inventory Update" challenge:
what would be a useful accumulator to employ in my reduce method?

I would like to start my solution with a well-written reduce method, for the sake of practice.
My code starts thusly:

  return arr1.reduce(function(acc, item){
    while(arr1[0][1] > 0 && arr2.has(item)){
      return acc;
    }

with the second line trying to implement this logic: if inventory has item, and new delivery has it too, then update inventory amount for said item

how can my acc usefully express this updating?
any tips welcome!
cheers, chris

LovingVi
@LovingVi
Aug 14 2017 08:25
@kumquatfelafel OK!TKS
kumquatfelafel
@kumquatfelafel
Aug 14 2017 08:27
@kjuchtmans
while (blah) {
  return something; //this only returns once.
}
Chris Juchtmans
@kjuchtmans
Aug 14 2017 08:28
@kumquatfelafel so, that would not be an appropriate way to let reduce iterate, you mean?
kumquatfelafel
@kumquatfelafel
Aug 14 2017 08:29
I mean that a loop doesn't make sense when it always returns on first iteration.
Markus Kiili
@Masd925
Aug 14 2017 08:30
@bburtson You must be referring to the debugging of the page ;)
Chris Juchtmans
@kjuchtmans
Aug 14 2017 08:30

i stumbled upon this post advocating a more generalized use of reduce, to solve any array iteration or string handling problem.

Now I'm looking to implement that in my present challenge

kumquatfelafel
@kumquatfelafel
Aug 14 2017 08:31
need to review inventory update challenge to provide more substantive advice though
Chris Juchtmans
@kjuchtmans
Aug 14 2017 08:31
@kumquatfelafel thanks anyway, your remarks certainly makes sense
CamperBot
@camperbot
Aug 14 2017 08:31
kjuchtmans sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 604 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Markus Kiili
@Masd925
Aug 14 2017 08:33
@kjuchtmans I used arr1 as the initial accumulator on my reduce solution.
And used the reduce upon arr2.
Chris Juchtmans
@kjuchtmans
Aug 14 2017 08:35
@Masd925 right, let me grab a cup of :tea: over that
@Masd925 thanks
CamperBot
@camperbot
Aug 14 2017 08:35
kjuchtmans sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4405 | @masd925 |http://www.freecodecamp.com/masd925
kumquatfelafel
@kumquatfelafel
Aug 14 2017 08:37
@kjuchtmans Now I feel like :tea: too... :p
Chris Juchtmans
@kjuchtmans
Aug 14 2017 08:37
@kumquatfelafel with falafel
Claudio Restifo
@Marmiz
Aug 14 2017 08:48
Hello lovely people, someone knows how to "export" (ie save somewhere) the whole Redux state?
Morchid Chellali
@Morched23MJ
Aug 14 2017 08:55
function pairElement(str) {
  str = str.split('');

  for (var i = 0; i < str.length; i++)
    switch (str[i]) {
      case 'A':
        str[i].push('T');
        break;
      case 'T':
        str[i].push('A');
        break;
      case 'G':
        str[i].push('C');
        break;
      case 'C':
        str[i].push('G');
        break;
    }

  return str;
}
What's wrong with my function? error: Syntax error: unexpected token ;
I check console couldn't find where is this ;
Claudio Restifo
@Marmiz
Aug 14 2017 08:56
@Morched23MJ there's no open { in the first for
Morchid Chellali
@Morched23MJ
Aug 14 2017 08:57
There is only one statemenent which is the switch? :l
Claudio Restifo
@Marmiz
Aug 14 2017 08:57
Ment the for statement :)
for ( stuff) {
  switch () {
  }
}
Morchid Chellali
@Morched23MJ
Aug 14 2017 08:58
Ah, thanks, @Marmiz
CamperBot
@camperbot
Aug 14 2017 08:58
morched23mj sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1022 | @marmiz |http://www.freecodecamp.com/marmiz
Blauelf
@Blauelf
Aug 14 2017 08:59
@Morched23MJ str[i] is a string, not an array. You could do like str[i] = ['A', 'T']; instead of pushing.
Morchid Chellali
@Morched23MJ
Aug 14 2017 09:00
Thanks, @Blauelf
CamperBot
@camperbot
Aug 14 2017 09:00
morched23mj sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4565 | @blauelf |http://www.freecodecamp.com/blauelf
Morchid Chellali
@Morched23MJ
Aug 14 2017 09:01
What's the only way?
That's*
Blauelf
@Blauelf
Aug 14 2017 09:02

I have a few versions with a dictionary, like

  return Array.prototype.map.call(str, ch => [ch, "ACGT"["TGCA".indexOf(ch)]]);

(here, I have a mapping "TGCA"=>"ACGT", character-wise)

Morchid Chellali
@Morched23MJ
Aug 14 2017 09:03
I see, thanks
Blauelf
@Blauelf
Aug 14 2017 09:03
Forgot the str :/

You could also have like

  var pairs = {
    'A' : ['A', 'T'],
    'C' : ['C', 'G'],
    'G' : ['G', 'C'],
    'T' : ['T', 'A']
  };

and use that as a dictionary.

Markus Kiili
@Masd925
Aug 14 2017 09:05
Or use var pairs = {A:'T', T: 'A', C: 'G', G: 'C'};
Blauelf
@Blauelf
Aug 14 2017 09:06
Or that way. Many ways, I just think this challenge works really well with a dictionary of some kind.
Morchid Chellali
@Morched23MJ
Aug 14 2017 09:07
Oh, that's useful, I just wanted to know if there were multiple ways, thanks
Blauelf
@Blauelf
Aug 14 2017 09:10
Sure there are many ways. You need some kind of loop, but that could be explicit (a for loop), or implicit (like map), but otherwise you are free to use whichever decision structure you want to use. if-elseif chain, conditional operator ? : chain, switch, a dictionary...
Markus Kiili
@Masd925
Aug 14 2017 09:11
@Morched23MJ Usually gathering the information on some structure is more elegant and readable than spreading it all over the code. Also easier to change (not that the dna structure would change too easily).
Morchid Chellali
@Morched23MJ
Aug 14 2017 09:14
Alright, thanks @Masd925, @Blauelf
CamperBot
@camperbot
Aug 14 2017 09:14
morched23mj sends brownie points to @masd925 and @blauelf :sparkles: :thumbsup: :sparkles:
:warning: morched23mj already gave blauelf points
:star2: 4406 | @masd925 |http://www.freecodecamp.com/masd925
Fernando
@lestairon
Aug 14 2017 09:15
4406
Jesus.
Ogundele Olumide
@Lumexralph
Aug 14 2017 09:15
Hallo! Good Morning
Fernando
@lestairon
Aug 14 2017 09:16
Hi
Markus Kiili
@Masd925
Aug 14 2017 09:16
@lestairon You called? :imp:
@Lumexralph Where is the rock you have been hiding under?
Fernando
@lestairon
Aug 14 2017 09:17
4406 challenges?
Alexander Domikov
@AlexanderDom
Aug 14 2017 09:17
4406 thanks ^^
Hello everybody too :)
Markus Kiili
@Masd925
Aug 14 2017 09:17
@lestairon Those include thanks from people.
CamperBot
@camperbot
Aug 14 2017 09:17
masd925 sends brownie points to @lestairon :sparkles: :thumbsup: :sparkles:
:cookie: 206 | @lestairon |http://www.freecodecamp.com/lestairon
Fernando
@lestairon
Aug 14 2017 09:17
Oh, it's still a lot
Alexander Domikov
@AlexanderDom
Aug 14 2017 09:20
Blauelf has more ;)
4565 :o
Markus Kiili
@Masd925
Aug 14 2017 09:20
@AlexanderDom That just means that I give 4% more solid advice ;)
Alexander Domikov
@AlexanderDom
Aug 14 2017 09:21
that means that you and Blauelf are helping people since long time too :)
Blauelf
@Blauelf
Aug 14 2017 09:28
@AlexanderDom Have been more active here in the past. But I can still remember hitting the 1701. No bloody A, B, C, or D.
Alexander Domikov
@AlexanderDom
Aug 14 2017 09:30
I gonna finally come back here since long time ^^, to finally finish pomodoro and other frontend last challenges, was very busy :(
Markus Kiili
@Masd925
Aug 14 2017 09:30
@AlexanderDom He always stays at arms length, which cannot be a coincidence. He is like a lure on a greyhound racing.
Alexander Domikov
@AlexanderDom
Aug 14 2017 09:30
^^
Fernando
@lestairon
Aug 14 2017 09:51
image.png
Is that okay?
Markus Kiili
@Masd925
Aug 14 2017 09:52
@lestairon It works?
Fernando
@lestairon
Aug 14 2017 09:52
Yeah
Markus Kiili
@Masd925
Aug 14 2017 09:53
@lestairon Positive tests are a bit easier to read:
function checkObj(checkProp) {
  if (myObj.hasOwnProperty(checkProp)) return myObj[checkProp];
  return "Not Found";
}
or
function checkObj(checkProp) {
  return myObj.hasOwnProperty(checkProp) ? myObj[checkProp] : "Not Found";
}
Mohammed Boudad
@matrixersp
Aug 14 2017 09:55
A better solution for this?
function whatIsInAName(collection, source) {
    var arr = [];
    var j = 0;
    var bool;
    for(var i = 0; i < collection.length; i++) {
        for(var key in source) {
            bool = false;
            if(collection[i].hasOwnProperty(key) && collection[i][key] === source[key])
                bool = true;
        }
        if(bool)
            arr[j++] = collection[i];
    }
    return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Markus Kiili
@Masd925
Aug 14 2017 09:58
@Tekkie7 If that passed, it is because of bad tests. The flag needs to be initialized to true before the for...in loop and set to false on a mismatch inside the loop block.
Fernando
@lestairon
Aug 14 2017 09:58
function checkObj(checkProp) {
  if (myObj.hasOwnProperty(checkProp)) return myObj[checkProp];
  return "Not Found";
}
How does that work?
Markus Kiili
@Masd925
Aug 14 2017 09:58
@Tekkie7 It is also better to push into the result array and not use a second index that you increment.
Fernando
@lestairon
Aug 14 2017 09:59
I mean, why
There's no {} in the if statement
Mohammed Boudad
@matrixersp
Aug 14 2017 09:59
Okay, thanks @Masd925
CamperBot
@camperbot
Aug 14 2017 09:59
tekkie7 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4407 | @masd925 |http://www.freecodecamp.com/masd925
Fernando
@lestairon
Aug 14 2017 09:59
Neither there's an else
Markus Kiili
@Masd925
Aug 14 2017 09:59
@lestairon If there is only one statement on the if block, braces are optional.
So if targets only that next return on the same line.
Stephen James
@sjames1958gm
Aug 14 2017 10:00
@Tekkie7
A more modern functional approach would be to use array functions like filter and every
Fernando
@lestairon
Aug 14 2017 10:01
@Masd925 I didn't know that, thanks
CamperBot
@camperbot
Aug 14 2017 10:01
lestairon sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4408 | @masd925 |http://www.freecodecamp.com/masd925
EpicTriffid
@EpicTriffid
Aug 14 2017 10:10
Is it possible for me to go through an array of numbers, and when the array skips one number, detect what its skipping and return that missing number?
Long Nguyen
@longnt80
Aug 14 2017 10:12
@EpicTriffid why the array skip the number?
EpicTriffid
@EpicTriffid
Aug 14 2017 10:14
Thats the challenge. I need to detect if a number has been skipped
Stephen James
@sjames1958gm
Aug 14 2017 10:15
@EpicTriffid If you are in a for loop you can always return out of the loop and the enclosing function
EpicTriffid
@EpicTriffid
Aug 14 2017 10:17
@sjames1958gm I dont quite understand?
Stephen James
@sjames1958gm
Aug 14 2017 10:18
@EpicTriffid Assuming you have to have a loop to go through the array, when you detect a missing number, then you can return right then
@EpicTriffid If you keep track of what the next number should be and if the current array value is not that next number - you have found the missing number
EpicTriffid
@EpicTriffid
Aug 14 2017 10:20
Ok cool. Thankyou!
Long Nguyen
@longnt80
Aug 14 2017 10:23
@EpicTriffid which challenge is this?
EpicTriffid
@EpicTriffid
Aug 14 2017 10:27
Missing Letters
Ogundele Olumide
@Lumexralph
Aug 14 2017 10:37
@Masd925 been good, was under duress to build a web app under very tight schedule....glad to be back
@Masd925 how're you?
Markus Kiili
@Masd925
Aug 14 2017 10:38
@Lumexralph Fine. Summer vacation over and back to work.
Ogundele Olumide
@Lumexralph
Aug 14 2017 10:40
@Masd925 how's work going?
Markus Kiili
@Masd925
Aug 14 2017 10:40
@Lumexralph Same old. How about you?
Jefferson
@jeffersonnnn
Aug 14 2017 10:46
hi guys, i need help for the Mutations challenge. Can i get someone to look at my code?

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

}
mutation(["hello", "hey"]);
Fernando
@lestairon
Aug 14 2017 10:47
var myMusic = [
  {
    artist: "Pendulum",
    title: "Hold Your Color",
    release_year: 2005,
    formats: ["12'' LP", "CD", "Digital"]
  }
];
Is this code valid for JSON?
korzo
@korzo
Aug 14 2017 10:49
@jeffersonnnn You return after 1. iteration
@lestairon no
@lestairon Considering you omit variable part, property names must be wrapped in ""
Fernando
@lestairon
Aug 14 2017 10:53
@korzo But is it okay for Javascript?
korzo
@korzo
Aug 14 2017 10:54
@lestairon yes, it's correct javascript code
Markus Kiili
@Masd925
Aug 14 2017 10:58
@lestairon JSON is a string (or text) format and that is a JS array literal.
Fernando
@lestairon
Aug 14 2017 11:06
Thanks :smile:
Datikzz
@Datikzz
Aug 14 2017 11:14
guys, how to allow div to get more than 1 drag'n'drop element
Abhinav Mishra
@abhinav-m
Aug 14 2017 11:22
Hello, im trying to understand promises
i read it up on mdn and wrote my understanding of the events*
can someone verify if this is correct
let myPromise = new Promise((resolve, reject) => {


    //Using setTimeout to simulate async code.
    setTimeout(() => resolve("Promises are done for!"), 1000);
})
myPromise.then((message) => console.log(message))
    // message is whatever we passed in the resolve(...) function above.
    // It doesn't have to be a string, but if it is only a succeed message, it probably will be.
Understanding the chain of events:
  1. A new promise is created with the declaration let myPromise = , and the EXECUTOR function provided is called
    IMMEDIATELY, even before the new promise object that was created is returned.
  2. The executor function has been passed two functions resolve and reject which set the status of the promise to
    fulfilled or rejected, respectively. Asynchronous operation is simulated with setTimeout, when it completes, it calls
    resolve() with the string "Promises are done for!". This sets the state of the promise object to "RESOLVED"
  3. The Promise.prototype.then(onFulfilled, onRejected) function has added a onFullFilled handler to the promise
    which is called from resolve() in the second step (as resolve represents fulfillment of the promise) this logs the
    message in the console.
  4. NOTE : .then also returns a new promise resolving to the return value of the called handler,can be used for
    chaining purposes. */
Long Nguyen
@longnt80
Aug 14 2017 11:27

@abhinav-thinktank you don't have to put regular text into code format, making it hard to read. Just paste it normally:

Understanding the chain of events:

  1. A new promise is created with the declaration let myPromise = , and the EXECUTOR function provided is called
    IMMEDIATELY, even before the new promise object that was created is returned.
  2. The executor function has been passed two functions resolve and reject which set the status of the promise to
    fulfilled or rejected, respectively. Asynchronous operation is simulated with setTimeout, when it completes, it calls
    resolve() with the string "Promises are done for!". This sets the state of the promise object to "RESOLVED"
    3.The Promise.prototype.then(onFulfilled, onRejected) function has added a onFullFilled handler to the promise
    which is called from resolve() in the second step (as resolve represents fulfillment of the promise) this logs the
    message in the console.
  3. NOTE : .then also returns a new promise resolving to the return value of the called handler,can be used for
    chaining purposes.
Blauelf
@Blauelf
Aug 14 2017 11:29
Add a space after 3. to fix the enumeration
Chris Juchtmans
@kjuchtmans
Aug 14 2017 11:30

@Masd925 "Inventory Update"
I have been looking at your code solution, and have a question regarding var last = acc[acc.length-1];

Would the reduce method not be able to build up the acc by its own iterative nature?
I understand last pointing towards the one but last index of the acc array, as such indicates the array growing in size. But my understanding of reduce was iteration is provided from the start.

Or am I confusing iteration and accumulation?

thanks for clarifying!

CamperBot
@camperbot
Aug 14 2017 11:30
kjuchtmans sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4410 | @masd925 |http://www.freecodecamp.com/masd925
Long Nguyen
@longnt80
Aug 14 2017 11:31
@abhinav-thinktank I'm trying to understand Promise as well so I can't give you much input, but maybe you can read up on this: https://github.com/getify/You-Dont-Know-JS/blob/master/async%20%26%20performance/ch3.md
Blauelf
@Blauelf
Aug 14 2017 11:31
@kjuchtmans Is that the Inventory Update solution that concatenates arrays and sorts them before applying reduce?
Long Nguyen
@longnt80
Aug 14 2017 11:32
@Blauelf is this for @kjuchtmans ?
Abhinav Mishra
@abhinav-m
Aug 14 2017 11:32
Understanding the chain of events:
  1. A new promise is created with the declaration let myPromise = , and the EXECUTOR function provided is called
    IMMEDIATELY, even before the new promise object that was created is returned.
  2. The executor function has been passed two functions resolve and reject which set the status of the promise to
    fulfilled or rejected, respectively. Asynchronous operation is simulated with setTimeout, when it completes, it calls
    resolve() with the string "Promises are done for!". This sets the state of the promise object to "RESOLVED"
  3. The Promise.prototype.then(onFulfilled, onRejected) function has added a onFullFilled handler to the promise
    which is called from resolve() in the second step (as resolve represents fulfillment of the promise) this logs the
    message in the console.
  4. NOTE : .then also returns a new promise resolving to the return value of the called handler,can be used for
    chaining purposes.
Blauelf
@Blauelf
Aug 14 2017 11:33
@longnt80 Yes. Autocomplete favours recency over match quality.
Long Nguyen
@longnt80
Aug 14 2017 11:33
:D
Markus Kiili
@Masd925
Aug 14 2017 11:33
@kjuchtmans You are talking about this solution?
function updateInventory(arr1, arr2) {
    return arr1.concat(arr2).sort(function(a,b){
        if(a[1] < b[1]) return -1;
        if(a[1] > b[1]) return 1;
        return 0;
    }).reduce(function(acc,curr){
      var last = acc[acc.length-1];
      if(acc.length>0 && curr[1]===last[1]) {
        last[0]+=curr[0];
      }
      else acc.push(curr);
      return acc;
    },[]);
}
@kjuchtmans Because I am concating the arrays and sorting them by the item name, I have to start from an empty array.
Another way would be to not concat and use reduce on arr2 and initial accumulator arr1.
Blauelf
@Blauelf
Aug 14 2017 11:40

That's the one I had in mind. I think @kjuchtmans referred to that. Using a variable defined outside the function might be more efficient. On the other hand, it does not have to, as outer scopes might be a bit slower.

Like

function updateInventory(arr1, arr2) {
    var last = [];
    return arr1.concat(arr2).sort(function(a, b) {
        if(a[1] < b[1]) return -1;
        if(a[1] > b[1]) return 1;
        return 0;
    }).reduce(function(acc, curr) {
        if(acc.length > 0 && curr[1] === last[1]) {
            last[0] += curr[0];
        } else {
            acc.push(last = curr);
        }
        return acc;
    },[]);
}
Abhishek Kumar Pandey
@abhishekpandeykr
Aug 14 2017 11:53
how to use onChange() in angular4?
Ken Haduch
@khaduch
Aug 14 2017 12:30
@sandsbe :point_up: August 14, 2017 12:06 AM - I understand how you feel - it was a good project, and as far as the sound, I know that it wasn't in the user stories, but the example project did make a nice little sound at the end of the time periods, and the timer is described as "going off" at the end of the time period, so to me that means a sound... but good work and best of luck with the continued learning and projects!
Gokula Krishna
@AKX-X-32
Aug 14 2017 13:14
Hey guys I have completed Simon game implementation. Please review it: https://codepen.io/gkrishna/full/rzLXdM/
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 13:17
@AKX-X-32 hey man noce job on your Simon game. Keep going. I am playing it right now
Gokula Krishna
@AKX-X-32
Aug 14 2017 13:18
@RoniqueRicketts thank you
CamperBot
@camperbot
Aug 14 2017 13:18
akx-x-32 sends brownie points to @roniquericketts :sparkles: :thumbsup: :sparkles:
:cookie: 358 | @roniquericketts |http://www.freecodecamp.com/roniquericketts
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 13:22
Your welcome man keep coding. It's really nice project
Stephen James
@sjames1958gm
Aug 14 2017 13:37
@AKX-X-32 Well done!
Ryan Williams
@Ryanwfile
Aug 14 2017 13:45

I am doing the npm tutorial on code9 and in the dist tag section I can't seem to properly add the dist tag, no matter if I get an error or if the add dist-tag command succeeds I still only have 1 dist-tag when I npm dist-tag ls. Can anyone help with this.? Tried many variations of the sample code and code from the dist-tag help such as

npm dist-tag add @linclark/pkg@1.0.1 beta 
npm dist-tag add linclark@1.0.1 beta  
npm dist-tag add pkg@1.0.1 beta
npm dist-tag add @username/linclark@1.1.0 ["beta"]  
npm dist-tag add @username /linclark@1.0.1 [beta]

none seem to work, any help is greatly appreciated

Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 13:48
Hey @sjames1958gm where do u work, are you working as a developer
Stephen James
@sjames1958gm
Aug 14 2017 13:49
@RoniqueRicketts I work for a small company Netzyn. I do work as a developer mostly in C++, with some java and javscript
Klaus Mana
@KlausMana
Aug 14 2017 13:50
nice
so like I have this problem
Unrecoverable syntax error (92% Scanned)

function convertToRoman(num) {
  var answer = "";
  while(num >= 1){
    while(num >= 5){
      while(num >= 10){
        while(num >= 50){
          while(num >= 100){
            while(num >= 500){
              while(num >= 1000){

              }
            }
          }
        }
        if(num >= 40){
          answer += "XL";
          num -= 40;
        }else{
          for(var k = 10; k < num;){
            answer += "X";
            num -= 10;
          }
        }
      }
      if(num == 9){
        answer += "IX";
        num -= 9;
      }else{
        answer += "V";
        num -= 5;
        }

      }
    }
    if(num == 4){
      answer += "IV";
      num -= 4;
    }else{
      for(var i = 0; i < num;){
        answer += "I";
        num -= 1;
      }
    }
  }

  return answer;
}

convertToRoman(36);
anyone who can help?
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 13:51
Now I understand your coding experience. I envy you in a good way. How long now have you been coding in all these languages ?
Klaus Mana
@KlausMana
Aug 14 2017 13:51
it's the roman numeral challenge
Markus Kiili
@Masd925
Aug 14 2017 13:53
@KlausMana It would be much better if you gather the (basis of) Roman numerals and corresponding numbers on some arrays and then solve it by iterating the array of numbers, instead of spreading them around the code.
Klaus Mana
@KlausMana
Aug 14 2017 13:54
damn
I've reset this like 4 times already xD
time to do that again! yay!
@Masd925 so I guess an array with the corresponding romans for 1,4,5,9,10,40,50,90,100,400,500,900,1000?
Markus Kiili
@Masd925
Aug 14 2017 13:57
@KlausMana Yes, but perhaps in reverse order so you iterate the largest first.
Klaus Mana
@KlausMana
Aug 14 2017 13:57
yeah
ty for the tip @Masd925
oh it doesn't recognize ty
thanks @Masd925
CamperBot
@camperbot
Aug 14 2017 13:57
klausmana sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4411 | @masd925 |http://www.freecodecamp.com/masd925
Stephen James
@sjames1958gm
Aug 14 2017 13:58
@RoniqueRicketts C++ since about 2004, java since mid 2000s and javascript the last couple of years
Klaus Mana
@KlausMana
Aug 14 2017 13:58
gotta get those brownies through xD
kumquatfelafel
@kumquatfelafel
Aug 14 2017 13:58
Start it off simple. "How would I get the right number of M's?" for example. You might notice there is a significant amount of repetitive code that can be handled by looping. The logic is largely the same, provided you handle the "weird cases",like IV, IX, etc properly
Klaus Mana
@KlausMana
Aug 14 2017 13:58
yeah
@sjames1958gm
nice
Stephen James
@sjames1958gm
Aug 14 2017 13:59
@KlausMana thx
CamperBot
@camperbot
Aug 14 2017 13:59
sjames1958gm sends brownie points to @klausmana :sparkles: :thumbsup: :sparkles:
:cookie: 300 | @klausmana |http://www.freecodecamp.com/klausmana
Klaus Mana
@KlausMana
Aug 14 2017 13:59
I have a question sice you seem a little more experienced @sjames1958gm
Stephen James
@sjames1958gm
Aug 14 2017 13:59
@KlausMana Code word for old :)
@KlausMana Fire away
Klaus Mana
@KlausMana
Aug 14 2017 14:00
When would you think that you have actually learned a language?
Like I know the basics of JS, Python and Java but I am not really sure that I actually have fully learned them
Is it just the syntax or is there more to it?
Markus Kiili
@Masd925
Aug 14 2017 14:02
@KlausMana Usually the basic syntax is easily learned. Frameworks and libraries take more time to learn.
Klaus Mana
@KlausMana
Aug 14 2017 14:02
So basically
you can never actually fully learn a language?
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:02
A "fully learnable" language is likely a dead language.
Klaus Mana
@KlausMana
Aug 14 2017 14:02
Because there will always be more
So just learn more frameworks and do more projects on it then?
Like is that all? :P
Clearly easier said than done but still
Markus Kiili
@Masd925
Aug 14 2017 14:04
@KlausMana I think that web development evolves faster that anyone can learn, so there is no fear for you catching up too soon.
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:04
Basically, if a language isn't capable of doing new things, it's not going to last long. But if it's capable of evolving, then there's always something you could learn
Klaus Mana
@KlausMana
Aug 14 2017 14:04
yeah
nice profile pic btw @kumquatfelafel xD
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:05
Danke :P
Markus Kiili
@Masd925
Aug 14 2017 14:05
@KlausMana Complement my nose too :sparkles:
EpicTriffid
@EpicTriffid
Aug 14 2017 14:05
Hi all, So im working on this Missing Letters challenge and currently trying to work out how to detect the missing element and return it. I know I'm not there yet, but I this code return "3". Where the hell is "3" coming from?!

function fearNotLetter(str) {
  var uni = [];
  var missing;
  for (var i = 0; i < str.length; i++) {
    uni.push(str.charCodeAt(i));
    if (uni[i-1] != uni[i]) {
      missing = i;      
    }

  } 
  return missing;
}

fearNotLetter("abce");
Klaus Mana
@KlausMana
Aug 14 2017 14:05
Yeah very defined @Masd925
Classy
@EpicTriffid missing = i?
i is an int, therefore missing will be an int if you assign i to it
EpicTriffid
@EpicTriffid
Aug 14 2017 14:07
@KlausMana So how do I store the missing number?
And where is "3" coming from?!
:P
Klaus Mana
@KlausMana
Aug 14 2017 14:07
3 is likely the value of i in the moment that you assigned it
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:07
@EpicTriffid 3 seems the appropriate return.
a is 0, b is 1, c is 2, d is between c and e. Don't remember what you have to do for this though.
EpicTriffid
@EpicTriffid
Aug 14 2017 14:07
@kumquatfelafel Oh that makes sense!
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:08
I also didn't read your code carefully. Sec
Kelechi Chinaka
@ke1echi
Aug 14 2017 14:08
:wave: guys
EpicTriffid
@EpicTriffid
Aug 14 2017 14:08
you have to detect if an array is missing the next letter in the sequence. In this instance it would be d, or Unicode 100
Kelechi Chinaka
@ke1echi
Aug 14 2017 14:09
do u know react @kumquatfelafel @Masd925
EpicTriffid
@EpicTriffid
Aug 14 2017 14:09
@kelechy Holla
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:09
okay. nothing to do with what i said. It's because 3 is last value assigned to missing. @EpicTriffid
Markus Kiili
@Masd925
Aug 14 2017 14:09
@kelechy No.
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:10

uni[i-1] != uni[i]

In no instance for the given string of abce is this true.

Kelechi Chinaka
@ke1echi
Aug 14 2017 14:10
do u feel any need to learn it @Masd925
EpicTriffid
@EpicTriffid
Aug 14 2017 14:11
@kumquatfelafel I was going off a similar query someone else had but have found it doesnt work.
Markus Kiili
@Masd925
Aug 14 2017 14:11
@kelechy Yes, I will look into node and react when I have time.
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:12
@kelechy not at moment. I might be able to look at react code and have pretty good idea of what is going on (especially with google), but I couldn't program in it.
EpicTriffid
@EpicTriffid
Aug 14 2017 14:13
So, I have to detect if the next number in a sequence is missing. Im thinking that if i take my one of my elements, and add one, it should equal the next value in the sequence. If it doesn't, return the number that should be there
Is that sound logic?
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:13
@EpicTriffid www.asciitable.com
Nazar
@IsaakNazar
Aug 14 2017 14:14
Good Monday!!!
EpicTriffid
@EpicTriffid
Aug 14 2017 14:14
@kumquatfelafel Yup, I've got it to show me the unicode numbers in an array, which is what I'm now working off
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:16
@EpicTriffid sounds sound, provided you add one not to the character but the char code, and compare not to the character but the...
EpicTriffid
@EpicTriffid
Aug 14 2017 14:18
@kumquatfelafel next charcode in the sequence?
Kelechi Chinaka
@ke1echi
Aug 14 2017 14:20
i think i will just learn it slowly @kumquatfelafel @Masd925
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:20
@EpicTriffid aye :)
EpicTriffid
@EpicTriffid
Aug 14 2017 14:20
I know I'm trying to compare it to the next number in the sequence, but with the loop, I can't access the next number can i?
Im picking up i, adding 1, and then telling it to check if it matches itself, plus 1?
My brain hurts
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:21
@EpicTriffid I feel like you said you had the char code sequence in an array???
EpicTriffid
@EpicTriffid
Aug 14 2017 14:22
I do
function fearNotLetter(str) {
  var uni = [];
  var missing;
  for (var i = 0; i < str.length; i++) {
    uni.push(str.charCodeAt(i));
    if (uni[i+1] != uni[i+1]) {
      return uni[i];
    }

  }
}

fearNotLetter("abce");
Wow, that looks weird
but yeah
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:23
@EpicTriffid if you add js after opening back ticks it will fix that
EpicTriffid
@EpicTriffid
Aug 14 2017 14:23
uni has all the charcodes
@kumquatfelafel thankyou :)
CamperBot
@camperbot
Aug 14 2017 14:23
epictriffid sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 605 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Nazar
@IsaakNazar
Aug 14 2017 14:23
bot
cbot
CamperBot
@camperbot
Aug 14 2017 14:23
you called?
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:25
@EpicTriffid ah. Well... let's try approaching this from a different angle.
EpicTriffid
@EpicTriffid
Aug 14 2017 14:26
@kumquatfelafel Okily doke
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:28
So our goal here is to find missing letter right. First... Do we need an array of previous characters, or do we just need the previous character for a comparison?
EpicTriffid
@EpicTriffid
Aug 14 2017 14:28
We only need the previous character
the rest of the array is kinda superfluous right?
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:29
A bit.
EpicTriffid
@EpicTriffid
Aug 14 2017 14:29
Im really sorry, but I've got to rush off. Can I call of you when I come back if you're around?
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 14:36
@sjames1958gm damn your coding skills has mileage.
Stephen James
@sjames1958gm
Aug 14 2017 14:38
@RoniqueRicketts This is the kind of device I wrote my first programs on - I seem to recall it was Basic
http://upload.wikimedia.org/wikipedia/commons/thumb/3/33/Teletype-IMG_7287.jpg/200px-Teletype-IMG_7287.jpg
Blauelf
@Blauelf
Aug 14 2017 14:39
Looks a bit like our Telex terminal. Used for decoration nowadays.
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 14:39
@sjames1958gm wait is that a type writer with legs?
Stephen James
@sjames1958gm
Aug 14 2017 14:40
Its a teletype machine. (Ours had an aucoustic modem in the blank spot on the right, which we connected to the mainframe over the phone)
we stored our code on paper tape, which you can see on the left
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 14:43
@sjames1958gm I didn't even know this sort of thing exist. This looks very old.
Blauelf
@Blauelf
Aug 14 2017 14:43

Looks like the Telex device is a specific type of "teletype".

"Teletype" seems to be the kind of device that my first programming books (BASIC) were targeting.

Stephen James
@sjames1958gm
Aug 14 2017 14:43
The year was 1976 :)
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 14:44
@sjames1958gm I wasn't even a sperm then. Damn your tech skills has a lot of mileage.
so there was no console? Btw how old is the console btw?
Stephen James
@sjames1958gm
Aug 14 2017 14:47
I started using CRT terminals in college in 1977, I was working for a professor and got special access.
Mostly we used card punch machines. terminals started becoming more common in the early 1980s
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:47
@RoniqueRicketts I was a sperm at the time... and for another 13 years or so after that. My adventures during that time actually became the basis for a series of children's books that... for whatever reason... were extremely popular and successful in Missouri.
Blauelf
@Blauelf
Aug 14 2017 14:48
@sjames1958gm So that's a paper display in bright white? As shiny as the Kindle Paperwhite or even brighter?
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 14:49
@kumquatfelafel what?? lol smh, how did you know you were a sperm already smh. Well you guys have some coding mileage man. No wonder your so good at this especially @sjames1958gm
Stephen James
@sjames1958gm
Aug 14 2017 14:49
@Blauelf Yes that is a roll of paper that you see there, very white, and it was quite noisy.
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:50

@kumquatfelafel what?? lol smh, how did you know you were a sperm already smh.

Don't destroy my dreams! :o

:p

Ken Haduch
@khaduch
Aug 14 2017 14:52
@sjames1958gm - that was the type of terminal that I wrote my first programs on, using a DEC PDP-8 and using the FOCAL language... I probably still have some of the paper tapes around here somewhere... :point_up: August 14, 2017 10:38 AM. In fact, that was what I used for quite a few years until some video terminals started becoming more widespread...
Blauelf
@Blauelf
Aug 14 2017 14:52
@sjames1958gm Noisy as any typewriter, or worse? And was that thing able to write punch tape?
Klaus Mana
@KlausMana
Aug 14 2017 14:52
guyz I need moar help
I reset my code and wrote sth short but I'm completely sure it should work
Stephen James
@sjames1958gm
Aug 14 2017 14:52
Yes it could read/write paper tape (punch tape)
Klaus Mana
@KlausMana
Aug 14 2017 14:53
oh nvm
I just misspelled a variable name xp
Ken Haduch
@khaduch
Aug 14 2017 14:53
@Blauelf - they did have paper-tape punches. There was a oiled paper that those machines used.
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:54
@KlausMana You should never misspell the variable xp. How else will the roman numerals level up? :p
Klaus Mana
@KlausMana
Aug 14 2017 14:54
xD
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 14:54
@sjames1958gm so did this machine give u headache to code on?
Klaus Mana
@KlausMana
Aug 14 2017 14:54
ok what is this paper machine though I am kinda curious now :P
Stephen James
@sjames1958gm
Aug 14 2017 14:54
@RoniqueRicketts well I was just a kid and didn't know any better - we thought we were the whiz kids
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:55
It's the past of programming
Stephen James
@sjames1958gm
Aug 14 2017 14:57
@KlausMana It the machine I programmed on in high school
Klaus Mana
@KlausMana
Aug 14 2017 14:57
I am really curious if when I'm around 60 years old people that are 16 (my age now) will be like "computer screens? JavaScript? That is so ancient!"
Stephen James
@sjames1958gm
Aug 14 2017 14:58
Yes likely
kumquatfelafel
@kumquatfelafel
Aug 14 2017 14:58
In all likelihood, many 10 year olds are already far more computer literate than the rest of us. Though they may not know how to write a for loop yet. :p
Klaus Mana
@KlausMana
Aug 14 2017 14:59
so the code was actually written in paper? :o
But how did the machine read it
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 14:59
@sjames1958gm lol I bet a few years from now the new generation of developers will laugh at us for the computers we will be using. Especially when they come out with their tongue phone.
Klaus Mana
@KlausMana
Aug 14 2017 14:59
or where did you get the output
Stephen James
@sjames1958gm
Aug 14 2017 15:00
@KlausMana You typed the code into the teletype and it sent the code over a modem to the main frame.
To store the program you saved it on punch tape, which had one line per character.
It was only output to the roll of paper. 2D at its finest
Klaus Mana
@KlausMana
Aug 14 2017 15:00
wow
Blauelf
@Blauelf
Aug 14 2017 15:01
@KlausMana Even much of the stuff I learnt in the 90s is pretty much deprecated. Remember Java Applets?
Klaus Mana
@KlausMana
Aug 14 2017 15:02
I do :P
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:02
@RoniqueRicketts ahahaha... okay... the visual image of that. :laughing:
Blauelf
@Blauelf
Aug 14 2017 15:02
HTML is also very different, with CSS there's so much more complexity compared to the 90s with their frameset-heavy designs.
Framesets, imagemaps, blink and marquee tags (green on purple to honor the tentacle!)
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 15:04
@kumquatfelafel lol. Kids will be like. hello "hello mom I am on my tongue phone atm so text me on my eye messenger" imagine that. sending text msgs by just thinking about it.
Klaus Mana
@KlausMana
Aug 14 2017 15:05
There probably won't be that much gadgets as there are now in my opinion
Blauelf
@Blauelf
Aug 14 2017 15:05
@RoniqueRicketts Sounds like something worth hacking.
Klaus Mana
@KlausMana
Aug 14 2017 15:05
I mean nano technology and cyborgs ftw :P
Blauelf
@Blauelf
Aug 14 2017 15:06
Does wearing glasses or riding a bike make you a cyborg? I think it might. Using a smartphone probably does.
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 15:06
@Blauelf lol, thats ruff.
Klaus Mana
@KlausMana
Aug 14 2017 15:06
Also, what opinions do you guys have on AI and how fast it is advancing? Pro or Counter?
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:07
Would an organization for cyborgs be a cyborgorg?
Klaus Mana
@KlausMana
Aug 14 2017 15:07
lol
Jim Tryon
@jimtryon
Aug 14 2017 15:07
AI is moving rapidly and I think it’s going to transform a lot of the things we know in 5 years
Klaus Mana
@KlausMana
Aug 14 2017 15:07
cyborg.org
Blauelf
@Blauelf
Aug 14 2017 15:08
Not sure whether mankind will survive long enough to create complex AI, or whether they will go extinct within the next few decades.
Markus Kiili
@Masd925
Aug 14 2017 15:08
@KlausMana It was a grave mistake to make electronic computers. Ones with levers and gears were enough. Could kill it with an axe if need be.
Jim Tryon
@jimtryon
Aug 14 2017 15:09
@Blauelf I give it to 2020 and we’ll have it figured out
Klaus Mana
@KlausMana
Aug 14 2017 15:09
@Blauelf but why would we go extinct in the next few decades?
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 15:09
@Blauelf they wont make it. No AI will take over the world Human Brain is too complex. If an AI gets out of hand a simple worm can destroy that bugga. AI would survive on Electricity we can always turn off the light and replace those servers
Klaus Mana
@KlausMana
Aug 14 2017 15:10
I agree with that personally
I don't think that making a sentient AI is a matter of need more than a matter of "we can do this so we will"
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:11

"AI would survive on Electricity we xccan always turn off the light and replace those servers"

This assumes we don't, in the height of hubris, assign these tasks to AI's in the future. :p

Blauelf
@Blauelf
Aug 14 2017 15:11
@jimtryon 2020, updates for Windows 7 willl stop. That will be a security issue that might lead to some kind of apocalypse. Though I rarely see XP nowadays (mostly in embedded systems that... so I hope... should not be connected to any network)
Klaus Mana
@KlausMana
Aug 14 2017 15:12
xD that is quite a reason for the world to end
kumquatfelafel @kumquatfelafel shrugs
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:12
Buy shutters?
Blauelf
@Blauelf
Aug 14 2017 15:12
@RoniqueRicketts I doubt the AI will make us go extinct, or at least not as a goal. Maybe as part of a mis-defined optimisation goal. But we humans will do the work all by ourselves.
Klaus Mana
@KlausMana
Aug 14 2017 15:13
I think we should just chill and see what happens :P
Blauelf
@Blauelf
Aug 14 2017 15:15
@kumquatfelafel I find those "smart meters" pretty interesting. Provide much attack surface. And much of our infrastructure relies on GSM (e.g., carsharing cars often cannot be started without mobile network signal)
Klaus Mana
@KlausMana
Aug 14 2017 15:15
@Blauelf `Maybe as part of a mis-defined optimisation goal
if(goingtoExterminateHumans()){
dont();
}
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 15:15
@KlausMana I think an AI should just come online to make life an medicine better.
Blauelf
@Blauelf
Aug 14 2017 15:15

@KlausMana More like

goal = minimize(suffering);

Giving us drugs that remove hunger, so we starve happily.

Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 15:17
@Blauelf People has this misconception that the world will be controlled by AI's an AI can learn to a point but can it survive without electricity? NO! But I think AIs are cool. I think they should make life better
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:18

For me the question is... what if the demise of humanity really is in the best interest of the universe, and AI's, having made this determination, take the logical step of extermination.

I mean... they are logically supported in their assertions... and by assertion, I mean killing all humans. :o

Blauelf
@Blauelf
Aug 14 2017 15:21
@RoniqueRicketts I don't say the AI will survive after we are no more. It will likely degrade in some way, probably while we do as well. For whichever reason. I don't think an AI is likely to intend killing people, and we probably don't need it for this reason. We are quite efficient in that already.
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:23
AssertExtinct("Humans", "Oops")
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 15:23
@Blauelf true. I like the AI idea. We can build some nice robots to work as security for night shift as securities. So humans can sleep in the day and get good rest.
Jim Tryon
@jimtryon
Aug 14 2017 15:23
If you listen to The Frontier podcast, you can get a sense of how fast things are going :)
Emmanuel Akodia
@akodiaemma
Aug 14 2017 15:42
hello world i need help concerning web design
Blauelf
@Blauelf
Aug 14 2017 15:45
@akodia488 Ask a question, and somebody might be able to answer it.
Emmanuel Akodia
@akodiaemma
Aug 14 2017 15:45
@Blauelf i want to make a local area network archive website
where the procurement office can store all there work
and easily search for them..but i do not know where to start
May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:46
what is .forEach()
is that a function or smth
Jason Luboff
@JLuboff
Aug 14 2017 15:47
@diomed It's an array method
Blauelf
@Blauelf
Aug 14 2017 15:47
@diomed You mean Array.prototype.forEach? It's like Array.prototype.map, just without any return value.
May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:48
how to push 1 var to another via for Each
Emmanuel Akodia
@akodiaemma
Aug 14 2017 15:48
i wwant to buildan archive website that can easily search for documents of all types in a database. but i do not know where to start from
it will be LAN
May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:48
Push the entire robots array to belt2
Abhinav Mishra
@abhinav-m
Aug 14 2017 15:48
var p = []; a.forEach ( v=> p.push(v) )
May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:51
@abhinav-thinktank is that es6
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:51
yeah
Abhinav Mishra
@abhinav-m
Aug 14 2017 15:51
@diomed yes
a.forEach( function(value) { p.push(value) } );
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:51
without... function(v) { p.push(v);} go inside paren instead.
May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:52
I see.
Blauelf
@Blauelf
Aug 14 2017 15:52
@diomed v => p.push(v) is nearly same as function(v) { return p.push(v); }, here a simple function(v) { p.push(value); } would do the same (as forEach ignores return values)
May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:52
what is p before push?
Moisés Man
@moigithub
Aug 14 2017 15:52
fat arrow function
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:52
@diomed that's an arbitrarily named empty array
Blauelf
@Blauelf
Aug 14 2017 15:53
@diomed You might have to use belt2 instead of p
Abhinav Mishra
@abhinav-m
Aug 14 2017 15:53
^
May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:53
is that related to var p
is is the same
Blauelf
@Blauelf
Aug 14 2017 15:53
Yes, it is.
May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:53
thing
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:53
Though doesn't have to necessarily be an empty array, or named p. E.g. could be called belt
May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:53
allright. thanks guys @kumquatfelafel @Blauelf @abhinav-thinktank
CamperBot
@camperbot
Aug 14 2017 15:53
:cookie: 501 | @abhinav-thinktank |http://www.freecodecamp.com/abhinav-thinktank
:cookie: 606 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
diomed sends brownie points to @kumquatfelafel and @blauelf and @abhinav-thinktank :sparkles: :thumbsup: :sparkles:
:star2: 4566 | @blauelf |http://www.freecodecamp.com/blauelf
Abhinav Mishra
@abhinav-m
Aug 14 2017 15:54

@abhinav-thinktank
Hello, im trying to understand promises
i read it up on mdn and wrote my understanding of the events*
can someone verify if this is correct

let myPromise = new Promise((resolve, reject) => {


    //Using setTimeout to simulate async code.
    setTimeout(() => resolve("Promises are done for!"), 1000);
})
myPromise.then((message) => console.log(message))
    // message is whatever we passed in the resolve(...) function above.
    // It doesn't have to be a string, but if it is only a succeed message, it probably will be.

Understanding the chain of events:

  1. A new promise is created with the declaration let myPromise = , and the EXECUTOR function provided is called
    IMMEDIATELY, even before the new promise object that was created is returned.
  2. The executor function has been passed two functions resolve and reject which set the status of the promise to
    fulfilled or rejected, respectively. Asynchronous operation is simulated with setTimeout, when it completes, it calls
    resolve() with the string "Promises are done for!". This sets the state of the promise object to "RESOLVED"
  3. The Promise.prototype.then(onFulfilled, onRejected) function has added a onFullFilled handler to the promise
    which is called from resolve() in the second step (as resolve represents fulfillment of the promise) this logs the
    message in the console.
  4. NOTE : .then also returns a new promise resolving to the return value of the called handler,can be used for
    chaining purposes. */
i dont know why i tagged myself..
but can someone verify if my understanding is correct
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:55

i dont know why i tagged myself..

Well... pretty important to see what you're posting as well. If you didn't see it, how would you know it was what you wanted to post! :o

;)

May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:55
var meadow=[]; a.forEach(bee=>meadow.push(bee))
Abhinav Mishra
@abhinav-m
Aug 14 2017 15:55
trying to understand about promises
May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:55
okay?
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:55
@diomed looks good
Blauelf
@Blauelf
Aug 14 2017 15:56
If you store your bees in a, then yes.
May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:56
what is a here?
Abhinav Mishra
@abhinav-m
Aug 14 2017 15:56
@diomed the array you call forEach on
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:56
presumably an array that has a bunch of bees. :point_up:
May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:56
can that array have different name - like hive ?
Moisés Man
@moigithub
Aug 14 2017 15:56
listOfNums = [1,2,3,4,5]
listOfNums.forEach( num => console.log(num) )
1
2
3
4
5
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:56
Though I'd prefer we call it hive :p
May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:56
:+1:
excellent!
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:57
@diomed Yes, but only if you store said array in hive.
May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:58
where else would I store it?
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:58
You couldn't for example say
var a = [insert bees here];
hive.forEach(blahblahblah);
May Kittens Devour Your Soul
@diomed
Aug 14 2017 15:58
I couldnt ?
Stephen James
@sjames1958gm
Aug 14 2017 15:58
@abhinav-thinktank Sounds correct to me.
kumquatfelafel
@kumquatfelafel
Aug 14 2017 15:59
@diomed nah. You'd either have to say var hive, or a.forEach
May Kittens Devour Your Soul
@diomed
Aug 14 2017 16:00
is this good now? var meadow=[]; hive.forEach(bee=>meadow.push(bee))
kumquatfelafel
@kumquatfelafel
Aug 14 2017 16:02
@diomed Without seeing where hive has been defined, I can't say "this is absolutely free from problems". But yes, the syntax is such that, for each "bee" in hive, you push said "bee" to the "meadow".
May Kittens Devour Your Soul
@diomed
Aug 14 2017 16:02
okay. thank you
kumquatfelafel
@kumquatfelafel
Aug 14 2017 16:08
np
Kelechi Chinaka
@ke1echi
Aug 14 2017 16:10
whats the lastest on your kata creation @kumquatfelafel
Mauricio Londoño
@mauricio1585
Aug 14 2017 16:12
Hello world

function Person(){
this.personName: "Alberto";
this.lastaname: "Alvarez";
this.age = 29;
this.consoleLogPerson: function(){
return this.personName + " " + this.lastaname + " " + "("+ this.age + ")";
}
}

var newPerson = new Person();

console.log(consoleLogPerson());

why I get the error Uncaught SyntaxError: Unexpected token :?
Moisés Man
@moigithub
Aug 14 2017 16:13
use = assigment operator
this.age = 29; <-- like that... not :
kumquatfelafel
@kumquatfelafel
Aug 14 2017 16:13
@mauricio1585
this.consoleLogPerson: function(){ The : used here is more reminiscent of object notation.
var obj = { a: 1, b: 2}
//vs.
function blah {
  var a = 1;
  var b = 2;
  doSomeOtherStuff();
  return importantThings;
}
Mauricio Londoño
@mauricio1585
Aug 14 2017 16:15

function Person(){
this.personName = "Alberto";
this.lastaname = "Alvarez";
this.age = 29;
this.consoleLogPerson = function(){
return this.personName + " " + this.lastaname + " " + "("+ this.age + ")";
}
}

var newPerson = new Person();

console.log(consoleLogPerson());

app.js:12 Uncaught ReferenceError: consoleLogPerson is not defined
at app.js:12
kumquatfelafel
@kumquatfelafel
Aug 14 2017 16:17
means what it says. You've never defined what "consoleLogPerson" is by assigning it any kind of value. I imagine you meant to do this for newPerson instead.
oh, wait... I see
newPerson.consoleLogPerson()
Though I would maybe consider renaming this function something else, like getInfo maybe.
Mauricio Londoño
@mauricio1585
Aug 14 2017 16:21
@kumquatfelafel "this.consoleLogPerson" is supposed to be a method. I used = notation instead of : notation but the error is the same : Uncaught SyntaxError: Unexpected token :
It says the error is in this.personName = "Alberto";
Stephen James
@sjames1958gm
Aug 14 2017 16:23
@mauricio1585 console.log(newPerson.consoleLogPerson());
The other code looks ok - you just have to give consoleLogPerson() a person object
kumquatfelafel
@kumquatfelafel
Aug 14 2017 16:24
@mauricio1585
@mauricio1585 if ": error" still coming up in spite of you changing code to this.personName = "Alberto";, try refreshing
From there, @sjames1958gm code snippet ought to work fine
Mauricio Londoño
@mauricio1585
Aug 14 2017 16:30
@kumquatfelafel
var Person = function (){
this.personName = "Alberto";
this.lastaname = "Alvarez";
this.age = 29;
this.consoleLogPerson = function(){
return this.personName + " " + this.lastaname + " " + "("+ this.age + ")";
}
}
var newPerson = new Person();
console.log(newPerson.consoleLogPerson());
kumquatfelafel
@kumquatfelafel
Aug 14 2017 16:31
@mauricio1585 that should work fine.
Mauricio Londoño
@mauricio1585
Aug 14 2017 16:31
It says the this.consoleLogPerson is not define with = notation.
if I change it to : notation it gives error.
I see it should work ok
kumquatfelafel
@kumquatfelafel
Aug 14 2017 16:33
the issue is not with the code you posted.
Try refreshing browser.
Mauricio Londoño
@mauricio1585
Aug 14 2017 16:37
Yes, it worked. Thank you @kumquatfelafel What is strange is that I saw somebody that used : notation and it worked totally fine. I had to change to = opertator and it worked but not with :
CamperBot
@camperbot
Aug 14 2017 16:37
:cookie: 607 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
mauricio1585 sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
Mauricio Londoño
@mauricio1585
Aug 14 2017 16:38
Maybe is browser issue.
Emmanuel Akodia
@akodiaemma
Aug 14 2017 16:38
@akodia488
how do i make images appear as i type out different search queries in my search dialog
what do i need to achieve this effect
Christopher McCormack
@cmccormack
Aug 14 2017 16:51
@akodia488 you can use something like input.onkeypress or input.onkeyup which will trigger when keys are pressed or released.
If you can pull values for every key pressed, you can use the input value for your search query and display something related to that query
you may want to add some sort of debouncing so it doesn't trigger EVERY keypress and instead after not hitting a key for a short amount of time
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 16:54
anyone here familiar with cloud9? I am using it for the first time for my internship test and I am not able to add a background image to a tag. Not even the body tag using css
Jason Luboff
@JLuboff
Aug 14 2017 16:54
@RoniqueRicketts I've used it
Christopher McCormack
@cmccormack
Aug 14 2017 16:54
@RoniqueRicketts make sure the image host allows direct linking
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 16:54
@cmccormack how do i verify that?

@cmccormack @JLuboff this works

#main_article{
    display: flex;
    justify-content: space-between;
    background-image: url('https://media.licdn.com/media/AAEAAQAAAAAAAANbAAAAJDE5NjBkNDk1LTY3ZGQtNDA0NS04YTJiLTdkNmU3NjZiNjI3Mg.png');
}

but not

#main_article{
    display: flex;
    justify-content: space-between;
    background-image: url('/assets/background.png');
}
Jason Luboff
@JLuboff
Aug 14 2017 16:59
What is your folder structure?
you may need ./assests/...
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 17:00
Capture.PNG
Christopher McCormack
@cmccormack
Aug 14 2017 17:00
no just do 'assets/...
Jason Luboff
@JLuboff
Aug 14 2017 17:00
No, he needs to go up a folder?
Christopher McCormack
@cmccormack
Aug 14 2017 17:01
I don't see that, looks like assets is on the same level
oh from the css
I see
Jason Luboff
@JLuboff
Aug 14 2017 17:01
assests and css are two different folders
Christopher McCormack
@cmccormack
Aug 14 2017 17:01
 background-image: url('../assets/background.png');
sorry was thinking it was from the html for some reason :D
Jason Luboff
@JLuboff
Aug 14 2017 17:01
;)
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 17:03
@cmccormack thanks that work
Christopher McCormack
@cmccormack
Aug 14 2017 17:03
np
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 17:04
@cmccormack @JLuboff thanks
CamperBot
@camperbot
Aug 14 2017 17:04
roniquericketts sends brownie points to @cmccormack and @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2147 | @jluboff |http://www.freecodecamp.com/jluboff
:star2: 1136 | @cmccormack |http://www.freecodecamp.com/cmccormack
Keon Samuel
@keonsam
Aug 14 2017 17:07
pure JS vs react?
Christopher McCormack
@cmccormack
Aug 14 2017 17:10
For what @keonsam ? Simple tasks pure js is fine but larger projects React or another framework/oop can be easier to manage
Abhinav Mishra
@abhinav-m
Aug 14 2017 17:17
Can someone point me towards resources for redux
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 17:18
Abhinav Mishra
@abhinav-m
Aug 14 2017 17:18
dont really like tutorialspoint..
their react section was awful
Christopher McCormack
@cmccormack
Aug 14 2017 17:19
@abhinav-thinktank I think https://egghead.io/courses/getting-started-with-redux is recommended pretty often. I haven't watched through myself just yet
Abhinav Mishra
@abhinav-m
Aug 14 2017 17:19
@cmccormack ty!
CamperBot
@camperbot
Aug 14 2017 17:19
abhinav-thinktank sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1137 | @cmccormack |http://www.freecodecamp.com/cmccormack
mstellaluna
@mstellaluna
Aug 14 2017 17:19
@abhinav-thinktank look on hackr.io its a forum where people post listings to free and paid tutorials
Abhinav Mishra
@abhinav-m
Aug 14 2017 17:19
@camperbot wow it's by dan abramov huh
@mstellaluna ok ty ! will do
CamperBot
@camperbot
Aug 14 2017 17:19
abhinav-thinktank sends brownie points to @mstellaluna :sparkles: :thumbsup: :sparkles:
:cookie: 631 | @mstellaluna |http://www.freecodecamp.com/mstellaluna
Christopher McCormack
@cmccormack
Aug 14 2017 17:20
I'm not camperbot!
but I wish I were
kumquatfelafel
@kumquatfelafel
Aug 14 2017 17:20
find info on camperbot
CamperBot
@camperbot
Aug 14 2017 17:20
find info on camperbot
nothing found
Christopher McCormack
@cmccormack
Aug 14 2017 17:21
about @camperbot
CamperBot
@camperbot
Aug 14 2017 17:21
:star2: 3381 | @camperbot |http://www.freecodecamp.com/camperbot
kumquatfelafel
@kumquatfelafel
Aug 14 2017 17:21

@cmccormack :o

It's like you have magic words!

Christopher McCormack
@cmccormack
Aug 14 2017 17:22
I cheated and went to camperbotPlayground to see how it's did
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 17:23
about @camperbot
CamperBot
@camperbot
Aug 14 2017 17:23
:star2: 3381 | @camperbot |http://www.freecodecamp.com/camperbot
kumquatfelafel
@kumquatfelafel
Aug 14 2017 17:28
thanks @camperBo
CamperBot
@camperbot
Aug 14 2017 17:28
kumquatfelafel sends brownie points to @camperbo :sparkles: :thumbsup: :sparkles:
:warning: @camperbo's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
kumquatfelafel
@kumquatfelafel
Aug 14 2017 17:29
@camperbot Ha! Take that! No brownies for you today. :o
Christopher McCormack
@cmccormack
Aug 14 2017 17:33
poor camperBo
cmccormack @cmccormack is out for now!
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 17:46
anyone has any css links that i can learn how to use flex box to arrange 2 columns left column should be like 20 % of the screen and the right column should be like 80% any reference on how to do this with flexbox
Thayyeb salim
@Thayyebsalim
Aug 14 2017 17:50
Dev tips has a proper video of flex box @RoniqueRicketts
Probably something like align-self:flex-start or something
Jefferson
@jeffersonnnn
Aug 14 2017 17:51
Hi guys, i have a question from the Falsy Bounce challenge: i can't seem to pass the challenge.

function bouncer(arr) {
  return arr.filter([null, false, NaN, undefined, "", 0]);
}

bouncer([7, "ate", "", false, 9]);
Kelechi Chinaka
@ke1echi
Aug 14 2017 17:53
show code
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 17:54
@Thayyebsalim any reading article
Thayyeb salim
@Thayyebsalim
Aug 14 2017 17:55
sorry no @RoniqueRicketts
Too lazy ;p
Kelechi Chinaka
@ke1echi
Aug 14 2017 17:56
your filter() is not wrong @jeffersonnnn
wrong usage
Ronique Ricketts
@RoniqueRicketts
Aug 14 2017 17:56
@Thayyebsalim lol me tpoo
Kelechi Chinaka
@ke1echi
Aug 14 2017 17:57
u can do this to remove all boolean argument
return arr.filter(Boolean)
@jeffersonnnn
luccifer00
@luccifer00
Aug 14 2017 17:59
:point_up: 14 de agosto de 2017 2:22 i really take my time to re-read @sjames1958gm answer... i use div.innerHTML = HTML; out of the loop, i test diferent ways to do it... but i have no results with them.... the last try i am is this https://codepen.io/luccifer00/pen/YxxjxE?editors=0010 before i get the las array result, now, i get the first array result... but i dont know how to créate divs with the content(changing the root of the array)
Stephen James
@sjames1958gm
Aug 14 2017 18:07
@luccifer00 I think this is what you want. Get the article element before the loop.
Then for each loop you create a new div and append it to the article
      var article = document.getElementById("article");
      for (var i =0; i<data[1].length;i++){
          var div = document.createElement('div');
          div.setAttribute('class', 'jumbotron');
          div.innerHTML = data[1][i]+ "<br>"+ data[2][i]+" <a href="+data[3][i]+">Read more</a>"
          article.appendChild(div);

        }// end
@jeffersonnnn the first parameter to .filter is a function - that receives each array element in turn
That function returns true to keep the element and false to drop the element.
[1, 2, 3, 4, 5].filter(function(elem) { return elem % 2 == 0; })
this will create a new array from only the even values (where elem % 2 is zero)
luccifer00
@luccifer00
Aug 14 2017 18:13
@sjames1958gm that is exactly what i was looking for.... i will study why i cant find the way, thanks a lot! you r a master for me ! :clap: :clap:
CamperBot
@camperbot
Aug 14 2017 18:13
luccifer00 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8313 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 14 2017 18:14
@luccifer00 :+1: Glad to help.
luccifer00
@luccifer00
Aug 14 2017 18:37

@sjames1958gm i see in

div.innerHTML = data[1][i]+ "<br>"+ data[2][i]+" <a href="+data[3][i]+">Read more</a>"
          article.appendChild(div);

after the Read more</a>" there is no semicolon... i check with and without semicolon, and the result is the same.... is better to use it right??

Stephen James
@sjames1958gm
Aug 14 2017 18:38
@luccifer00 I may have accidentally delete it may I suggest
Read more . . .
Stuhl
@Stuhl
Aug 14 2017 18:44
Hey guys is there a way to access a object through a string ?
E.g
let obj = {a: 10};
let str = "obj";
str.a // -> doesnt work!
Jason Luboff
@JLuboff
Aug 14 2017 18:45
@Stuhl No that wouldn't work. let str = "obj"; all this does is make a string with the word obj
Stuhl
@Stuhl
Aug 14 2017 18:46
@JLuboff Isnt there a workaround to achieve this ?
Jason Luboff
@JLuboff
Aug 14 2017 18:46
If you turn an object into a string, its no longer an object..
Stuhl
@Stuhl
Aug 14 2017 18:47
I dont want to make an new object (or the same one) I just want to reference with the string to the object
or point to it
Jason Luboff
@JLuboff
Aug 14 2017 18:48
Ok, I'm not sure I understand. Perhaps you can give some context to the problem?
Stephen James
@sjames1958gm
Aug 14 2017 18:49
@Stuhl You cannot convert a string into a variable name
Or object reference
Stuhl
@Stuhl
Aug 14 2017 18:51
Im making a small text game. Its basically like a turn based combat game where the Player can attack, defend etc.
I have a constructor which define Enemies and a algorithm is rolling a number which will pick a string from an array where each enemies name is stored in it
Keon Samuel
@keonsam
Aug 14 2017 18:51
store the string in the variable.
Stuhl
@Stuhl
Aug 14 2017 18:52
let wolf = new Enemy(100, 100, 100, 100, 100, "wolf", 1, 20);
let werewolf = new Enemy(150, 100, 200, 200, 200, "werewolf", 2, 50);
let uberwolf = new Enemy(200, 200, 200, 200, 200, "uberwolf", 3, 100);
Here are my enemies
Keon Samuel
@keonsam
Aug 14 2017 18:52
so what is the prob?
Stuhl
@Stuhl
Aug 14 2017 18:53
Now when the algorithm picks an enemy and its returning a string from the array of enemies like "wolf", "werewolf", "uberwolf" etc.
I want to make a function that will take that returned value and use it to access one of those constructor objects
kumquatfelafel
@kumquatfelafel
Aug 14 2017 18:54
@sjames1958gm Well... maybe eval depending on what's being done?? But that seems like a really bad idea.
Stephen James
@sjames1958gm
Aug 14 2017 18:54
Oh, yeah I forgot about eval (I never use it)
Keon Samuel
@keonsam
Aug 14 2017 18:54
sounds easy
Stuhl
@Stuhl
Aug 14 2017 18:55

Here is the function that will use the value to access (or atleast try to) the enemies values:

function loadEnemy() {
  let e = randomEnemy(); // Thats the function that will return one string from the arr

  console.log(e); // --> wolf
}

but if I do e.health for example, it's not displaying anything

Stephen James
@sjames1958gm
Aug 14 2017 18:56
@Stuhl Put them in a object
var enemies  = { wolf: new Enemy(100, 100, 100, 100, 100, "wolf", 1, 20)}
enemy = "wolf"
enemies[enemy];
kumquatfelafel
@kumquatfelafel
Aug 14 2017 18:56
@Stuhl what about randomEnemy()?
Keon Samuel
@keonsam
Aug 14 2017 18:56
variable.e.health.
Stuhl
@Stuhl
Aug 14 2017 18:57
@kumquatfelafel Fixed it, I added a comment right next to it
Keon Samuel
@keonsam
Aug 14 2017 18:57
wolf.e.health, try that.
also this.e
Stuhl
@Stuhl
Aug 14 2017 18:58
@sjames1958gm Mhm So basically put all three of them in a object and call them from there ?
kumquatfelafel
@kumquatfelafel
Aug 14 2017 18:58
I'd second @sjames1958gm on this
Stephen James
@sjames1958gm
Aug 14 2017 18:58
Yes.
Stuhl
@Stuhl
Aug 14 2017 19:00
@keonsam Doesn't work, neither this or wolf.e
will try out the object thing
Keon Samuel
@keonsam
Aug 14 2017 19:00
you need to look up how to make constructor function.
Stuhl
@Stuhl
Aug 14 2017 19:01
@sjames1958gm
basically that's the idea?
let enemies = {
  wolf: new Enemy(100, 100, 100, 100, 100, "wolf", 1, 20),
  werewolf: new Enemy(150, 100, 200, 200, 200, "werewolf", 2, 50),
  uberwolf: new Enemy(200, 200, 200, 200, 200, "uberwolf", 3, 100)
}
Stephen James
@sjames1958gm
Aug 14 2017 19:02
@Stuhl yes.
Stuhl
@Stuhl
Aug 14 2017 19:02
Awesome! works
@sjames1958gm @keonsam @kumquatfelafel Thanks all for helping out and letting me draining ur valuable time
CamperBot
@camperbot
Aug 14 2017 19:03
stuhl sends brownie points to @sjames1958gm and @keonsam and @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 608 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
:cookie: 412 | @keonsam |http://www.freecodecamp.com/keonsam
:star2: 8314 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 14 2017 19:03
@Stuhl All good - :+1:
dyon3334
@dyon3334
Aug 14 2017 19:14
hello all i ned some help with https://www.freecodecamp.org/challenges/mutations
function mutation(arr) {
    var output;
    var test = arr[1].split("");
    for (i = 0; i < test.length; i++) {
        if (arr.indexOf(test[i])) {
            output = true;
        } else {
            output = false;
        }
    }
    return output;
}

mutation(["hello", "hey"]);
Stephen James
@sjames1958gm
Aug 14 2017 19:16
@dyon3334 indexOf doesnt' return true/false when not found it returns -1 with is truthy
dyon3334
@dyon3334
Aug 14 2017 19:19
@sjames1958gm but this also dont work
function mutation(arr) {
    var output;
    var test = arr[1].split("");
    for (i = 0; i < test.length; i++) {
        if (arr.indexOf(test[i]) === -1) {
            output = false;
        } else {
            output = true;
        }
    }
    return output;
}

mutation(["hello", "hey"]);
Stephen James
@sjames1958gm
Aug 14 2017 19:20
@dyon3334 should you be searching in arr or maybe something more specific
dyon3334
@dyon3334
Aug 14 2017 19:20
oow yes
thanks
im gonna try now
dyon3334
@dyon3334
Aug 14 2017 19:26
@sjames1958gm thanks
CamperBot
@camperbot
Aug 14 2017 19:26
dyon3334 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8315 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 14 2017 19:27
@dyon3334 Set output to true to start - only set it to false in the loop
dyon3334
@dyon3334
Aug 14 2017 19:27
@sjames1958gm
almost all will pass now only the last two not because my code also gives true when a array with [hello,neo]
function mutation(arr) {
    var output;
    var test = arr[1].split("");
    for (i = 0; i < test.length; i++) {
        if (arr[0].indexOf(test[i]) === -1) {
            output = false;
        } else {
            output = true;
        }
    }
    return output;
}

mutation(["hello", "hey"]);
so maybe i need a whole other algo ?
Stephen James
@sjames1958gm
Aug 14 2017 19:30
@dyon3334 declare output as true, then only set to false in the loop (no else)
dyon3334
@dyon3334
Aug 14 2017 19:41
@sjames1958gm
function mutation(arr) {
    var counter = 0;
    var test = arr[1].split("");
    for (i = 0; i < test.length; i++) {
        if (arr[0].indexOf(test[i]) <= 0) {
            counter++;
        }
        if (counter === arr[0].length) {
            return true;
        } else {
            return false;
        }
    }
}

mutation(["hello", "hey"]);
Stephen James
@sjames1958gm
Aug 14 2017 19:45
@dyon3334 You've made it worse. You increment counter on indexOf 0 and -1 ?
And your counter check is inside the loop.
You were close before
You could have done, this at the start
var output = true;
Then if indexOf === -1 then output = false
don't set output = true after the declaration
dyon3334
@dyon3334
Aug 14 2017 19:48
@sjames1958gm thank you im gonna check again but it don need only checking every letter because neo and hello also have to terurn false
CamperBot
@camperbot
Aug 14 2017 19:48
dyon3334 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: dyon3334 already gave sjames1958gm points
dyon3334
@dyon3334
Aug 14 2017 19:49
oow shit i have to learn read poperly
Stephen James
@sjames1958gm
Aug 14 2017 19:49
@dyon3334 You can simply return false on the first failure and return true if you make it all the way through the loop
dyon3334
@dyon3334
Aug 14 2017 19:52
@sjames1958gm but still now mutation(["Mary", "Army"]) should return true.
mutation(["Mary", "Aarmy"]) should return true. dont pass
function mutation(arr) {
    var test = arr[1].split("");
    for (i = 0; i < test.length; i++) {
        if (arr[0].indexOf(test[i]) === -1) {
            return false;
        }

    }
    return true;
}

mutation(["hello", "hey"]);
Stephen James
@sjames1958gm
Aug 14 2017 19:53
@dyon3334 From the instructions ignoring case.
dyon3334
@dyon3334
Aug 14 2017 19:53
what do you mean ?
Stephen James
@sjames1958gm
Aug 14 2017 19:53
you should probably make both strings all one case (upper or lower) at the start
dyon3334
@dyon3334
Aug 14 2017 19:54
oow yes hahah thanks !!
@sjames1958gm thanks a lot im gonna check
CamperBot
@camperbot
Aug 14 2017 19:54
dyon3334 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: dyon3334 already gave sjames1958gm points
Kelechi Chinaka
@ke1echi
Aug 14 2017 19:56
function vowel2index(str) {
  var vowel = 'aeiou', arr = [];
  for (var i = 0; i < str.length; i++) {
     (vowel.indexOf(str[i]) !== -1) ? arr.push(i + 1) : arr.push(str[i]);
  }
  return arr.join('');
}
fails 1 test and i cant make a meaning of the error msg
can u take a look @sjames1958gm
Stephen James
@sjames1958gm
Aug 14 2017 20:00
@kelechy What are the instructions?
dyon3334
@dyon3334
Aug 14 2017 20:00

@sjames1958gm

function mutation(arr) {
    for (j = 0; j < arr.length; j++) {
        arr[j].toLowerCase();
    }
    var test = arr[1].split("");
    for (i = 0; i < test.length; i++) {
        if (arr[0].indexOf(test[i]) === -1) {
            return false;
        }

    }
    return true;
}

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

still not good

Stephen James
@sjames1958gm
Aug 14 2017 20:00
@dyon3334 toLowerCase returns a new string.
dyon3334
@dyon3334
Aug 14 2017 20:01
@sjames1958gm so i have to push it i again okay thank
CamperBot
@camperbot
Aug 14 2017 20:01
dyon3334 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: dyon3334 already gave sjames1958gm points
Stephen James
@sjames1958gm
Aug 14 2017 20:01
or arr[j] = arr[j].toLowerCase()
dyon3334
@dyon3334
Aug 14 2017 20:03
@sjames1958gm thanks fo saving me that work it works now :) im verry happy
CamperBot
@camperbot
Aug 14 2017 20:03
dyon3334 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: dyon3334 already gave sjames1958gm points
Kelechi Chinaka
@ke1echi
Aug 14 2017 20:04

Write a function

vowel2index(str)
that takes in a string and replaces all the vowels [a,e,i,o,u] with their respective positions within that string.
E.g:

vowel2index('this is my string') == 'th3s 6s my str15ng'

Stephen James
@sjames1958gm
Aug 14 2017 20:05
@kelechy What's the error
Kelechi Chinaka
@ke1echi
Aug 14 2017 20:06
i think it would make more sense if u see the particular test case that fails, it makes no sense to me yet..may i send the kata link? @sjames1958gm
Expected: '90\'s c7rnh11l13 1516st19n, p24ckl28d b32tch36r yr m43ss46ng49r b53g g57str61p63b n67xt l72v74l l78gg81ngs l87st90cl93 m96d98t100t102103n try-h111rd V116c118. T122x124d126rmy g132str136p138b g142ntr146fy, m152h f156p 159rg162n164c 167nn170171 f174ng177rst181ch184 p187ckl191d v195g197n. S202203t205n s209st212213n215bl218 PBR&B c227rnh231l233 VHS. J241242n sh247rts 252ct255256lly b262tt265rs 269gh bl275g 278nt281ll284g286nts290291. 294rt297s299n K303ckst308rt311r D315Y, f320x322323 cl327ch330 s333lv336337 l340-f343 f346347r l351k353. PBR&B 362dd F367t369r371 373gh f378ng381rst385ch388 cr392y W396s 399nd402rs405n ch410411 typ416wr419t421r 424Ph427n429 b432sp435k437 f440441r l445k447, 450nt453ll456g458nts462463 ph467t469 b472473th d478r480ct tr486d488. 491492sth496t498c T502mblr P509rtl513nd X518X520 sq524525d, synth v536r538l l542st545cl548 sk552t554b556557rd f562563r d567ll570r t574575st c580rnh584l586 Bl590591 B594ttl598 s601m603604t606cs.', instead got: '90\'s c7rnh11l13 A16st19n, p24ckl28d b32tch36r yr m43ss46ng49r b53g g57str61p63b n67xt l72v74l l78gg81ngs l87st90cl93 m96d98t100t102103n try-h111rd V116c118. T122x124d126rmy g132str136p138b g142ntr146fy, m152h f156p 159rg162n164c 167nn170171 f174ng177rst181ch184 p187ckl191d v195g197n. S202203t205n s209st212213n215bl218 PBR&B c227rnh231l233 VHS. J241242n sh247rts 252ct255256lly b262tt265rs 269gh bl275g Int281ll284g286nts290291. Art297s299n K303ckst308rt311r DIY, f320x322323 cl327ch330 s333lv336337 l340-f343 f346347r l351k353. PBR&B Odd F367t369r371 373gh f378ng381rst385ch388 cr392y W396s And402rs405n ch410411 typ416wr419t421r 424Ph427n429 b432sp435k437 f440441r l445k447, Int453ll456g458nts462463 ph467t469 b472473th d478r480ct tr486d488. A492sth496t498c T502mblr P509rtl513nd XOXO sq524525d, synth v536r538l l542st545cl548 sk552t554b556557rd f562563r d567ll570r t574575st c580rnh584l586 Bl590591 B594ttl598 s601m603604t606cs.'
Stephen James
@sjames1958gm
Aug 14 2017 20:07
@kelechy Hmm capital vowels?
Kelechi Chinaka
@ke1echi
Aug 14 2017 20:09
i dont understand
Moisés Man
@moigithub
Aug 14 2017 20:10
ur code checking only for a but not for A (and all others vowels)
check uppercases too or convert ur str[] tolowercase
instead got: '90\'s c7rnh11l13 A16st19n
Expected: '90\'s c7rnh11l13 1516st19n,
Stephen James
@sjames1958gm
Aug 14 2017 20:12
@kelechy A vs a as @moigithub says you have a bunch of upper case vowels the expected string does not
@kelechy vowel.indexOf(str[i].toLowerCase())
Kelechi Chinaka
@ke1echi
Aug 14 2017 20:13
ok thanks @sjames1958gm @moigithub
CamperBot
@camperbot
Aug 14 2017 20:13
kelechy sends brownie points to @sjames1958gm and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3582 | @moigithub |http://www.freecodecamp.com/moigithub
:star2: 8316 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
iso
@iso1048
Aug 14 2017 20:18
Hi is anyone able to help with the 'sum all prime numbers' challenge?
Stephen James
@sjames1958gm
Aug 14 2017 20:33
@gothamknight What's the issue?
iso
@iso1048
Aug 14 2017 20:36

@sjames1958gm

function sumPrimes(num) {

  var arr=[];

  for (var i = 2; i <=num; i++){
    if (i%2 !==0){
      arr.push(i);
    }
  }
  arr.unshift(2);
  for (var j = 1; j<arr.length; j+=arr[j]){
    for (var q = 2; q <=arr[arr.length-1]/arr[j]; q++){
      if (arr.indexOf(arr[j]*q) !== -1){
        var x = arr.indexOf(arr[j]*q);
        arr[x] = 0;
      }
    }
  }
  return arr;
}

sumPrimes(977);

that is my code so far - the console says I have a potential infinite loop in this line:for (var q = 2; q <=arr[arr.length-1]/arr[j]; q++){, but I do not see how.

Manuel
@manny45
Aug 14 2017 20:40
function testGreaterThan(val) {
  if (val>10) {  // Change this line
    return "Over 100";
  }

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

  return "10 or Under";
}

// Change this value to test
testGreaterThan(10);
Stephen James
@sjames1958gm
Aug 14 2017 20:40
@gothamknight I don't see an infinite loop - Not sure what your outer loop is doing
Manuel
@manny45
Aug 14 2017 20:40
What's wrong
Comparison with the Greater Than Operator
I changed 101 to 10
Stephen James
@sjames1958gm
Aug 14 2017 20:40
@manny45 Well val > 10 and the string Over 100 don't seem to match
Manuel
@manny45
Aug 14 2017 20:41
but if I change it, it ends up being wrong
never mind ot it thanks @sjames1958gm
CamperBot
@camperbot
Aug 14 2017 20:41
manny45 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8317 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 14 2017 20:42
@camperbot :+1:
iso
@iso1048
Aug 14 2017 20:43
@sjames1958gm the loop with variable j is looping through the elements of the array. Then the variable q in the second loop is a factor which is multiplied to the elements of the array - if the product is in the array , the if statement replaces it with 0. that is my thinking - not sure it if is right...
Stephen James
@sjames1958gm
Aug 14 2017 20:45
@gothamknight what is j += arr[j] j will be 1 then 4 then some larger number, not 1, 2, 3, 4 like I imagined
When I put in the console it did hang my browser.
iso
@iso1048
Aug 14 2017 20:47
@sjames1958gm oh yeah - i just changed that to j++ and the console still gives the 'potential infinite loop' error
Tuomas Salokanto
@stuomas
Aug 14 2017 20:48
How can I copy a static string to clipboard in JS? Not reading from elemets, no dummy objects, just copy a string variable to clipboard?
Christopher McCormack
@cmccormack
Aug 14 2017 20:54
@stuomas select the text and use something like the following
var text = document.getElementById('input').select()
var copy = document.execCommand('copy')
Might want to use a try/catch block just in case
I have an example of it here if you want to take a look: https://codepen.io/cmccormack/pen/rwqLyr
Tuomas Salokanto
@stuomas
Aug 14 2017 20:55
but that reads from an element "input". I just want to copy var myString = "copy this text";
Christopher McCormack
@cmccormack
Aug 14 2017 20:56
@stuomas you can append the text in some way to the DOM then copy it
Tuomas Salokanto
@stuomas
Aug 14 2017 20:56
yeah I saw that kind of examples but just couldnt believe that is the only way...
Christopher McCormack
@cmccormack
Aug 14 2017 20:57
why not? Why would you expect the clipboard to be called from a script within a page on content the user may not even be able to see? that's a huge security risk
It's still a risk if you create the element, copy, then remove, but I think the idea is don't give malicious developers those kinds of tools in the first place, make them work for it
Tuomas Salokanto
@stuomas
Aug 14 2017 21:02
well like you said it's still possible and pretty easy so I dont think security is the concern
soulproprietor
@soulproprietor
Aug 14 2017 21:40
hello, can someone help me with a 'circular object' error?
var friends = [];
var relationships = {};
var matches = [];
friends.push(animals[0].username,animals[1].username);
relationships.friends = friends;
relationships.matches = matches;
relationships.matches.push(animals[2].username,animals[3].username);
for (var i in animals) {
  animals[i] = relationships;
}
console.log(animals);
what is a circular object ans how can I correct it
Margaret
@Margaret2
Aug 14 2017 21:49
@soulproprietor i'm guessing the circular object thing is because the content of relationships is defined by animals, and now you want the content of animals to be defined by relationships
soulproprietor
@soulproprietor
Aug 14 2017 21:51
so when I store a variable using Push, it stores that path, and not the final value?
how can I correct this? toString() would work?
Margaret
@Margaret2
Aug 14 2017 21:52
idk, try it and see
soulproprietor
@soulproprietor
Aug 14 2017 21:59
even storing the variables like this I get the error:
relationships.matches[0] = animals[3].username;
relationships.matches[1] = animals[2].username;
i can't seem to avoid a refrence from animals
toString doesnt work either :-/
Margaret
@Margaret2
Aug 14 2017 22:00
var animals = [{username: 'taie'}, {username: 'hua'}, {username: 'gong'}, {username: 'laibu'}]
var friends = animals.slice(0,2).map(x=>x.username)
var matches = animals.slice(2).map(x=>x.username)
animals.forEach(x=>{x.friends = friends; x.matches = matches; delete x.username;})
this works
using slice and map

maybe because

The slice() method returns a shallow copy

soulproprietor
@soulproprietor
Aug 14 2017 22:01
ahh
yes... thats what I need. the copy and not the path stored
thanks @Margaret2
CamperBot
@camperbot
Aug 14 2017 22:02
soulproprietor sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 2881 | @margaret2 |http://www.freecodecamp.com/margaret2
Margaret
@Margaret2
Aug 14 2017 22:02
:smile_cat:
ctcrnitv
@ctcrnitv
Aug 14 2017 22:27
does anyone here know how to deal with environment variables in the integrates vscode terminal?
when I check 'env' in the integrated terminal, it shows some old API key that I once had
but it's not in my external terminal's env
I have no idea how the integrated terminal is getting that
Joseph
@revisualize
Aug 14 2017 22:49
@ctcrnitv I don't BUT!
ctcrnitv
@ctcrnitv
Aug 14 2017 22:49
well I found the answer
Joseph
@revisualize
Aug 14 2017 22:49
@ctcrnitv VSCode has a dedicated gitter chat.
ctcrnitv
@ctcrnitv
Aug 14 2017 22:49
just had to use the unset command
Joseph
@revisualize
Aug 14 2017 22:50
Oh.
ctcrnitv
@ctcrnitv
Aug 14 2017 22:50
unset lets you unset environment variables
goot to know for later