These are chat archives for FreeCodeCamp/HelpJavaScript

6th
Feb 2018
jusgoose
@gusd773
Feb 06 2018 00:07
thanks @JLuboff
still not sure how you guys check stuff on python tutor nothing comes up when I run the code, I had to use Chrome console?
CamperBot
@camperbot
Feb 06 2018 00:07
gusd773 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
api offline
Jason Luboff
@JLuboff
Feb 06 2018 00:08
Select visualize...make sure you choose Javascript as the programming languge, copy your code into the box and hit visualize. It shows 35 steps from the above code
Gulsvi
@gulsvi
Feb 06 2018 00:09
If you just want a console other than your dev tools, you could use codepen: https://s.codepen.io/pen?editors=0012
PythonTutor has more to offer in terms of features
jusgoose
@gusd773
Feb 06 2018 00:25
thank you guys so much my idea worked :) @gulsvi
thank you @gulsvi
CamperBot
@camperbot
Feb 06 2018 00:25
gusd773 sends brownie points to @gulsvi :sparkles: :thumbsup: :sparkles:
:star2: 2585 | @gulsvi |http://www.freecodecamp.org/gulsvi
jusgoose
@gusd773
Feb 06 2018 00:40
I keep getting the "return a[value] " as undefined, my "vals" array is finally set up right but now I just need it to return the a["lowest index in vals"]
function firstDuplicate(a) {
   var vals= [];
   var value=vals[0];
   for (var i=0; i<a.length;i++){
      for (var j=i+1; j<a.length; j++){
         if (a[i]==a[j] && i!==j){
            vals.push(a.indexOf(a[i],j)); 
            }

          }
      }

      for (var n = 0; n<vals.length; n++){
         if (vals[n]<vals[0]){
            value=vals[n];
         }
      }
      return a[value];
   }
you guys are the best btw I have learned so much on here & FCC in general
Diego Mayer
@Chrono79
Feb 06 2018 00:42
@gusd773 what are you trying to do there?
jusgoose
@gusd773
Feb 06 2018 00:43
@Chrono79 return the earliest index of a duplicate occurence
Diego Mayer
@Chrono79
Feb 06 2018 00:43
so, the index of the first repeated number? [1,2,3,4,1] would be 4
or the index of the first number that repeats in the array? or [1,2,3,4,1] would be 0
jusgoose
@gusd773
Feb 06 2018 00:48
@chrono79 I'm sorry return the array value not the index
Diego Mayer
@Chrono79
Feb 06 2018 00:49
so in either case it'll be 1 right?
jusgoose
@gusd773
Feb 06 2018 00:49
@Chrono79 correct
Diego Mayer
@Chrono79
Feb 06 2018 00:50
use an object
use the numbers as keys and when the key already exists return that number
jusgoose
@gusd773
Feb 06 2018 00:50
This message was deleted
@Chrono79 not sure what you mean
Diego Mayer
@Chrono79
Feb 06 2018 00:51
use a loop to store numbers as an object keys
if the key doesn't exist, create the property, when it does exist, it's the first repetition
Maybe you don't know objects yet, or do you?
jusgoose
@gusd773
Feb 06 2018 00:53
@Chrono79 haha it sounds hilarious to admit but nope not really
reads through objects for dummbies fast
Brad
@bradtaniguchi
Feb 06 2018 00:53
@gusd773 look up a hashmap datastructure, or map (usually synonymous)
jusgoose
@gusd773
Feb 06 2018 00:55
@bradtaniguchi I am sure you guys are right I am just trying to learn from why my code is not working, that usually helps me more
I think it's called debugging, no I'm not being sarcastic 100% sincere
Diego Mayer
@Chrono79
Feb 06 2018 00:58
@gusd773 look at your code again, vals is an empty array, value is initialized as vals[0] (undefined)
         if (vals[n]<vals[0]){
            value=vals[n];
         }
if that condition isn't true, value isn't changed
jusgoose
@gusd773
Feb 06 2018 00:59
@Chrono79 yea I was worried that's what was wrong lol
thank you @Chrono79
CamperBot
@camperbot
Feb 06 2018 00:59
gusd773 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4611 | @chrono79 |http://www.freecodecamp.org/chrono79
Brad
@bradtaniguchi
Feb 06 2018 00:59
@gusd773 No its fine, when you fix the code I recommend reading up the datastructure that Diego is recommending using. :D
Diego Mayer
@Chrono79
Feb 06 2018 00:59
So you return a[value]; with value being undefined, thus undefined
Gulsvi
@gulsvi
Feb 06 2018 01:03
I think your method would give 3 instead of 2 with this [1, 2, 3, 3, 4, 5, 2, 2] unless I'm misunderstanding @Chrono79
Maybe that is the intended approach though, not really sure
"earliest index of a duplicate occurrence" seems to mean that we should return 2
Diego Mayer
@Chrono79
Feb 06 2018 01:13
@gusd773 could you copy and paste a couple of input / output pairs?
jusgoose
@gusd773
Feb 06 2018 01:13
@gulsvi I explained it incorrectly, it's supposed to return the value who has the earliest occurring duplicate in your example it would be 3
sure @Chrono79
Gulsvi
@gulsvi
Feb 06 2018 01:14
Okay, using an object is a very clean way of doing that
Otherwise, you can use indexOf and lastIndexOf
jusgoose
@gusd773
Feb 06 2018 01:15

