These are chat archives for FreeCodeCamp/HelpJavaScript

16th
May 2018
Tony Stark
@KingOfUniverse
May 16 2018 05:26
Hi there
Dhaval Vira
@dhavalveera
May 16 2018 05:26
hi
Rohit Yadav
@rohyadav
May 16 2018 07:57
Hi anyone help me out :- i want some texts from an html page that how many time occurs text and get that all the text
is there anything can do ?
Dhaval Vira
@dhavalveera
May 16 2018 07:58
Plz clarify the issur
Rohit Yadav
@rohyadav
May 16 2018 08:03
ok,
so here is the scenario we have lots of single page html templates and we need to change some text and so we need some kind of script that will run on console and we can get all the texts occurence and hightlight text some color so we can know in which places is comming
@dhavalveera
you get it now
Francois Beyers
@Blusoup
May 16 2018 08:10
I need to set local/session storage if the customer clicked on the megaMenu. This needs to be false by default and then set to true on the next page if the customer clicked on a menu button. Any help would be appreciated. The following is what I have so far, but I'm stuck on how to get megaClicked = true. And how to read it on the next page. I used to use cookies for this, but I feel that local/session storage would be better.
var megaClicked = { value: false };
var megaMenu = $("#menu-top-navigation > div");
// check local storage on page load
if (localStorage.getItem('mega')) {
    megaClicked = JSON.parse(localStorage.getItem('mega'))
}

megaMenu.bind('click', function () {
    megaClicked.value = true;
    localStorage.setItem('mega', JSON.stringify(megaClicked));
})
Rohit Yadav
@rohyadav
May 16 2018 08:11
anyone help me
Marianissimus
@Marianissimus
May 16 2018 08:11
@rohyadav You basically seem to need a textContent, like document.querySelector('body').textContent
Question is - if you can properly select the element
Rohit Yadav
@rohyadav
May 16 2018 08:11
@Marianissimus
var array = ["lipsum", "continum", "okie"];

var str1 = document.body.innerHTML;
for(var i=0;i< array.length;i++){
var check= str1.search(array[i]);
    if(check > -1){
        var search = array[i].toLowerCase();
        var replacement = '<strong  style="color:red; font-weight: bold;">'+array[i]+ '</strong>';
var content = document.body.innerHTML.toLowerCase();
        document.body.innerHTML =content.split(search).join(replacement);
    }
}
Marianissimus
@Marianissimus
May 16 2018 08:11
Meaning - different pages will have different containers; you need to select the most specific elements that gets your content
Rohit Yadav
@rohyadav
May 16 2018 08:12
i tried this get the highlight text but i need count as well
can you check is this ok
aur need to modifiy
Marianissimus
@Marianissimus
May 16 2018 08:12
Wait, i didn't understand the problem too well
You need to find out how many times a string inside the text repeats?
do you have some predefined values? like that array you have there?
Marianissimus
@Marianissimus
May 16 2018 08:18
OK, first: document.body.innerHTML gets you all the HTML inside the page; that is way too much, it will get you the scripts, the formatting, everything
You need to be more specific;
Rohit Yadav
@rohyadav
May 16 2018 08:22
ok let me explain
Marianissimus
@Marianissimus
May 16 2018 08:22
You say you have some page templates; thus, the content must probably be in some tags / classes / id-s that you can use for a better selection. Maybe you should make a pen and work on it
Rohit Yadav
@rohyadav
May 16 2018 08:34
ok so mine problem is the when i have some array like this
var array = [ "DS API", "DS bid strategies","Sales Management", "Ad Exchange line item", "AdX line item", "Ad Exchange inventory", "Open auction", "API"];
so the issue is when we have support on 0th position "DS API" and suppose in the last have "API" only when we run the script that time got the highlighted text complete DS API but got one case for now when we add "API" in the 0th position like below array
var array = [ "API", "DS API", "DS bid strategies","Sales Management", "Ad Exchange line item", "AdX line item", "Ad Exchange inventory", "Open auction"];
it only highlight color in API only means that if sentence have two words like mentioned in the DS API so it is only highlight API it completely ignoring DS
...
So, It should be highlight complete string as mentioned in the array no matter if we change the order in the array
@Marianissimus
Marianissimus
@Marianissimus
May 16 2018 08:38
I'm sorry, I don't really understand it:(
Rohit Yadav
@rohyadav
May 16 2018 08:39
ok i am sharing the screenshots with complete explanation
thanks for quick response
Marat
@Marat89bluolyu
May 16 2018 08:49
This message was deleted
This message was deleted
Dhaval Vira
@dhavalveera
May 16 2018 08:50
what T ?
Marat
@Marat89bluolyu
May 16 2018 08:51
How to correctly merge 2 objects with spread? const json = await fetch(url, { credentials: "include", headers: { Accept: "application/json", Authorization: jwtToken ? `bearer ${jwtToken}` : "" }, ...options })
Dhaval Vira
@dhavalveera
May 16 2018 08:53
what
Marat
@Marat89bluolyu
May 16 2018 08:54
and postImage: async (path: string, body: Object): Promise<any> => { return request(path, { method: "post", body: body, headers: { "Content-Type": "multipart/form-data" } }); }
I need merge headers in 2 objects
Daniel Simeonov
@dbsimeonov
May 16 2018 08:58

Guys is there anyone who can spend couple of minutes help me with something that I've struggled more than a week..
I have an array with elements inside, and each element has data-attribute, I need to sort them for ex in alphabetical order and apply that order to the elements with some styling..

I've done the code with else/if statements but I need to convert it to for loop and tried to do it many times, just the logic or I'm missing something.. Code is quite a lot so prefer to send it on private..

The problem with my code is that if I add new item, I need to add it to my function as well

Marat
@Marat89bluolyu
May 16 2018 09:00
postImage call function where I have fetch and I need merge two headers(in postImage and request func), how can I do it?
Claudio Restifo
@Marmiz
May 16 2018 09:20
@dbsimeonov So you have some data, and you need to create matkup based on the data.
const myData = ['zebra', 'wombat', 'apple',  'banana'];
myData.sort( //sort aplphabetically);

myData.forEach((el, index) => {
  // here I can create Markup since I am calling this function for every entry:
  // like for example a random innerHTML
  document.getElementById('container').innerHTML = `<span class="element${index}">${el}</span>`
});
hoping that you don't have compatibility issues with template literals, arrow functions and such
Claudio Restifo
@Marmiz
May 16 2018 09:27
hope it make sense
Francois Beyers
@Blusoup
May 16 2018 09:46
I need to set local/session storage if the customer clicked on the megaMenu. This needs to be false by default and then set to true on the next page if the customer clicked on a menu button. Any help would be appreciated. The following is what I have so far, but I'm stuck on how to get megaClicked = true. And how to read it on the next page. I used to use cookies for this, but I feel that local/session storage would be better.
var megaClicked = { value: false };
var megaMenu = $("#menu-top-navigation > div");
// check local storage on page load
if (localStorage.getItem('mega')) {
    megaClicked = JSON.parse(localStorage.getItem('mega'))
}

megaMenu.bind('click', function () {
    megaClicked.value = true;
    localStorage.setItem('mega', JSON.stringify(megaClicked));
})
Stephen James
@sjames1958gm
May 16 2018 09:52
@Blusoup megaClicked is an object, so only megaClick.value would be true.
if you really want the variable to just be true/false
megaClicked = JSON.parse(localStorage.getItem('mega')).value
    megaClicked = true;
    localStorage.setItem('mega', JSON.stringify({value: megaClicked}));
Francois Beyers
@Blusoup
May 16 2018 09:58
@sjames1958gm do I put the second part in the "click" function then?
Stephen James
@sjames1958gm
May 16 2018 09:59
@Blusoup Yes, those lines basically replace the similar lines in your code.
Francois Beyers
@Blusoup
May 16 2018 09:59
@sjames1958gm Oh I see, thank you
CamperBot
@camperbot
May 16 2018 09:59
blusoup sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9243 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
May 16 2018 09:59
Changing the first line to var megaClicked = false as well
Francois Beyers
@Blusoup
May 16 2018 09:59
I will try it out
Stephen James
@sjames1958gm
May 16 2018 10:00
:+1:
Francois Beyers
@Blusoup
May 16 2018 10:00
appreciate the help
Stephen James
@sjames1958gm
May 16 2018 10:00
Only "objectize" the information in/out of local storage
Francois Beyers
@Blusoup
May 16 2018 10:00
was really stuck on this
Stephen James
@sjames1958gm
May 16 2018 10:00
@Blusoup Hope that helps
Francois Beyers
@Blusoup
May 16 2018 10:18
@sjames1958gm works like charm thanks again 👍🏼
CamperBot
@camperbot
May 16 2018 10:18
blusoup sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
api offline
Stephen James
@sjames1958gm
May 16 2018 10:18
@Blusoup :)
Tiago Correia
@tiagocorreiaalmeida
May 16 2018 10:34
hello everyonr
Dhaval Vira
@dhavalveera
May 16 2018 10:34
hello
Tiago Correia
@tiagocorreiaalmeida
May 16 2018 10:34
does anyone has an example of auth using jwt ?
Danny Chan
@chandanny
May 16 2018 11:33
@cmccormack @NJM8 thank you so much. i want to develop a real web app rather than host on github. the plan is hosting on digital ocean, buying domain name on namecheap, getting ssl from cloudflare
CamperBot
@camperbot
May 16 2018 11:33
chandanny sends brownie points to @cmccormack and @njm8 :sparkles: :thumbsup: :sparkles:
:cookie: 438 | @njm8 |http://www.freecodecamp.org/njm8
:star2: 1453 | @cmccormack |http://www.freecodecamp.org/cmccormack
Nate Mallison
@NJM8
May 16 2018 11:39
@chandanny Good plan, check out Heroku too, I haven't used digital ocean but Heroku is super simple and great to work with.
Daniel Simeonov
@dbsimeonov
May 16 2018 12:51
Guys that might be dumb question but couldn't find the answer..
If I'm sorting a < b and when they are strings, should I make sure that they are all with the same length because I have some results that are not exactly in alphabetical order?
Aditya
@ezioda004
May 16 2018 13:13
@dbsimeonov Could you give an example?
Length doesnt matter to an extent, comparison operators (<, >) check the characters one by one. If the both strings characters (ASCII value) is same, it moves and checks the next characters.
"b" > "abcdef" //true because b > a
"a" > "Z" //true lowercase comes after uppercase
"abcd" > "ac" // false the first characters are checked, since they are same the comparison happens between "b"  and "c"
Daniel Simeonov
@dbsimeonov
May 16 2018 13:15
image.png
For some reason the result I'm having is the one from the picture where I used
const sortedProducts = products.sort((a, b) => a.name < b.name);
Aditya
@ezioda004
May 16 2018 13:20
Can you copy and paste the array?
weifo
@weifo
May 16 2018 13:24
image.png
Anyone knows how to design this with css?
Danny Chan
@chandanny
May 16 2018 14:03
@NJM8 digital ocean is more affordable and i would learn more backend skill if i use it
@NJM8 thank you for your suggestion
CamperBot
@camperbot
May 16 2018 14:04
chandanny sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
:cookie: 439 | @njm8 |http://www.freecodecamp.org/njm8
Rohit Yadav
@rohyadav
May 16 2018 14:39
@Marianissimus you there?
hello
Dhaval Vira
@dhavalveera
May 16 2018 14:39
Hello
Rohit Yadav
@rohyadav
May 16 2018 14:40
can anyone help me out about some text finding on the page so i write some code but have some issue
Dhaval Vira
@dhavalveera
May 16 2018 14:40
What exactly it is
Rohit Yadav
@rohyadav
May 16 2018 14:41
ok let me explain
So the secnario is i have one page on that page i want to find occurence of the text and also exactly match the item and hightligh some color so wrote js code but not efficient have some issue i am sharing the screenshots
1.png
Rohit Yadav
@rohyadav
May 16 2018 14:46
So in this image i used
var array = ["DS API", "Adwords Ads", "DS bid strategies","Sales Management", "Google Adwords", "Ad Exchange line item", "AdX line item", "Ad Exchange inventory", "Open auction", "AdWords", "Ads", "Google", "API"];

var str1 = document.body.innerHTML;
for(var i=0;i< array.length;i++){
var check= str1.search(array[i]);
    if(check > -1){
        var search = array[i].toLowerCase();
        var replacement = '<strong  style="color:red; font-weight: bold;">'+array[i]+ '</strong>';
var content = document.body.innerHTML.toLowerCase();
        document.body.innerHTML =content.split(search).join(replacement);
    }
}
this code
on the console
but not matching the content exactly in the mentioned in the array
and if i switch the content position like last 4 items i put it in starting position of the array then result different
means if we have string google adwords then only find google because that is in fist place of that string postion
see in the below example
2.png
this time i just changed elements positions of the array
var array = ["AdWords", "Ads", "Google", "API", "DS API", "Adwords Ads", "DS bid strategies","Sales Management", "Google Adwords", "Ad Exchange line item", "AdX line item", "Ad Exchange inventory", "Open auction"];
Rohit Yadav
@rohyadav
May 16 2018 14:52
@dhavalveera
you there?
anyone
:(
Dhaval Vira
@dhavalveera
May 16 2018 14:53
I am not familiar with JavaScript
Sorry for Trouble
Rohit Yadav
@rohyadav
May 16 2018 14:53
ok, thanks brother
Dhaval Vira
@dhavalveera
May 16 2018 14:54
Your Welckme
Where are you from rohit
Rohit Yadav
@rohyadav
May 16 2018 14:55
@dhavalveera delhi
Dhaval Vira
@dhavalveera
May 16 2018 14:56
Ok
Moisés Man
@moigithub
May 16 2018 15:32
mdn.io/string.replace
mdn.io/regexp
and some kind of loop might help
Jason Luboff
@JLuboff
May 16 2018 15:33
Just to make sure I'm understanding const correctly (I'm switching every where I used let to const if I'm not reassigning the variable), a const can not be reassigned but we can manipulate the data within.
For example..
const arr = [1 , 3 , 5];

arr = arr.reduce((a, b) => a +b); //This is NOT allowed

arr.forEach(e => e+5); //This IS allowed
Rohit Yadav
@rohyadav
May 16 2018 15:34
@JLuboff
can you help me out
some js code issue
of mine
Jason Luboff
@JLuboff
May 16 2018 15:34
@rohyadav If its the above, looks like @moigithub is making some suggestions'
Moisés Man
@moigithub
May 16 2018 15:36
var array = ["DS API", "Adwords Ads", "API"];

var str1 = document.body.innerHTML;
const format = (word)=>  return "<strong  style='color:red; font-weight: bold;'>"+ word + "</strong>;"

array.forEach(toChange =>{
     str1= str1.replace(new regexp(toChange,"gi", format(toChange))
});
document.body.innerHTML = str1;
@moigithub syntax error
can you check on this url and put this code on the console
Moisés Man
@moigithub
May 16 2018 15:39
maybe in the arrow function ?
Rohit Yadav
@rohyadav
May 16 2018 15:39
i think
Jason Luboff
@JLuboff
May 16 2018 15:40
@moigithub Can you confirm what I wrote about const above? Just want to make sure I'm not misunderstanding it
Rohit Yadav
@rohyadav
May 16 2018 15:43
3.png
Moisés Man
@moigithub
May 16 2018 15:43
yep.. with const u cant reassign values to the variable, but with arrays and objects since those are non primitive u can mutate its content @JLuboff but not reassign
Jason Luboff
@JLuboff
May 16 2018 15:43
@moigithub :+1: Thanks
CamperBot
@camperbot
May 16 2018 15:43
jluboff sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3754 | @moigithub |http://www.freecodecamp.org/moigithub
Rohit Yadav
@rohyadav
May 16 2018 15:50
4.png
@moigithub but i need to run on the console
Moisés Man
@moigithub
May 16 2018 15:52
check code on codepen.. its working OK there..
Rohit Yadav
@rohyadav
May 16 2018 15:52
anyhow
Moisés Man
@moigithub
May 16 2018 15:54
and ??...
..just copy paste
Rohit Yadav
@rohyadav
May 16 2018 15:54
yes i did that but got the error
see the sceenshot
i just shared above
Nate Mallison
@NJM8
May 16 2018 15:56
@rohyadav new RegExp(...
it's capitalized
also check your parenthesis
Rohit Yadav
@rohyadav
May 16 2018 15:58
and another thing is also want occurrence count of the highlighted text
@NJM8 thanks its working .. :)
CamperBot
@camperbot
May 16 2018 15:58
rohyadav sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
:cookie: 441 | @njm8 |http://www.freecodecamp.org/njm8
Rohit Yadav
@rohyadav
May 16 2018 15:59
how do i get the count of highlighted text
Nate Mallison
@NJM8
May 16 2018 16:01
Do you mean successful replacements? isn't that just the length of the array?
Rohit Yadav
@rohyadav
May 16 2018 16:01
yes
succesfull items replacment lenght
and what is happening here, i did not understand this
str1.replace(new RegExp(toChange,"gi"), format2(toChange))
Nate Mallison
@NJM8
May 16 2018 16:06
replace takes two arguments, something to replace, and what to replace it with
using new RegExp(toChange, 'gi')
Rohit Yadav
@rohyadav
May 16 2018 16:07
ok so the "gi" is dummy content or ?
gi means
sorry i am not that good in JavaScript but i am learning
Nate Mallison
@NJM8
May 16 2018 16:09
takes the string toChange and turns it into a regexp, or regular expression, it's a way to match patterns, g is global, i is case insensitive, so in otherwords, search the whole string str1 for whatever string is held in toChange regardless of case or where is it, format(toChange) calls the format function and wraps that new next in the html and css to turn it red.
Rohit Yadav
@rohyadav
May 16 2018 16:10
ohho.. thats awesome
thank you so much for nice explanation
:)
thanks :)
Nate Mallison
@NJM8
May 16 2018 16:11
let str = 'hi how are you';
str = str.replace( new RegExp(/h/, 'gi'), '5');
console.log(str) // 5i 5ow are you
your welcome
Rohit Yadav
@rohyadav
May 16 2018 16:11
ok ,
thanks
Nate Mallison
@NJM8
May 16 2018 16:12
if you are new to programming in general I'd wait to dive into RegExp too much. it's very complex
Rohit Yadav
@rohyadav
May 16 2018 16:12
and what about if i want the count of the highlighted text
Nate Mallison
@NJM8
May 16 2018 16:12
but very powerful
Rohit Yadav
@rohyadav
May 16 2018 16:12
yes, i can see ..even in this example
Nate Mallison
@NJM8
May 16 2018 16:13
hmmm, that is going to be a little harder, if you know that all the text in the array will get replaced, then it's just array.length, since you will replace all those items, then you know it will do that.
if you aren't sure if you are going to find all the text in the array,
then you need to store the str.... oh no I got it
Christopher McCormack
@cmccormack
May 16 2018 16:16
:wave:
Rohit Yadav
@rohyadav
May 16 2018 16:16
yes, because in my case have lots of html code if i got the count that will help me note the in which page how many occurrence we get
Nate Mallison
@NJM8
May 16 2018 16:17
you can query the html for all the strong elements, and if there maybe other strong elements on the page you can set a custom class on your strong element in the format function, then query all those elements and get the length
so in the format function, add class="madeRed" to the <strong> element
Rohit Yadav
@rohyadav
May 16 2018 16:18
what if already strong elements on that page
can you please implement this i did not getting
Nate Mallison
@NJM8
May 16 2018 16:18
then after the .forEach do :
let strongElements = document.querySelectorAll('.madeRed');
let count = strongElements.length;
Rohit Yadav
@rohyadav
May 16 2018 16:18
that will be really help for me
Nate Mallison
@NJM8
May 16 2018 16:21
can you post the code you are using now?
Jason Luboff
@JLuboff
May 16 2018 16:22
@cmccormack Yo
Rohit Yadav
@rohyadav
May 16 2018 16:23
@NJM8 its coming 13
count
but should be 8
@NJM8
var array = ["Adwords Ads", "DS bid strategies","Sales Management", "Google Adwords", "Google", "Ad Exchange line item", "AdX line item", "Ad Exchange inventory", "Open auction", "AdWords", "Ads",  "DS API", "API"];

var str1 = document.body.innerHTML;

var format2 =(word)=>'<strong class="madeRed" style="color:red; font-weight: bold;">'+ word + '</strong>';

var strongElements = document.querySelectorAll('.madeRed');
var count = strongElements.length;
console.log(count)

array.forEach(function(toChange){
     str1= str1.replace(new RegExp(toChange,"gi"), format2(toChange))
});

document.body.innerHTML = str1;
Christopher McCormack
@cmccormack
May 16 2018 16:26
@rohyadav log the output of strongElements and see what it looks like, maybe you need to make it more specific
Kudzu
@czhower
May 16 2018 16:27
@rohyadav avoid var in favor of let unless you are in a very old ES
Rohit Yadav
@rohyadav
May 16 2018 16:27
5.png
Rohit Yadav
@rohyadav
May 16 2018 16:29
@czhower yes, i will update later , thanks
CamperBot
@camperbot
May 16 2018 16:29
rohyadav sends brownie points to @czhower :sparkles: :thumbsup: :sparkles:
:cookie: 105 | @czhower |http://www.freecodecamp.org/czhower
Rohit Yadav
@rohyadav
May 16 2018 16:29
@NJM8
Jason Luboff
@JLuboff
May 16 2018 16:29
@czhower And we should be using const in favor of let unless the variable is being reassigned at any point (hence my going through my current project and changing majority of my lets to consts
Christopher McCormack
@cmccormack
May 16 2018 16:30
@JLuboff yay const
Rohit Yadav
@rohyadav
May 16 2018 16:30
@cmccormack any idea
Nate Mallison
@NJM8
May 16 2018 16:30
@rohyadav strongElements may have some extra stuff as it's a node list technically, try
var count = Array.arrayFrom(strongElements).length;
Jason Luboff
@JLuboff
May 16 2018 16:31
@cmccormack :+1:
Nate Mallison
@NJM8
May 16 2018 16:31
also console.log(strongElements) to see what it is
Christopher McCormack
@cmccormack
May 16 2018 16:31
I'm confused how it's showing anything if he's not adding the class until below
@JLuboff I will spend an hour completely refactoring a block of code just to avoid using let and instead use const :) in the end the code is better and less prone to side effects though
Kudzu
@czhower
May 16 2018 16:33
@JLuboff I always use const as a matter of safety, but in JS it has less effect than in other langs so the usefulness of it is less, but still there.
Rohit Yadav
@rohyadav
May 16 2018 16:33
6.png
@NJM8
Christopher McCormack
@cmccormack
May 16 2018 16:34
it should be Array.from(
Nate Mallison
@NJM8
May 16 2018 16:34
opps, sorry should be Array.from
Rohit Yadav
@rohyadav
May 16 2018 16:37
7.png
this is not working everytime i am running the scripting its adding the count
13+12
23 next time is going to 33
Christopher McCormack
@cmccormack
May 16 2018 16:39
why are you running it in the console
there's your problem
if you need to run from console for whatever reason, copy your script and reload the page between attempts
Rohit Yadav
@rohyadav
May 16 2018 16:40
because i need to run at anyhow to find
existing pages
how can i do that @cmccormack
Christopher McCormack
@cmccormack
May 16 2018 16:41
Which part?
reload the page?
Rohit Yadav
@rohyadav
May 16 2018 16:41
see the script in the above screenshot
i just shared
Jason Luboff
@JLuboff
May 16 2018 16:42
@cmccormack I didn't have to refactor, just find and replace hah! Only have 9 uses of let (which will go down further, haven't finished refactoring some code) and currently 89 const (this is my routes file)
Christopher McCormack
@cmccormack
May 16 2018 16:43
But who's counting :)
@rohyadav you asked how can I do that?. What is it you are asking about?
Rohit Yadav
@rohyadav
May 16 2018 16:45
you suggest me copy your script and reload the page between attempts
between attempts
means i need to run the script in the console because we have 400 pages already live
@NJM8 you there?
Jason Luboff
@JLuboff
May 16 2018 16:48
@cmccormack Good ol' Find and Replace is counting!
Kudzu
@czhower
May 16 2018 16:49
not sure if/which linter you use, but the linters will tell you where you have a let that can be a const.
Jason Luboff
@JLuboff
May 16 2018 16:50
@czhower Oh, thats good to know. I'm using Atom has my editor, haven't really found a linter that works for me (I think I've only tried 2 or 3).
Christopher McCormack
@cmccormack
May 16 2018 16:51
I use eslint with "eslint:recommended", "plugin:react/recommended" and I"m not sure I've ever seen it call out let but I also rarely use let
Kudzu
@czhower
May 16 2018 16:53
@JLuboff with JS a linter is a MUST. I use tslint but Im doing mostly TS. try eslint.... It suck that a lang has a lint as a near requirement, but thats JS and since its not compiled and lazy interpreted without any validation, a linter is a MUST
it might be an option you have to set. I know tslint catches them.
Using JS without a linter is like driving a car without ABS, airbags, or for that matter brakes. :)
Jason Luboff
@JLuboff
May 16 2018 16:55
Installing eslint now
Kudzu
@czhower
May 16 2018 16:55
Make it part of your build/run process so it runs every time.
Christopher McCormack
@cmccormack
May 16 2018 16:56
I love it - I can use single quotes/double quotes/forget dangling comma, and eslint fixes it for me :)
Kudzu
@czhower
May 16 2018 16:58
yup. It definitely makes JS more usable.
Christopher McCormack
@cmccormack
May 16 2018 16:59
@JLuboff you may need to add a setting for eslint to fix on save if you're interested in that
in vs code it's "eslint.autoFixOnSave": true not sure about atom though, probably similar
Brad
@bradtaniguchi
May 16 2018 17:19
I once didn't use a linter... at least 15 hours over the course of a few months would have been saved by it ;D
Jason Luboff
@JLuboff
May 16 2018 17:19
Ya looks like I need a file of some sort
Kudzu
@czhower
May 16 2018 17:20
@cmccormack Far more on a large project
15 hours in a week easily
Brad
@bradtaniguchi
May 16 2018 17:21
Hey now I wasn't bad enough to screw up that much :P
Kudzu
@czhower
May 16 2018 17:24
Wait till your code grows.. I cant speak for you, but most JS devs think 20,000 lines of code is "huge"
Brad
@bradtaniguchi
May 16 2018 17:35
I recently migrated to hooking prettier to perform on save, and pre-commit, code looks "nicer" now hehe.
Kudzu
@czhower
May 16 2018 17:42
In VS Code, ctrl-alt-f will format current code window.
At least for TS, I assume it does same for other langs using their language extension.
Brad
@bradtaniguchi
May 16 2018 17:46
Doesn't work for me, my OS opens a file-explorer window
Kudzu
@czhower
May 16 2018 17:51
Might be my keymappings.... Im sure something similar exists for raw JS.
Christopher McCormack
@cmccormack
May 16 2018 17:52
Alt+Shift+F in VS Code windows
Kudzu
@czhower
May 16 2018 17:52
blob
Aah yes..sorry my bad.... I dont look at the keys.. its in my muscle memory.
Christopher McCormack
@cmccormack
May 16 2018 17:53
Prettier is interesting. Something about opinionated formatting that I like, but I couldn't get it to work so I skipped it :)
Jason Luboff
@JLuboff
May 16 2018 17:53
Should eslint be installed per project or globally? I'm thinking globally..
Christopher McCormack
@cmccormack
May 16 2018 17:53
@JLuboff both
you can have eslint per project and globally
Jason Luboff
@JLuboff
May 16 2018 17:54
I've used both prettier and beautify...think prettier is a little better
Well I know it can be both but which is prefered
Christopher McCormack
@cmccormack
May 16 2018 17:54
I've found using global isn't that great though
so for my projects I install it as a dev dependency and keep my configs in an .eslintrc.js file
but if you install globally it's easier to just use it if you want, like eslint server.js --fix or whatever
instead of ./node_modules/.bin/eslint server.js --fix
of course you can create a script as well
But you'll want (need?) the plugin for the editor as well
I've never been 100% sure about how the editor eslint and node eslint work together
Jason Luboff
@JLuboff
May 16 2018 17:56
Ok ya, I've installed linter-eslint for Atom but I'll have to also install eslint
Its kind of confusing
Christopher McCormack
@cmccormack
May 16 2018 17:56
I imagine the editor just uses the eslintrc file to actually syntax highlight
Henry
@GitHub-Henry
May 16 2018 17:56
I did something like Brad with VSCode, I have eslint format and lint my js, and prettier formats all the rest. So nice not to think about making code look pretty.
Christopher McCormack
@cmccormack
May 16 2018 17:56
That's how it is for every linter I've ever used
Python too
@GitHub-Henry Brad?
Henry
@GitHub-Henry
May 16 2018 17:59
@bradtaniguchi
Jason Luboff
@JLuboff
May 16 2018 17:59
@bradtaniguchi is Brad
Brad
@bradtaniguchi
May 16 2018 18:00
Hu :eyes:
Henry
@GitHub-Henry
May 16 2018 18:00
really seems to save time when formatting is not an issue
Brad
@bradtaniguchi
May 16 2018 18:01
I do find myself getting very lazy tho, just typing out garbage to a point it "compiles" then hit save for the formatting and compile. But my code kinda looks like this when im writing it out:
if (something) {arr.forEach((item) => {return doSomThing(item)})}
but it gets fixed on save so Im like whatever XD
Christopher McCormack
@cmccormack
May 16 2018 18:02
haha
I thought Brad might be similar to Prettier but google just gave me Brad Pitt results
Keon Samuel
@keonsam
May 16 2018 18:11
Who knows Java and want to work on a project?
Jason Luboff
@JLuboff
May 16 2018 18:18
erg...my eslint acts like it can't see eslint-config-google (I'm lazy and using googles style guide). I think it's becuase I installed eslint globally instead of local..
Christopher McCormack
@cmccormack
May 16 2018 18:21
@JLuboff followed this guy? https://atom.io/packages/linter-eslint
Jason Luboff
@JLuboff
May 16 2018 18:22
@cmccormack Ya but think I buggered things up. Going to start over (uninstall and reinstall)
Henry
@GitHub-Henry
May 16 2018 18:24
I feel your pain
been there done that
Christopher McCormack
@cmccormack
May 16 2018 18:26
@JLuboff maybe just switch to vs code :p
Kudzu
@czhower
May 16 2018 18:29
Ive never used Atom so I cant speak about it, but VS Code is awesome. I like it better than VS Enterprise for many tasks (and certainly TS and JS).
Henry
@GitHub-Henry
May 16 2018 18:29
@czhower agree, vs code is better for front end than vs studio
Jason Luboff
@JLuboff
May 16 2018 18:30
I use Atom for text editor, VS Community for IDE
Christopher McCormack
@cmccormack
May 16 2018 18:32
I tried both and found Atom to just be a more buggy less feature rich version of VS Code/Sublime
hope it's gotten better
I remember Atom blew up in the beginning because it had that activate-power-mode that everyone went gaga over though
Jason Luboff
@JLuboff
May 16 2018 18:35
Its just what I've become accustomed to
Ok...got it working..I got lots of errors :joy:
Christopher McCormack
@cmccormack
May 16 2018 18:40
@JLuboff run the --fix before doing it manually and see what it does
it's very pleasing to see most go away in one command line entry
for me most of the time it's because I used single quotes instead of double quotes or whatever
Jason Luboff
@JLuboff
May 16 2018 18:41
I just fixed half of them by changing from CRLF to LF (not sure the difference)
Ah.. Carriage Returns vs Line Feed
Christopher McCormack
@cmccormack
May 16 2018 18:43
crlf is \r\n I believe
Jason Luboff
@JLuboff
May 16 2018 18:43
Correct
Kudzu
@czhower
May 16 2018 18:44
CRLF is not CR, but CR and LF. Its left over from the days before monitors.
Back in the day we had keyboards and a line printer... CR was carriage return - ie return the print head to beginning of line, and LF was move the paper up a line.
Jason Luboff
@JLuboff
May 16 2018 18:45
Ya, I was being lazy in typoing it out
Kudzu
@czhower
May 16 2018 18:45
Windows generally uses CRLF, Linux often just LF.
As bad as a printer instead of a monitor was, it was better than punch cards :)
Christopher McCormack
@cmccormack
May 16 2018 18:46
You can still use CR, i've used it to display stuff like a progress bar in a command line downloading tool
fun to play with
Jason Luboff
@JLuboff
May 16 2018 18:46
eslint fix fixed quite a bit more
Kudzu
@czhower
May 16 2018 18:47
Depends on the app. Consoles typically respect it, parsing code not so much. Most parsing code ignores CRs and looks for LFs, this makes it easy to parse CRLF or LF.
Some parsing code simply removes all CRs first and looks for LFs.
to be safe, CR+LF is safest bet for files.
Christopher McCormack
@cmccormack
May 16 2018 18:49
that's why I let eslint take care of it :) I go back and forth between Mac Linux daily so CRLF inevitably get in somehow but the linter just wipes them away
Brad
@bradtaniguchi
May 16 2018 18:50
@cmccormack brad != prettier, I am brad, idk if I'm "pretty" hehe
Kudzu
@czhower
May 16 2018 18:50
Id bet Mac is LF becuase MacOSX is based on *nix.
Christopher McCormack
@cmccormack
May 16 2018 18:50
haha
yeah probably
Jason Luboff
@JLuboff
May 16 2018 18:55
Welp. Looks like I'm going to learn some destructuring
Christopher McCormack
@cmccormack
May 16 2018 18:57
@JLuboff it's the best!
Jason Luboff
@JLuboff
May 16 2018 18:57
So.. if I'm understanding the example given by ESLint..
const requestID = req.params.requestID; // This 
const {requestID} = req.params; //Should be changed to this?
Christopher McCormack
@cmccormack
May 16 2018 18:57
yes
be wary though - if params is empty, do you know what you'll get?
Jason Luboff
@JLuboff
May 16 2018 18:58