[2, 3, 3, 1, 5, 2] ; 3

[2, 1, 3] ; -1

[8, 4, 6, 2, 6, 4, 7, 9, 5, 8]; 6

Diego Mayer
@Chrono79
Feb 06 2018 01:16
Then it is as I thought
and return -1 if no number repeats
jusgoose
@gusd773
Feb 06 2018 01:18
@Chrono79 yea I just fixed it for the -1 at the end of the first loop I wrote "if (vals.length==0) { return -1}"
Diego Mayer
@Chrono79
Feb 06 2018 01:18
@gusd773 did you solve it then?
jusgoose
@gusd773
Feb 06 2018 01:19
@Chrono79 i wish lol, na I am still being hard headed avoiding the map since that's a whole new lesson when I might have another solution on my hands, at least I believe I do
This message was deleted
JunxianZhang
@blackwa
Feb 06 2018 07:14
who can show me the example of NO.168? THX
Dan Couper
@DanCouper
Feb 06 2018 08:27
The number is your personal points, need a name
Blauelf
@Blauelf
Feb 06 2018 09:32
Also, THX is 1138 (if any of you remembers that movie). Also referenced in Dark Star: http://3.bp.blogspot.com/-HOmm1RH3IXY/VTp6pQWcadI/AAAAAAAABJw/FLP7Agl15r8/s1600/dark%2Bstar%2Btank2.JPG
Tiago Correia
@tiagocorreiaalmeida
Feb 06 2018 09:50
hey gm
does anyone know a good movies database api?I found a few but there's some problems of them like the usual rate limit per certain time the problem is the api doesnt accept's a query limit value so I can't really controll it making it impossible to work with
Jen
@jenniredfield
Feb 06 2018 10:50
HI anyone done the 'arguments optional' challenge? I did it but feel its not the best solution, would like to compare if anyone wants to talk privately
Markus Kiili
@Masd925
Feb 06 2018 10:51
@jenniredfield You could also post it on https://gitter.im/FreeCodeCamp/CodeReview
Marat
@Marat89bluolyu
Feb 06 2018 10:57
Hi all, need make alert message after stop scrolling event, and i dont know how :) please help :smile:
Stephen James
@sjames1958gm
Feb 06 2018 11:05
@Marat89bluolyu You are wanting to display an alert after the user stops scrolling the wheel?
I would consider a timer setTimeout, that displays the alert, every time they scroll the timer is reset.
There is no, "not scrolling" event.
Marat
@Marat89bluolyu
Feb 06 2018 11:07
@sjames1958gm Need to wrap an event?
Stephen James
@sjames1958gm
Feb 06 2018 11:09
@Marat89bluolyu
More you have to create your own "event" using timers.
@Marat89bluolyu Assuming that what you want is to show an alert when they stop scrolling.
Stephen James
@sjames1958gm
Feb 06 2018 11:24
@Marat89bluolyu You can create a "global" alertTimer. then in your "wheel" event handler;
          // If the timer is running stop it because the user scrolled
          if (alertTimer) {
            clearTimeout(alertTimer);
          }

          // Start new timer that displays alert if no scrolling after 2 seconds 
          alertTimer = setTimeout(function() {
            alert("you stopped scrolling?");
            alertTimer = undefined;
          }, 2000);
Marat
@Marat89bluolyu
Feb 06 2018 11:25
@sjames1958gm i need to put it in event listener?
Stephen James
@sjames1958gm
Feb 06 2018 11:25
@Marat89bluolyu Inside the "wheel" event listener? Yes.
Marat
@Marat89bluolyu
Feb 06 2018 11:25
aaaaaaa
=)
Marat
@Marat89bluolyu
Feb 06 2018 11:39
@sjames1958gm something wrong with clearTimeout , without if statement i getting allert
Stephen James
@sjames1958gm
Feb 06 2018 11:42
@Marat89bluolyu Did you create the alertTimer variable outside of the event listener?
Marat
@Marat89bluolyu
Feb 06 2018 11:43
@sjames1958gm i create alertTimer Inside
Stephen James
@sjames1958gm
Feb 06 2018 11:44
@Marat89bluolyu You need
var alertTimer;
Outside the event listener, so it is shared across wheel events
Marat
@Marat89bluolyu
Feb 06 2018 11:46
thats work!
@sjames1958gm thank you !!!
CamperBot
@camperbot
Feb 06 2018 11:46
marat89bluolyu sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8942 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Feb 06 2018 11:48
@Marat89bluolyu :+1:
Marat
@Marat89bluolyu
Feb 06 2018 11:49
could you explain why i need declare variable outside the listener and check this variable inside?
Stephen James
@sjames1958gm
Feb 06 2018 11:51
@Marat89bluolyu You need the variable to exist from one "wheel" event to the next.
So the variable has to exist outside the listener, so that it is the same variable and the same timer
If it is inside the listener you get a new "instance" of the variable each time.
Marat
@Marat89bluolyu
Feb 06 2018 11:54
@sjames1958gm Ah ok, i think i understand. Thank's for help!
CamperBot
@camperbot
Feb 06 2018 11:54
marat89bluolyu sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
api offline
Stephen James
@sjames1958gm
Feb 06 2018 11:57
@Marat89bluolyu Sure, no problem.
Razvan Jackson
@RazvanJackson
Feb 06 2018 12:19
Hey guys
This it's not gonna work in React no?
<Wrapper>
                    <Navbar/>
                    <Header/>
                    <Movies/>