And alternatively... if I wanted to give the variable a different name it would be

const {requestID : ID } = req.params;

?

Christopher McCormack
@cmccormack
May 16 2018 18:58
if params is undefined then you'll get an error
Jason Luboff
@JLuboff
May 16 2018 18:58
params should never be empty but any way to avoid the error?
Christopher McCormack
@cmccormack
May 16 2018 18:59
so it's not ALWAYS great to use destructuring, but you can combine it with default values
@JLuboff yes ID would be the new variable name
Same way you would if you weren't using destructuring
Jason Luboff
@JLuboff
May 16 2018 19:00
:+1:
Christopher McCormack
@cmccormack
May 16 2018 19:00
but you can also do something like
const { params={} } = req;
const { requestID: id } = params;
are you using babel?
Jason Luboff
@JLuboff
May 16 2018 19:01
Nope
Christopher McCormack
@cmccormack
May 16 2018 19:03
There's a new object property check feature coming, not sure when or what it's called but I think it's pretty cool. You can do something like
const prop2 = object?.prop1?.prop2 and I think you just get undefined if prop1 doesn't exist
I may be mutilating the syntax but it's something like that
Jason Luboff
@JLuboff
May 16 2018 19:05
That looks difficult to read
Moisés Man
@moigithub
May 16 2018 19:06
I think saw that in react router... Optional parameter ?
Christopher McCormack
@cmccormack
May 16 2018 19:18
Not sure if parameter or property or what I can never remember what to search for
@JLuboff agreed, it's not pretty, but I like the effect of it a lot
Jason Luboff
@JLuboff
May 16 2018 19:19
Agh... the linter is pissing me off. It hates my code :joy: I'm taking a break...see ya in a while
Christopher McCormack
@cmccormack
May 16 2018 19:20
@JLuboff you can destructure inline as well. I used something like this to grab a property of a property from a globalOptions object:
const { footer: { socialIcons, }, } = globalOptions
Norvin Burrus
@ndburrus
May 16 2018 19:42
Jason Luboff
@JLuboff
May 16 2018 20:32
@cmccormack Neat! Are the comma's necessary? (I know they won't throw an error)
Christopher McCormack
@cmccormack
May 16 2018 20:34
that's me - I've been adding dangling commas as I found it much easier when you want to add stuff later
Jason Luboff
@JLuboff
May 16 2018 20:36
But you're not supporting IE8! How dare you!
ESLint really hates all of my console.log() :joy:
Christopher McCormack
@cmccormack
May 16 2018 20:38
I use this to force myself to be more intentional:
module.exports = {
    "rules": {
        "no-console": [
            "error", {
                allow: ["warn", "error", "info", "debug",]
            }
        ],
    },
}
Jason Luboff
@JLuboff
May 16 2018 20:39
Do you use a style guide (i.e airbnb/google./etc) or your own?
Christopher McCormack
@cmccormack
May 16 2018 20:40
I used to use airbnb but now I just use my own rules along with recommended
My normal setup:
module.exports = {
    "env": {
        "browser": true,
        "commonjs": true,
        "es6": true,
        "node": true
    },
    "extends": ["eslint:recommended", "plugin:react/recommended"],
    "parser": "babel-eslint",
    "plugins": [ "react" ],
    "rules": {
        "indent": [ "error", 2 ],
        "quotes": [ "error", "double" ],
        "semi": [ "error", "never" ],
        "no-console": [
            "error", {
                allow: ["warn", "error", "info", "debug",]
            }
        ],
        "comma-dangle": ["error", "always"],
        "strict": 0,
    }
}
Jason Luboff
@JLuboff
May 16 2018 20:42
I think I'll stick with airbnb for now..but want to turn off this: https://eslint.org/docs/rules/consistent-return

So I tried doing this

module.exports = {
    "extends": "airbnb-base",
    "rules": {
        "treatUndefinedAsUnspecified": true
    }
};

But its giving me an error

Christopher McCormack
@cmccormack
May 16 2018 20:42
@JLuboff yeah they definitely teach you a bit, I like to google all of the errors I get and read up on it
anthonygallina1
@anthonygallina1
May 16 2018 20:43
CAn i ask a dumb question
Bjorn van de Peut
@bjorno43
May 16 2018 20:43
@anthonygallina1 You just did :trollface:
anthonygallina1
@anthonygallina1
May 16 2018 20:43
:)
Jason Luboff
@JLuboff
May 16 2018 20:43
In atom it show you the error and you can click on the link which takes you to the eslint page
Christopher McCormack
@cmccormack
May 16 2018 20:44
@JLuboff my console rule allows me to be deliberate - I only add console.log if I'm debugging and eslint will remind me to delete it later basically
Jason Luboff
@JLuboff
May 16 2018 20:45
Ya eslint just gives a warning for the console.log messages, not an error
Bjorn van de Peut
@bjorno43
May 16 2018 20:45
Of course. Why would you want to receive an error for perfectly valid code?
anthonygallina1
@anthonygallina1
May 16 2018 20:46
been there done that LOL
less hair
Bjorn van de Peut
@bjorno43
May 16 2018 20:47
I mean.. I guess you could throw a custom exception or something.. lol
Jason Luboff
@JLuboff
May 16 2018 20:47
@cmccormack Can you see why the above doesn't work?
Christopher McCormack
@cmccormack
May 16 2018 20:48
@JLuboff what error? does that rule take a boolean?
Bjorn van de Peut
@bjorno43
May 16 2018 20:49
A few days ago someone actually asked a rly dumb question. He wanted to know why he wasn't seeing any error after disabling error reporting..
Jason Luboff
@JLuboff
May 16 2018 20:49
My Linter just says Error while running ESLint: file path. And I believe so.. ?https://eslint.org/docs/rules/consistent-return
Christopher McCormack
@cmccormack
May 16 2018 20:49
it would be
    ....
    "rules": {
        'consistent-return': ["error", { "treatUndefinedAsUnspecified": true }]
    }