</Wrapper>
Nvm i solved it
<div id="Wrapper"> {this.props.children} </div>
Zunaid Aslam
@ZunaidAslam
Feb 06 2018 13:30

Basic Algorithm Section : Mution Problem -

I used the code below. It works for all the text except for hello and hey?!?

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

  var split = lCap[1].split("");
  for (var j=0; j<arr.length; j++) {
  return lCap[0].indexOf(split[j])!=-1;
}}

mutation(["hello", "hey"]);
Diego Mayer
@Chrono79
Feb 06 2018 13:32
@Zunaid-Aslam return exits the loop, you're only testing one char then
there is an indexOf method for strings too
Zunaid Aslam
@ZunaidAslam
Feb 06 2018 13:52
oooh
So should I just put it outside the for loop @Chrono79
Diego Mayer
@Chrono79
Feb 06 2018 13:54
Not exactly, you should only return inside the loop if some condition is met
and return outside the loop if it wasn't
Zunaid Aslam
@ZunaidAslam
Feb 06 2018 13:56
I guess I need to think more on how I can see if all the letters of second argument is present in first argument
My code is only checking the first letter it seems.
Blauelf
@Blauelf
Feb 06 2018 14:04
The keyword would be "early return", returning as soon as you know the result (in your case that's only possible when you want to return false, a true result would mean you passed the loop without returning). The opposite is "single return", having one return statement (so you cannot leave the function at surprising ends).
Blauelf
@Blauelf
Feb 06 2018 14:16
https://softwareengineering.stackexchange.com/a/118793 has an interesting view on "Single Entry, Single Exit" and its original meaning. I understood it all wrong, and I'm not alone. Second answer is about how I understood it (and it makes sense, too).
lfvpCO
@lfvpCO
Feb 06 2018 15:47
Hello there. Hi guys, I wanna know about a JavaScript book..
I’m starting with JavaScript I need something clear in examples and content!
Christopher McCormack
@cmccormack
Feb 06 2018 15:49
@lfvpCO I've heard good things about this series but haven't read it myself https://github.com/getify/You-Dont-Know-JS
I did read Javascript - The Good Parts and thought it was pretty decent
Jason Luboff
@JLuboff
Feb 06 2018 16:06
I've only read the first book of YDKJS, but I liked it
Christopher McCormack
@cmccormack
Feb 06 2018 16:08
@JLuboff :wave:
Jason Luboff
@JLuboff
Feb 06 2018 16:08
@cmccormack :wave: How's it going
Christopher McCormack
@cmccormack
Feb 06 2018 16:08
@JLuboff I did something fun yesterday
Found out my godaddy account was going to be like triple price for the next year so switched to a digitalocean vps
Kaz Baig
@kbaig
Feb 06 2018 16:09
That's godaddy for ya
Christopher McCormack
@cmccormack
Feb 06 2018 16:09
$5/month and full linux server with amazing guides on their learning center
Jason Luboff
@JLuboff
Feb 06 2018 16:09
digitalocean? Haven't heard of it
Christopher McCormack
@cmccormack
Feb 06 2018 16:09
Got everything switched over pretty easily, and now have a let's encrypt setup that will actually autorenew
Jason Luboff
@JLuboff
Feb 06 2018 16:09
Sweet
Christopher McCormack
@cmccormack
Feb 06 2018 16:09
I got to setup my own LEMP stack as well and it was pretty easy
Jason Luboff
@JLuboff
Feb 06 2018 16:10
Ewww... LEMP includes PHP
Christopher McCormack
@cmccormack
Feb 06 2018 16:10
it's definitely not simple web hosting, but it wasn't hard either, couple hours setup and now I have tons of flexibility
@JLuboff haha yeah but I'm going to use PHP for an e-mail contact section until I'm more comfortable handling it with node
tons of drop in php templates for sending an e-mail
Now I can run my own node apps as well which is pretty cool
Nate Mallison
@NJM8
Feb 06 2018 16:13
@lfvpCO http://javascriptbook.com/ is great, also heard good things about YDKJS. I also really enjoyed http://www.javascriptenlightenment.com/
Christopher McCormack
@cmccormack
Feb 06 2018 16:13
MDN tends to have some good documentation on JS as well, along with small projects that can help fill in some gaps in knowledge
Jason Luboff
@JLuboff
Feb 06 2018 16:14
I've had nothing but problems with PHP. Like the time I chagned the time zone in php.ini but forgot a ' and it continuied to act like it was working when it wasn't (wasn't sending email). Or how I have it creating a JSON file, but 60% of the time, doesn't work so the user has to keep resubmitting :joy: (this one I'm working on a fix by replacing with nodejs/mongo db and get rid of php all together)
Christopher McCormack
@cmccormack
Feb 06 2018 16:15
I"m learning this morning that e-mail only works with php if you actually have a mail client installed :D
seems obvious in retrospect but was bugging me all night last night
Jason Luboff
@JLuboff
Feb 06 2018 16:17
Just use node to do all that ;)
Christopher McCormack
@cmccormack
Feb 06 2018 16:18
yeah I probably should
Jason Luboff
@JLuboff
Feb 06 2018 16:20
I've tested and verified nodemailer works, given you still need an smtp server to handle the mail routing
Christopher McCormack
@cmccormack
Feb 06 2018 16:24
i'm running through a guide to setup postfix right now, I think that should cover smtp
Jason Luboff
@JLuboff
Feb 06 2018 16:27
Well there you go
Christopher McCormack
@cmccormack
Feb 06 2018 16:32
hehe
I'll try to jump to node asap though to placate our php hate
Jason Luboff
@JLuboff
Feb 06 2018 16:38
;)
aRtoo
@artoodeeto
Feb 06 2018 16:42