Jason Luboff
@JLuboff
May 16 2018 20:50
@cmccormack Thanks. That worked
CamperBot
@camperbot
May 16 2018 20:50
jluboff sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1454 | @cmccormack |http://www.freecodecamp.org/cmccormack
Jason Luboff
@JLuboff
May 16 2018 20:50
OH...now I see in the comments of the example that code
Christopher McCormack
@cmccormack
May 16 2018 20:50

eslint can use comments which is nice if you want to ignore certain errors on just the next line or whatever:

/*eslint consistent-return: ["error", { "treatUndefinedAsUnspecified": true }]*/

in this case consistent-return is the key and the array the value

Bjorn van de Peut
@bjorno43
May 16 2018 20:50
@cmccormack You have too many cookies, lol
Jason Luboff
@JLuboff
May 16 2018 20:51
If he has too many...than I have way too many
Christopher McCormack
@cmccormack
May 16 2018 20:51
haha
Bjorn van de Peut
@bjorno43
May 16 2018 20:51
xD
Christopher McCormack
@cmccormack
May 16 2018 20:51

@JLuboff

  /* eslint no-unused-vars: 0 */
  app.use((err, req, res, next) => {

that's a good one to use for your error handling route

Jason Luboff
@JLuboff
May 16 2018 20:51
Hmmm...still giving me the consitent-return error
Bjorn van de Peut
@bjorno43
May 16 2018 20:51
@JLuboff Thanks. I just want to see how much you have :trollface:
CamperBot
@camperbot
May 16 2018 20:51
bjorno43 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2413 | @jluboff |http://www.freecodecamp.org/jluboff
Bjorn van de Peut
@bjorno43
May 16 2018 20:51
lol
Christopher McCormack
@cmccormack
May 16 2018 20:51
next doesn't get used but you have to have 4 parameters to have an error handling route in express
Jason Luboff
@JLuboff
May 16 2018 20:53
Grr...for some reason thats not working. Oh well.
Christopher McCormack
@cmccormack
May 16 2018 20:53
@JLuboff which?
Jason Luboff
@JLuboff
May 16 2018 20:53
The consitent-return
I don't want it giving me an error becuase an arrow function doesn't return something (which in my routes they do, its just not at the end)
Christopher McCormack
@cmccormack
May 16 2018 20:54
Maybe try
"consistent-return": [ "error", "never" ],
anthonygallina1
@anthonygallina1
May 16 2018 20:55
After thread i have a question Just so i dont step on thread
Christopher McCormack
@cmccormack
May 16 2018 20:55
@anthonygallina1 jump right in
Jason Luboff
@JLuboff
May 16 2018 20:55
@cmccormack Nope..doesn't like that. Causes an error
anthonygallina1
@anthonygallina1
May 16 2018 20:55
np I will wait But thank you @cmccormack
CamperBot
@camperbot
May 16 2018 20:55
anthonygallina1 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1455 | @cmccormack |http://www.freecodecamp.org/cmccormack
anthonygallina1
@anthonygallina1
May 16 2018 20:57
hmmm so
Bjorn van de Peut
@bjorno43
May 16 2018 20:57
@anthonygallina1 It's a public room. If they don't want to be disrupted, there's the option for a private chat. Besides, I have no idea what they're talking about. So others in this room that aren't part of their convo could help you out in the meantime :)
anthonygallina1
@anthonygallina1
May 16 2018 20:57
What if I didnt want to use react just ejs In your code above
Christopher McCormack
@cmccormack
May 16 2018 20:58
@anthonygallina1 the eslint code?
just exclude the react stuff
anthonygallina1
@anthonygallina1
May 16 2018 20:58
I have a outside open source I am trying to learn writing more secure code on
Yes es lint But I think siince much is written in es6 I need to convert to es5 Hope thats not dumb
Christopher McCormack
@cmccormack
May 16 2018 20:59
@anthonygallina1 that's what babel is so nice for :)
anthonygallina1
@anthonygallina1
May 16 2018 21:00
Just incorperate it in the package jason scripts right?
I can show you if permissable
Christopher McCormack
@cmccormack
May 16 2018 21:03

pretty much

> npm install --save-dev babel-cli babel-preset-env babel-plugin-transform-object-rest-spread babel-preset-stage-2

.babelrc:

{
  "presets": ["env", "stage-2"],
  "plugins": [
    ["transform-object-rest-spread", { "useBuiltIns": true }]
  ]
}

is what I have

But I also use babel-loader with webpack
anthonygallina1
@anthonygallina1
May 16 2018 21:04
I havent incorperated web pack yet But is in future plans for it Prob production build
Christopher McCormack
@cmccormack
May 16 2018 21:05
A lot of devs at my work were discussing webpack vs parcel today and they seemed to really like parcel, may want to try that as well
anthonygallina1
@anthonygallina1
May 16 2018 21:06
I heard of that about 3 weeks ago looks good
Christopher McCormack
@cmccormack
May 16 2018 21:06
I may test it out tonight and see
anthonygallina1
@anthonygallina1
May 16 2018 21:07
:thumbsup:
Christopher McCormack
@cmccormack
May 16 2018 21:08
@JLuboff what error?
anthonygallina1
@anthonygallina1
May 16 2018 21:09
Wishing I would have went nunjucks in stead of ejs doing partials doesnt seem as nice.
Christopher McCormack
@cmccormack
May 16 2018 21:09
you can switch whenever if you add additional engines :)
anthonygallina1
@anthonygallina1
May 16 2018 21:09
My first JS blog I have done lots PHP etc But first JS attempt
Feel like I am reinventing the wheel But I am learning things.
Christopher McCormack
@cmccormack
May 16 2018 21:11
should be fun :)
anthonygallina1
@anthonygallina1
May 16 2018 21:15
lol yup after
Running into issues like ejs vs nunjucks and Old gulp vs new more secure gulp etc but I will remember
memory leaks etc
The not fun is the Oh crap I should have used that instead moments
:)
Christopher McCormack
@cmccormack
May 16 2018 21:20
people still use gulp?
anthonygallina1
@anthonygallina1
May 16 2018 21:20
Ya and mongo vs new mongo Using sneaker net(walking it to the other machine
And the gee my old Mongo university from Feb this year might get ruined LOL
Ah a little duct tape and I should be all right :smile:
Christopher McCormack
@cmccormack
May 16 2018 21:21
are they changing it?
doubt it will change too much
anthonygallina1
@anthonygallina1
May 16 2018 21:23
From what I read the db has to be updated to do the conversion
I meen data
Christopher McCormack
@cmccormack
May 16 2018 21:24
ah
I just use mlab for now so I hope they do all that for me :)
anthonygallina1
@anthonygallina1
May 16 2018 21:25
:thought_balloon:
:thumbsup:
Wierd spot I am in I know some things and I am good at some things but then dumb as rock on others
The prob with mlab is some of the mong DBs were a GB
Out of my price range at the moment stil in working in kitchen burrito phase.
Christopher McCormack
@cmccormack
May 16 2018 21:30
haha not heard of that phase
Quincy rocks.
So do you I find solid info when your on @cmccormack
:thumbsup:
Christopher McCormack
@cmccormack
May 16 2018 21:39
Hah thanks @anthonygallina1 I love being in here, I learn from others and hopefully pass on what I learn
CamperBot
@camperbot
May 16 2018 21:39
cmccormack sends brownie points to @anthonygallina1 :sparkles: :thumbsup: :sparkles:
:star2: 5879 | @anthonygallina1 |http://www.freecodecamp.org/anthonygallina1
Brad
@bradtaniguchi
May 16 2018 21:39
haha burrito in closet period
anthonygallina1
@anthonygallina1
May 16 2018 21:39
Much appreciated
Hi @bradtaniguchi
Brad
@bradtaniguchi
May 16 2018 21:39
Hello :D
Bjorn van de Peut
@bjorno43
May 16 2018 21:40
I've just discovered a major downside of creating a library..
anthonygallina1
@anthonygallina1
May 16 2018 21:40
?
Bjorn van de Peut
@bjorno43
May 16 2018 21:40
Ppl actually start using it and expect you to continue its development
Christopher McCormack
@cmccormack
May 16 2018 21:40
@bjorno43 carrying all those books inside is bad for your back?
Bjorn van de Peut
@bjorno43
May 16 2018 21:41
@cmccormack lol
anthonygallina1
@anthonygallina1
May 16 2018 21:41
I just did the dance with keys I think my git skills are getting better
For maintaining
Bjorn van de Peut
@bjorno43
May 16 2018 21:43
Nah. I've put the project on Github hoping it'd be picked up by the community as to continue its development and move it towards the next level. But aside from lots of ppl downloading it, only 1 person actually contributed. And he messed it up xD
anthonygallina1
@anthonygallina1
May 16 2018 21:46
Hope it wasnt me
Bjorn van de Peut
@bjorno43
May 16 2018 21:46
But then you start receiving emails on an almost daily basis from users either asking for help in their specific situations or asking you to add more functionality etc etc
Nah
anthonygallina1
@anthonygallina1
May 16 2018 21:46
:sweat:
:smile:
Bjorn van de Peut
@bjorno43
May 16 2018 21:47
But ye, users asking for more functionality is a good thing. I just wish they realised that a library is supposed to work for everyone and doesn't add specific designs etc :P
anthonygallina1
@anthonygallina1
May 16 2018 21:49
I still have my orig ruby rails up from before FCC And no place to run and fix it Hoping people realize this is way old.
Jason Luboff
@JLuboff
May 16 2018 21:50
@cmccormack Sorry, was off setting up a computer and now we're dealing with a ESXi host thats hung (aka several servers down now) but uh it gave the same error as earlier about the file itself
anthonygallina1
@anthonygallina1
May 16 2018 21:50
Fingers crossed till I can access
Christopher McCormack
@cmccormack
May 16 2018 21:51
@JLuboff haha :fire_engine:
Bjorn van de Peut
@bjorno43
May 16 2018 21:51
@anthonygallina1 That's the thing with users. Tell them to input their age, expecting an integer and I garantuee someone will type "eightteen" lol
Jason Luboff
@JLuboff
May 16 2018 21:51
@cmccormack Ya I did prelim diag... my boss is taking care of the rest so I walked away hehe
Christopher McCormack
@cmccormack
May 16 2018 21:54
@JLuboff "it's borked" @boss "/sigh"
anthonygallina1
@anthonygallina1
May 16 2018 21:54
@bjorno43 I was messing with validation Still need to put backend sanitization in place etc
Brad
@bradtaniguchi
May 16 2018 21:54
Going to become one of those maintainers that closes all the issues with just like "Nope"
anthonygallina1
@anthonygallina1
May 16 2018 21:56
I look everyday But only touch those I feel confident wont be breaking changes
Christopher McCormack
@cmccormack
May 16 2018 21:56
@bradtaniguchi yeah why not
haha
This is an app that adds 1+1, I'm not adding a feature to calculate pi to the jillionth digit
Jason Luboff
@JLuboff
May 16 2018 22:11
@cmccormack oh ya...its borked fo sho. Had to force power down the server (via the management console). Its coming up now though....but our database server is on it :(
Christopher McCormack
@cmccormack
May 16 2018 22:11
ouch
can you make the db redundant?
Jason Luboff
@JLuboff
May 16 2018 22:18
It's backed up and everything...but no.. we don't have enough disk space available to do that (even though we've fought for it since probably before I was here)
We have two ESXi hosts though
Christopher McCormack
@cmccormack
May 16 2018 22:28
scary stuff losing your DB I bet
glad you had backups
Jason Luboff
@JLuboff
May 16 2018 22:37
@cmccormack Ya...looks like everything came back up ok but only time will tell
Christopher McCormack
@cmccormack
May 16 2018 22:46
:thumbsup: good to hear man.
I'm off for a bit ttyl
Jason Luboff
@JLuboff
May 16 2018 22:47
See ya
Brad
@bradtaniguchi
May 16 2018 22:52
I saw this article in my feed gaining a lot of traction:
https://medium.com/tech-tajawal/modern-backend-developer-in-2018-6b3f7b5f8b9 pretty cool, only went through part of the diagram at the top
Angela Sirls
@annDAcoder_gitlab
May 16 2018 23:26

I’m working on this challenge but it will not run. Will
Someone help.
var firstName = "Alan";
var lastName = "Turing";
var myfirstName = "Angela";
var mylastName = "Sirls";

ERROR:
“myFirstName should be a string with at least one character in it.
myLastName should be a string with at least one character in it.”

Kudzu
@czhower
May 16 2018 23:31
JS is case sensitive, you need to mach all your upper case letters.
myLastName is not same as mylastName
Its stupid, but its a historical problem affecting many langs. Many people call it a feature, but if you study the evolution and where it came from, its not. And it leads to lots of bad code when its used purposefully and serious interop problems with other languages.
Jason Luboff
@JLuboff
May 16 2018 23:32
@annDAcoder_gitlab As @czhower has mentioned myfirstName is not the same as myFirstName
Bjorn van de Peut
@bjorno43
May 16 2018 23:37
@JLuboff var myFirstName = myfirstName; now it is :trollface:
Jason Luboff
@JLuboff
May 16 2018 23:43
:smile:
Angela Sirls
@annDAcoder_gitlab
May 16 2018 23:56

Could it be a bug? Its not the case. I added "firstName = myfirstName; lastName = mylastName;"

// Example
var firstName = "Alan";
var lastName = "Turing";

// Only change code below this line
firstName = myfirstName;
lastName = mylastName;
var myfirstName = "Angela";
var mylastName = "Sirls";

Im sure its something simple... Ive literally been stuck for 24 hours.
Kudzu
@czhower
May 16 2018 23:57
Capitalize your F > myFirstName... you have myfirstName.. they are NOT the same... and same for your other variables.
Joseph
@revisualize
May 16 2018 23:57
@annDAcoder_gitlab It isn't a bug.
var myfirstName = "Angela";
var mylastName = "Sirls";
This code is wrong.
Kudzu
@czhower
May 16 2018 23:57
Its bad design, and affects many modern and historical computer languages.
Joseph
@revisualize
May 16 2018 23:57
@annDAcoder_gitlab You need to delete this code:
firstName = myfirstName;
lastName = mylastName;
Angela Sirls
@annDAcoder_gitlab
May 16 2018 23:58
I misunderstood. I will delete that but it still doesn't work.
Joseph
@revisualize
May 16 2018 23:58

@annDAcoder_gitlab The code that you have here:

var myfirstName = "Angela";
var mylastName = "Sirls";

isn't correct because variable declarations are case sensitive.
It needs to be:

var myFirstName = "Angela";
var myLastName = "Sirls";
notice the F and L are both capital letters.
@annDAcoder_gitlab The tests that FreeCodeCamp uses relies on case sensitivity as JavaScript is case sensitive.