hey anyone using react its my first time how i still get an error using JSX but everything on my json.package is installed.
@Marauder @Kai

  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.6.1",
    "babel-preset-es2016": "^6.24.1",
    "babel-preset-es2017": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "react": "^16.2.0",
    "react-bootstrap": "^0.32.1",
    "react-dom": "^16.2.0",
    "webpack": "^3.10.0",
    "webpack-dev-server": "^2.11.1"
  },
  "presets": [
    "env",
    "react"
  ],
  "dependencies": {
    "create-react-app": "^1.5.1",
    "start": "^5.1.0"
  }
}

thats inside my package.json bros.

Christopher McCormack
@cmccormack
Feb 06 2018 16:46
@artoodeeto did you create your app using create-react-app or just install it as a dependency?
aRtoo
@artoodeeto
Feb 06 2018 16:46
@cmccormack yes sir
Christopher McCormack
@cmccormack
Feb 06 2018 16:47
@artoodeeto no which one did you do
Stephen James
@sjames1958gm
Feb 06 2018 16:47
@cmccormack did you do A or B - yes
aRtoo
@artoodeeto
Feb 06 2018 16:47
@cmccormack im sorry i installed it like this npm install create-react-app
@sjames1958gm sorry. im making milk for my nephew. haha
Christopher McCormack
@cmccormack
Feb 06 2018 16:48
using create react app you should be building a new project, using something like # npm create-react-app my-app
create-react-app is not a dependency
Sweet Coding :)
@SweetCodingInc
Feb 06 2018 16:48
@artoodeeto what did you do exactly? It doesn't look like a package.json generated by create react app
it looks like this
{
  "name": "react-redux-demo",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.17.1",
    "bootstrap": "^4.0.0",
    "classnames": "^2.2.5",
    "lodash": "^4.17.5",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-iframe": "^1.1.0",
    "react-redux": "^5.0.6",
    "react-scripts": "1.1.0",
    "reactstrap": "^5.0.0-beta",
    "redux": "^3.7.2",
    "redux-observable": "^0.17.0",
    "rxjs": "^5.5.6"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}
Christopher McCormack
@cmccormack
Feb 06 2018 16:48
it builds all of the config for you, including your webpack/babel config
Sweet Coding :)
@SweetCodingInc
Feb 06 2018 16:49

@artoodeeto That's not how you do it...

First run this command

npm install -g create-react-app

Sweet Coding :)
@SweetCodingInc
Feb 06 2018 16:49

then go to a new folder and run

create-react-app my-app

aRtoo
@artoodeeto
Feb 06 2018 16:50
@SweetCodingInc so in side my project folder sir i installed it like this.
npm install babel-preset-react react react-dom react-bootstrap --save-dev
Sweet Coding :)
@SweetCodingInc
Feb 06 2018 16:51
@artoodeeto the whole point of using create-react-app is not have to do all that stuff :laughing:
You installed all that, that is fine, but you haven't configured webpack to utilise all these things you installed
aRtoo
@artoodeeto
Feb 06 2018 16:51
@cmccormack in the tutorial it says to create a folder called components then a global.js for react.
Christopher McCormack
@cmccormack
Feb 06 2018 16:52
@artoodeeto that's probably after you have built a new create-react-app project
Sweet Coding :)
@SweetCodingInc
Feb 06 2018 16:52
@artoodeeto Don't follow that tutorial.. It seems outdated
Christopher McCormack
@cmccormack
Feb 06 2018 16:52
can you link the tutorial you are using?
aRtoo
@artoodeeto
Feb 06 2018 16:52
@SweetCodingInc at first i followed the tutorial then someone tolde me to do create-react-app :(
@cmccormack for sure sir wait
@SweetCodingInc its a tutorial about es6 but hes just doin a sample on how to use es6 on react
Christopher McCormack
@cmccormack
Feb 06 2018 16:53
oh it's a paid course. Well I would recommend reading the official facebook page on create-react-app I linked and see if you can use it to understand what the tutorial may be saying or saying wrong
aRtoo
@artoodeeto
Feb 06 2018 16:54
@SweetCodingInc i think so its outdated. because he showed the depndencies its older version
@cmccormack for sure sir. thanks
CamperBot
@camperbot
Feb 06 2018 16:54
artoodeeto sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1303 | @cmccormack |http://www.freecodecamp.org/cmccormack
aRtoo
@artoodeeto
Feb 06 2018 16:54
@SweetCodingInc thank you too bro
CamperBot
@camperbot
Feb 06 2018 16:54
artoodeeto sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 244 | @sweetcodinginc |http://www.freecodecamp.org/sweetcodinginc
Tom
@moT01
Feb 06 2018 17:14
regex help...
trying to replace New York with <span class="matched">Ne</span>w York
but it wont always be new york - it might be new jersey - and wont always be ne it might be new or any string
Jason Luboff
@JLuboff
Feb 06 2018 17:16
Thats too fancy of regex work for me :P
Tom
@moT01
Feb 06 2018 17:17
me too
it's probly not too tough - just not my area
the string to search for is a variable from an input
Stephen James
@sjames1958gm
Feb 06 2018 17:18
@moT01 What are the exact rules for your replacement?
Tom
@moT01
Feb 06 2018 17:19
i get a value from input - filter an array of cities to match
so if you type ne
new york, new jersey... all show up
i want what was typed to be a different color
so the Ne (if that was typed) would be one color - and the rest would be black
so here's what i have for that part
      let regex = new RegExp(value, 'gi');
      var city = result.city.replace(regex, '<span style="color: white">' + value + '</span');
      var state = result.state.replace(regex, '<span style="color: white">' + value + '</span');
its replacing the whole string with ne or whatever was typed - and value is the variable that holds what was typed
Christopher McCormack
@cmccormack
Feb 06 2018 17:22
@moT01 don't update your original array, just add the replaced text to your output
not sure if that's what you're doing but It would create lots of weird spans wrapping spans if you tried to replace the original text with the text including the span elements
@moT01 what isn't working for you? Other than your closing span tag not having a closing >?
Tom
@moT01
Feb 06 2018 17:25
didnt catch that
its replacing the whole string with value and not keeping the other parts of the string
so if new is typed
it replaces New York with <span style="color: white">New</span>
and the york is gone
you know what
scratch all that
its working
closing tag did it
Christopher McCormack
@cmccormack
Feb 06 2018 17:27
hah ok that's good, seemed like it should work OK with what you had
Tom
@moT01
Feb 06 2018 17:27
thanks @cmccormack @sjames1958gm @JLuboff
CamperBot
@camperbot
Feb 06 2018 17:27
mot01 sends brownie points to @cmccormack and @sjames1958gm and @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1304 | @cmccormack |http://www.freecodecamp.org/cmccormack
:star2: 8943 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
:star2: 2320 | @jluboff |http://www.freecodecamp.org/jluboff
Jason Luboff
@JLuboff
Feb 06 2018 17:28
Hmm..anybody ever had an issue with a dropdown menu not rendering correctly when appending to an existing div? Its rendering the options outside of the select
Christopher McCormack
@cmccormack
Feb 06 2018 17:28
Anyone mind testing out my feedback form? https://mackville.net/#contact
Stephen James
@sjames1958gm
Feb 06 2018 17:29
@moT01 BTW you probably don't want the g flag
Christopher McCormack
@cmccormack
Feb 06 2018 17:29
@JLuboff do the options still work properly when selected?
Jason Luboff
@JLuboff
Feb 06 2018 17:29
@cmccormack
blob
@cmccormack No they render outside of it lol
Jason Luboff
@JLuboff
Feb 06 2018 17:30
@cmccormack
blob
Top two are rendered on page load, the bottom two are dynamically added
Christopher McCormack
@cmccormack
Feb 06 2018 17:31
@moT01 :thumbsup: looks nice - quick question - are you rendering the entirety of your matched cities as one html element, or appending each individually?
@JLuboff thanks man I just sent a response, can you let me know if you got it?
CamperBot
@camperbot
Feb 06 2018 17:31
cmccormack sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2321 | @jluboff |http://www.freecodecamp.org/jluboff
Jason Luboff
@JLuboff
Feb 06 2018 17:31
@cmccormack I got it :+1:
Christopher McCormack
@cmccormack
Feb 06 2018 17:31
@JLuboff awesome works great! thanks again.
CamperBot
@camperbot
Feb 06 2018 17:31
cmccormack sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
api offline
Christopher McCormack
@cmccormack
Feb 06 2018 17:32
@JLuboff source?
Jason Luboff
@JLuboff
Feb 06 2018 17:32
Same code as whats rendered on load except for adding an index number to some of the id's
$(appendTo).append(`<div id="meetEventBody${meetEventIndex}">
      <div class="form-group">
        <label for="meetingDate" class="col-sm-2 control-label">Meeting Date</label>
        <div class="col-sm-6">
          <input class="form-control meetingDate" id="meetingDate${meetEventIndex}" name="meetingDate[]" required/>
        </div>
      </div>
      <div class="form-group">
        <label for="meetingTitle" class="col-sm-2 control-label">Meeting Title</label>
        <div class="col-sm-6">
          <input class="form-control" id="meetingTitle${meetEventIndex}" name="meetingTitle[]" required/>
        </div>
      </div>
      <div class="form-group">
        <label for="startTime" class="col-sm-2 control-label">Start Time</label>
        <div class="col-sm-6">
          <input class="form-control numOnly" id="startTime${meetEventIndex}" name="startTime[]" minlength="4" maxlength="5" required/>
        </div>
        <div class="col-sm-2">
          <select class="form-control" name="startTimePeriod[]" required/>
          <option value=""> </option>
          <option value="AM">AM</option>
          <option value="PM">PM</option>
        </select>
      </div>
    </div>
    <div class="form-group">
      <label for="endTime" class="col-sm-2 control-label">End Time </label>
      <div class="col-sm-6">
        <input class="form-control numOnly" id="endTime${meetEventIndex}" name="endTime[]" minlength="4" maxlength="5" required/>
      </div>
      <div class="col-sm-2">
        <select class="form-control" name="endTimePeriod[]" required/>
        <option value=""> </option>
        <option value="AM">AM</option>
        <option value="PM">PM</option>
      </select>
    </div>
  </div>
</div>`);
Not sure if its bootstrap or jquery that isn't playing nice
@moT01 Hey my city is in there, nifty
Tom
@moT01
Feb 06 2018 17:33
@cmccormack i create an element in js and put a div in the innerHtml
   getCities(value).forEach(result => {
      var div = document.createElement("div");
      div.classList.add('item');

      let regex = new RegExp(value, 'i');
      var city = result.city.replace(regex, '<span style="color: white">' + value + '</span>');
      var state = result.state.replace(regex, '<span style="color: white">' + value + '</span>');

      div.innerHTML = city + ', ' + state + '<div class="population">POPULATION : ' + result.population + '</div>';
      results.appendChild(div);

    });
Christopher McCormack
@cmccormack
Feb 06 2018 17:34
@moT01 I would recommend creating a virtual element, appending all results to that element, then appending that virtual element to the dom only after you have completed your loop
updating the DOM for every iteration will be slow
@JLuboff you're terminating the select early
@JLuboff <select class="form-control" name="endTimePeriod[]" required/>
Tom
@moT01
Feb 06 2018 17:36
@cmccormack noted
Christopher McCormack
@cmccormack
Feb 06 2018 17:36
I don't actually remember how dropdowns are configured but that may be part of your issue
Jason Luboff
@JLuboff
Feb 06 2018 17:37
@cmccormack Mmm... terminating early how?
Christopher McCormack
@cmccormack
Feb 06 2018 17:37
@JLuboff
<select ... required/>
after the d
Jason Luboff
@JLuboff
Feb 06 2018 17:39
@cmccormack Damn you. That is correct. Thanks. For some reason I though that that was a requirement for required
CamperBot
@camperbot
Feb 06 2018 17:39
jluboff sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1305 | @cmccormack |http://www.freecodecamp.org/cmccormack
Christopher McCormack
@cmccormack
Feb 06 2018 17:39
@JLuboff haha np
Jason Luboff
@JLuboff
Feb 06 2018 17:40
hmm.. why did I do that. Mind you I originally created this form over a year ago
Christopher McCormack
@cmccormack
Feb 06 2018 17:41
I feel like that answer is enough, older younger you wasn't as wise!
Jason Luboff
@JLuboff
Feb 06 2018 17:41
younger me*
:P
Tom
@moT01
Feb 06 2018 17:42
little buggy still - some regex characters break it - type a bunch of ..., how could i make it so it will only match value exactly
Christopher McCormack
@cmccormack
Feb 06 2018 17:42
although in some ways younger us was both smarter and dumber
@moT01 did you remove the global flag like @sjames1958gm suggested?
Tom
@moT01
Feb 06 2018 17:43
yes
Kaz Baig
@kbaig
Feb 06 2018 17:43
I def feel like I was smarter when I was a student
Jason Luboff
@JLuboff
Feb 06 2018 17:44
@kbaig You were
Kaz Baig
@kbaig
Feb 06 2018 17:45
Well that feels bad lmao
Jason Luboff
@JLuboff
Feb 06 2018 17:45
I'm just being a jerk :P
Christopher McCormack
@cmccormack
Feb 06 2018 17:46
@moT01 you're allowing the input to be a regex, you may need to filter the input first so it's only alpha or something
Kaz Baig
@kbaig
Feb 06 2018 17:46
I'm willing to bet it's just that academic environments are designed to make you feel more valued than the workplace is
Jason Luboff
@JLuboff
Feb 06 2018 17:46
ARgh!!! Why can't IE support fucking es6.
Christopher McCormack
@cmccormack
Feb 06 2018 17:46
@kbaig that and you actually have more time to focus on studies
working full time and wanting to learn everything is much more difficult
Kaz Baig
@kbaig
Feb 06 2018 17:47
Day in day out makes me feel slower
Christopher McCormack
@cmccormack
Feb 06 2018 17:48
@kbaig find yourself a sugar momma and study all day :p
Kaz Baig
@kbaig
Feb 06 2018 17:48
:P
Christopher McCormack
@cmccormack
Feb 06 2018 17:48
@JLuboff i hate IE when I actually want to use useful JS. You try using any polyfills?
Jason Luboff
@JLuboff
Feb 06 2018 17:49
@cmccormack No, I haven't. Worth it? or should I just stick to not using es6..?
Kaz Baig
@kbaig
Feb 06 2018 17:49
@JLuboff why not transpile to ES5
Christopher McCormack
@cmccormack
Feb 06 2018 17:50
@JLuboff up to what you need to support. I personally couldn't even get all the polyfills to work even after extensive research but maybe you'll have better luck
Jason Luboff
@JLuboff
Feb 06 2018 17:51
@kbaig Becuase I've never done it before lol
Christopher McCormack
@cmccormack
Feb 06 2018 17:51
babel has a bunch of polyfills if you're using it
Jason Luboff
@JLuboff
Feb 06 2018 17:51
I mean, it's not a big enough piece of code to really need to.. but at the same time it's annoying to not be able to use es6 becuase I need to have support for IE becuase so many individuals use it here at work
Kaz Baig
@kbaig
Feb 06 2018 17:52
@JLuboff is this a personal or work project?
Jason Luboff
@JLuboff
Feb 06 2018 17:53
Work project
Kaz Baig
@kbaig
Feb 06 2018 17:53
I wouldn't bother supporting everything for personal lol
makes sense
Jason Luboff
@JLuboff
Feb 06 2018 17:53
I don't support IE for personal stuff. Fuck that
Kaz Baig
@kbaig
Feb 06 2018 17:53
:clap:
Christopher McCormack
@cmccormack
Feb 06 2018 17:55
@JLuboff I thought that too, then my brother told me he wasn't able to use my pomodoro timer on his work laptop, and I think it's because he has to use IE and I'm probably using something it doesn't support :(
Jason Luboff
@JLuboff
Feb 06 2018 17:56
@cmccormack Ew. I put Chrome and Firefox on all new computers so users can use what they like
We don't really use group policy...so doesn't make a difference in that regard
Christopher McCormack
@cmccormack
Feb 06 2018 17:57
He works for a medical company, I guess they are pretty strict even if it's necessarily the right way to do it
https://hackernoon.com/polyfills-everything-you-ever-wanted-to-know-or-maybe-a-bit-less-7c8de164e423 this seems to be pretty good at explaining polyfills vs/with transpiling
Kaz Baig
@kbaig
Feb 06 2018 17:58
Isn't the TLDR that polyfill -> adding the feature you want to use, transpiling -> finding a workaround implementation for your unsupported feature at build time
Kaz Baig
@kbaig
Feb 06 2018 18:00
I too browse r/ProgrammerHumor
Jason Luboff
@JLuboff
Feb 06 2018 18:00
;)
Christopher McCormack
@cmccormack
Feb 06 2018 18:02

@kbaig from the Medium post:

A good general rule is this:

If it’s new syntax, you can probably transpile it
If it’s a new object or method, you can probably polyfill it
If it’s something clever that the browser does outside of your code, you’re probably SOL

Kaz Baig
@kbaig
Feb 06 2018 18:03
you’re probably SOL
same
Christopher McCormack
@cmccormack
Feb 06 2018 18:03
This was my experience, Promises required polyfills because transpiling wasn't cutting it
Jason Luboff
@JLuboff
Feb 06 2018 18:05
:( I can't use string literals. Fucking bullshit.
Christopher McCormack
@cmccormack
Feb 06 2018 18:05
@JLuboff you using babel? You can try using babel-plugin-transform-es2015-template-literals
Jason Luboff
@JLuboff
Feb 06 2018 18:06
@cmccormack No I'm not... I'm too lazy to figure that shit out lol
Christopher McCormack
@cmccormack
Feb 06 2018 18:07
@JLuboff the more you work with React the more you depend on something like webpack with babel to do all the build work behind the scenes. Means you can write the code you want and have your tools fill in the gaps
Jason Luboff
@JLuboff
Feb 06 2018 18:07
I still need to get into react...too much stuff to learn too little time
Christopher McCormack
@cmccormack
Feb 06 2018 18:07
But if you want you can run a build script that runs babel over your original code
You can use webpack/babel without react as well
it's a hell of a learning curve, but once you learn it you can use scss/jsx/babel/etc.. without having to think about it too much, which is nice
Jason Luboff
@JLuboff
Feb 06 2018 18:09
Sounds like it
...Jesus... I'm forgetting how to concatenate normally instead of using string literals lol
I got it i got it
Christopher McCormack
@cmccormack
Feb 06 2018 18:14
@JLuboff implement your own String.format!
if (!String.prototype.format) {
  String.prototype.format = function() {
    var args = arguments;
    return this.replace(/{(\d+)}/g, function(match, number) { 
      return typeof args[number] != 'undefined'
        ? args[number]
        : match
      ;
    });
  };
}
I don't think this is built in by default, although I wish it were. Coming from a minor python background it would have been nice to have
Jason Luboff
@JLuboff
Feb 06 2018 18:15
Whats that doing?
Christopher McCormack
@cmccormack
Feb 06 2018 18:15
after you implement you can use curly braces like this:
> '{1} {0}'.format('World', 'Hello, ')
'Hello,  World'
I HATE concatenating strings with the + operator so I use workarounds like this when I can
Sweet Coding :)
@SweetCodingInc
Feb 06 2018 18:17
@cmccormack That's a syntax I saw for the first time! :+1:
pretty neat util, I must say
Christopher McCormack
@cmccormack
Feb 06 2018 18:17
I think several programming languages use something very similar
Jason Luboff
@JLuboff
Feb 06 2018 18:17
@cmccormack Ah, works like C#
Christopher McCormack
@cmccormack
Feb 06 2018 18:18
no clue why JS doesn't have it, and template literals are not the same
Sweet Coding :)
@SweetCodingInc
Feb 06 2018 18:18
I'm familiar with c, printf("%d + %d = %d", a, b, a+b);
but this indexed this seems nice
Christopher McCormack
@cmccormack
Feb 06 2018 18:20
@SweetCodingInc Python has both styles, the C-like implementation being the old, the curly braced style being the new. I'm more fond of the new but they both have their benefits
Sweet Coding :)
@SweetCodingInc
Feb 06 2018 18:20
@cmccormack :+1:
Christopher McCormack
@cmccormack
Feb 06 2018 18:21
I kind of wish they would simplify it though, maybe a printf('string {0}', arg0)
I mean, how often do you print a string that doesn't have a variable in it?
Sweet Coding :)
@SweetCodingInc
Feb 06 2018 18:22
rarely
good point..
have you ever considered publishing this as a polyfill?
Christopher McCormack
@cmccormack
Feb 06 2018 18:22
maybe I'll make a pull request to the python source :)
Sweet Coding :)
@SweetCodingInc
Feb 06 2018 18:22
that .format function
Christopher McCormack
@cmccormack
Feb 06 2018 18:23
well it's not my code originally but it would be cool if it was available easily
Sweet Coding :)
@SweetCodingInc
Feb 06 2018 18:23
@cmccormack if accepted, that would cause your resume to go super saiyan
Christopher McCormack
@cmccormack
Feb 06 2018 18:23
maybe i'll look into how that all works :D
Sweet Coding :)
@SweetCodingInc
Feb 06 2018 18:24
@cmccormack :+1:
Jason Luboff
@JLuboff
Feb 06 2018 18:26
Holy hell. I now remember why I love string literals so much. I missed several + and had to lookup how to break line lol
Christopher McCormack
@cmccormack
Feb 06 2018 18:26
is it \?
Jason Luboff
@JLuboff
Feb 06 2018 18:29
Ya
And then Math order of operations get me...becuase of stupid concatenation
Christopher McCormack
@cmccormack
Feb 06 2018 18:32
I wonder how you could even convert template literals using a polyfill... might not be possible without transpiling
Sweet Coding :)
@SweetCodingInc
Feb 06 2018 18:33
@cmccormack you'll need to transpile, definitely
Christopher McCormack
@cmccormack
Feb 06 2018 18:35
I tried looking through babel's transform code and now I'm even more confused :D
Sweet Coding :)
@SweetCodingInc
Feb 06 2018 18:35
:laughing:
Jason Luboff
@JLuboff
Feb 06 2018 19:44
@cmccormack If you ever need Windows passthrough authentication with node.. I'm playing with node-sspi and thus far...works..
Christopher McCormack
@cmccormack
Feb 06 2018 19:44
I hope I never do :)
but thanks
single-signon... passport interface?
Jason Luboff
@JLuboff
Feb 06 2018 19:45
Not single-signon (single sign-on wouldn't present a login window, right?). Presents a standard login popup window
Christopher McCormack
@cmccormack
Feb 06 2018 19:47
haha no idea
so it basically allows you to auth with a local user account? That's pretty cool
Jason Luboff
@JLuboff
Feb 06 2018 19:47
Yup
Going to use AD groups to handle permissions for this web app I'm making
Christopher McCormack
@cmccormack
Feb 06 2018 19:50
Sounds like a smart way to do it
Jason Luboff
@JLuboff
Feb 06 2018 19:50
Seems to store the connection info too.. hmm. I can restart the server and I stay logged in
Christopher McCormack
@cmccormack
Feb 06 2018 19:50
probably has express-session built in or something similar
Jason Luboff
@JLuboff
Feb 06 2018 19:51
Ya..wierd. I'll have to deep dive to understand
Apparently it is to Node what mod-auth-sspi is to Apache HTTPD
Christopher McCormack
@cmccormack
Feb 06 2018 19:53
I'll have to hit you up if I ever need to do AD based auth
Jason Luboff
@JLuboff
Feb 06 2018 19:55
:+1:
Hmmm...apparently there is a Passport strategy as well. But may have to go through IIS which I'd prefer not to do..
Mr. Frosty
@BinaryKing
Feb 06 2018 19:58
Hello
Jason Luboff
@JLuboff
Feb 06 2018 19:59
@BinaryKing Yo
Christopher McCormack
@cmccormack
Feb 06 2018 20:01
Would you have to be using IIS as a web server or just setup some kind of auth with it
Jason Luboff
@JLuboff
Feb 06 2018 20:02
@cmccormack I guess there are a couple ways. I'd have to play around with it. https://github.com/auth0/passport-windowsauth#readme I'd think I would want to use the IIS w/LDAP method (thus I would present a login screen).
I like that it gives a lot more info, but not sure it gives the groups (that might be the objectClass in the example though..?)
Christopher McCormack
@cmccormack
Feb 06 2018 20:04
no clue - do you already have ldap setup in your environment?
Jason Luboff
@JLuboff
Feb 06 2018 20:11
mmm..good question
Jason Luboff
@JLuboff
Feb 06 2018 21:59
@cmccormack Just checked... ldap is running but not over ssl
Tiago Correia
@tiagocorreiaalmeida
Feb 06 2018 23:26
hey!
Jason Luboff
@JLuboff
Feb 06 2018 23:26
Hi
Tiago Correia
@tiagocorreiaalmeida
Feb 06 2018 23:26
how's life?:
:D
Jason Luboff
@JLuboff
Feb 06 2018 23:27
Not too bad..you
Tiago Correia
@tiagocorreiaalmeida
Feb 06 2018 23:27
all according to the normal I would say
Jason Luboff
@JLuboff
Feb 06 2018 23:28
Having a hell of a time trying to get any sort of LDAP passport strategy to work though. Fucking hell
Tiago Correia
@tiagocorreiaalmeida
Feb 06 2018 23:29
would love to help but I dont think I would be any big of a help :D and I guess you are allready going for https://www.npmjs.com/package/passport-ldapauth right?
Jason Luboff
@JLuboff
Feb 06 2018 23:29
Thats the current one I'm trying. I had tried passort-windowsauth prior. Not might be trying ldapauth-fork