These are chat archives for FreeCodeCamp/HelpJavaScript

3rd
Apr 2018
amir mekk
@amirmekk
Apr 03 2018 01:20
Guys what is the command that Clones the blog project repo and store it in directory named blog-project
Christopher McCormack
@cmccormack
Apr 03 2018 01:21
@amirmekk with git? git clone [repo]
amir mekk
@amirmekk
Apr 03 2018 01:22
Thanks
In git given a sha what's the command to get the name of who did the commit
Christopher McCormack
@cmccormack
Apr 03 2018 01:32
can try git log
Brad
@bradtaniguchi
Apr 03 2018 01:33
@amirmekk theres this:
the simple one is: git log -l <SHA>
shows the entire commit, in the link you can filter it down if you want/need to
so I guess the full command would be git log -1 <SHA> --format="%an"
good way to find out who to blame real quick :trollface:
McCabe Coats
@mcoats13
Apr 03 2018 03:18
var count = 0;

function cc(card) {
  // Only change code below this line
  switch(card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;
    case 7:
    case 8:
    case 9:
      return count;
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      count--;
  }

  if(count <= 0){
    return count + ' Hold';
  }
  else{
    return count + ' Bet';
  }
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Hi all, can I get some help on this? I am on the Counting Cards challenge and this is the code I have thus far.
abraham anak agung
@padunk
Apr 03 2018 03:22
@mcoats13 what is the problem?
Christopher McCormack
@cmccormack
Apr 03 2018 03:23
@mcoats13 you don't want to return count in your 7, 8, 9 case
break instead
McCabe Coats
@mcoats13
Apr 03 2018 03:35
@padunk that did the trick! Thank you. Why did the return statement in case 7,8,9 cause it not to work?
CamperBot
@camperbot
Apr 03 2018 03:35
mcoats13 sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 483 | @padunk |http://www.freecodecamp.org/padunk
laowong
@shanxilaowang
Apr 03 2018 03:36
@mcoats13 7 8 9 不用,默认都是0;
abraham anak agung
@padunk
Apr 03 2018 03:36
@mcoats13 i think you should thank @cmccormack . return will stop your function
CamperBot
@camperbot
Apr 03 2018 03:36
padunk sends brownie points to @mcoats13 and @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 119 | @mcoats13 |http://www.freecodecamp.org/mcoats13
:star2: 1388 | @cmccormack |http://www.freecodecamp.org/cmccormack
abraham anak agung
@padunk
Apr 03 2018 03:37
@mcoats13 additionally you can skip write condition for 7,8,9 since it will return 0.
Greg Duncan
@GregatGit
Apr 03 2018 03:59
@mcoats13 return exits the function where break exits the switch or loop
McCabe Coats
@mcoats13
Apr 03 2018 04:03
@GregatGit that makes sense. I just got done refreshing return statements. Thank you.
CamperBot
@camperbot
Apr 03 2018 04:03
mcoats13 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 901 | @gregatgit |http://www.freecodecamp.org/gregatgit
Pedro Diaz
@Pjdaze
Apr 03 2018 04:04
hey guys, can anyone tell me why my last return statement doesn't work? im supposed to return . an empty string if the floor <= 1
Greg Duncan
@GregatGit
Apr 03 2018 04:04
@Pjdaze which challenge is this
Pedro Diaz
@Pjdaze
Apr 03 2018 04:05
function sc(floor){
  let arr = [];
  for(let i = 1; i <= floor; i++){
    arr.push(i);

  }
  const over6 =  arr.map(x => x = 'Aa~').slice(0,-1).join(' ') + ' Pa!';
 const lessThan6 =  arr.map(x => x = ' Aa~').slice(0, -1).join(' ') + ' Pa! '  + 'Aa!';



if(arr.length <= 6){

  return lessThan6;
}
else if(arr.length > 6){


  return over6;
}
return "";

}
sc(1) // 'Aa~ Pa!' sopposed to be ""
i went with it in a horrible way lol i could have done conditionals on the floors perce ... but just wondering
Greg Duncan
@GregatGit
Apr 03 2018 04:08
what is the name of the challenge?
Pedro Diaz
@Pjdaze
Apr 03 2018 04:09
my bad guys this is from codewars
not fcc
a lil shorter with temp literals ...
function sc(floor){
  let arr = [];
  for(let i = 1; i <= floor; i++){
    arr.push(i);

  }
  const over6 =  `${arr.map(x => x = 'Aa~').slice(0,-1).join(' ')} Pa!`;
 const lessThan6 =  `${arr.map(x => x = 'Aa~').slice(0, -1).join(' ')} Pa! Aa!`;



if(arr.length <= 6){

  return lessThan6;
}
else if(arr.length > 6){


  return over6;
}
return "";
}
sc(1) // 'Aa~ Pa!' sopposed to be ""
abraham anak agung
@padunk
Apr 03 2018 04:12
@Pjdaze you need more if condition i think, cause <=6 will include <=1
Pedro Diaz
@Pjdaze
Apr 03 2018 04:13
ohhhh ok ! lets try that lol
yesssss! thanks dude ! gosh i suck
function sc(floor){
  let arr = [];
  for(let i = 1; i <= floor; i++){
    arr.push(i);

  }
  const over6 =  `${arr.map(x => x = 'Aa~').slice(0,-1).join(' ')} Pa!`;
 const lessThan6 =  `${arr.map(x => x = ' Aa~').slice(0, -1).join(' ')} Pa! Aa!`;



if(arr.length <= 6 && arr.length > 1){

  return lessThan6;
}
else if(arr.length > 6){


  return over6;
}
return "";

}
there u go it was exactly that!
abraham anak agung
@padunk
Apr 03 2018 04:15
@Pjdaze :+1:
Blauelf
@Blauelf
Apr 03 2018 08:21
@Pjdaze x => x = 'Aa~' is same as x => 'Aa~', isn't it? The whole thing makes no sense to me.
tundeiness
@tundeiness
Apr 03 2018 09:56
hey all need final push on the random page part of the wiki-viewer. My Idea is that on click of a button , I should insert a link into the button in html and also open the page externally. opening the page externally with the link is the tricky part. Any heads up on this?
Stephen James
@sjames1958gm
Apr 03 2018 10:00
@tundeiness Use window.open?
tundeiness
@tundeiness
Apr 03 2018 10:01
@sjames1958gm okay...
@sjames1958gm not working....
$.ajax({

      type: "GET",
      url: randomWikiLink,
      async: false,
      dataType: "json",
      success: function(data) {

        window.open("data")
      }
Stephen James
@sjames1958gm
Apr 03 2018 10:05
@tundeiness window.open expects a URL - and it opens a new tab or window for that URL.
tundeiness
@tundeiness
Apr 03 2018 10:07
@sjames1958gm apperently no need for the ajax setup?
Stephen James
@sjames1958gm
Apr 03 2018 10:07
@tundeiness No
tundeiness
@tundeiness
Apr 03 2018 10:07
@sjames1958gm great!
Leigh Hobson
@leighhobson89
Apr 03 2018 10:39
hi guys,with this code, arr will be passed as an argument, it will be an array of two numbers which can be any positive integer. Can someone tell me why this won't push those two numbers and all in between to the array rangeArray:
  var rangeArray = [];
  var i;
  if (arr[0] > arr[1]) { //find out if we should make a rnage by going down or going up
    for (i=arr[0];i==arr[1];i--) {
      rangeArray.push(i);
    }
  }
  if (arr[0] < arr[1]) {
    for (i=arr[0];i==arr[1];i++) {
      rangeArray.push(i);
    }
  }
its just returning an empty array
Aditya
@ezioda004
Apr 03 2018 10:48
@leighhobson89 Check the for loop condition, i==arr[1] it'll never return true since arr[0] > arr[1] or arr[0] < arr[1]
So the loop will never execute
Leigh Hobson
@leighhobson89
Apr 03 2018 10:54
so if arr[0] was 10 and arr[1] was 5, my understanding is that i would be set to 10, and would decrement each iteration until it was equal to 5 then stop. is this not the case?
should it just be <= in this case then?
= even
>= even
Leigh Hobson
@leighhobson89
Apr 03 2018 10:59
thanks thats done it
@ezioda004
thanks @ezioda004
CamperBot
@camperbot
Apr 03 2018 11:00
leighhobson89 sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 523 | @ezioda004 |http://www.freecodecamp.org/ezioda004
FutureGeek
@Jackxiaojiahuo
Apr 03 2018 12:22
Make Object Properties Private
this is a bug?
help me !
Is Anybody There?
Greg Duncan
@GregatGit
Apr 03 2018 12:25
@Jackxiaojiahuo are you still stuck
Ken Haduch
@khaduch
Apr 03 2018 12:30
@Jackxiaojiahuo - do you have code to share? And a specific question?
???
FutureGeek
@Jackxiaojiahuo
Apr 03 2018 12:46
I've done it
thanks
any one know it ?@
FutureGeek
@Jackxiaojiahuo
Apr 03 2018 12:48
@GregatGit @khaduch @Jackxiaojiahuo
I've done it
thanks
CamperBot
@camperbot
Apr 03 2018 12:48
jackxiaojiahuo sends brownie points to @gregatgit and @khaduch :sparkles: :thumbsup: :sparkles:
:cookie: 902 | @gregatgit |http://www.freecodecamp.org/gregatgit
:star2: 3845 | @khaduch |http://www.freecodecamp.org/khaduch
Ken Haduch
@khaduch
Apr 03 2018 12:49
@AhmedMElhalaby - yes, what is your question - please post your code for the line that you are supposed to change, post it between single backquotes: `
@Jackxiaojiahuo - you're welcome...
FutureGeek
@Jackxiaojiahuo
Apr 03 2018 12:51
@khaduch I wanted to have a screenshot, but I didn't know how to send it
@khaduch JS private declarations that question, I in the get method with the variable name and private variable names this and set.
Ken Haduch
@khaduch
Apr 03 2018 12:53

@Jackxiaojiahuo - for a screenshot, you can just do that on your computer (like using the "Snipping Tool" on windows) and copy it, then paste it into the chat. For the code block that looks like this:

var myVar = "This is a code block";

You put three backquotes on a line by themselves:
```
Then post your code. And then three more backquotes:
```
You can read about it in this forum post.

That is the Markdown syntax for posting code, and it's definitely the right way to post code here. For long code blocks, they recommend creating a github gist and posting a link. (That is mentioned in the top navbar on the chat window.)
FutureGeek
@Jackxiaojiahuo
Apr 03 2018 12:55
ok I see
I'm a direct screenshot and a copy, but it doesn't work @khaduch
@GregatGit Because I'm in China, so I can't go to youtobe
ShelomiZheng
@ShelomiZheng
Apr 03 2018 14:27
good evening
FutureGeek
@Jackxiaojiahuo
Apr 03 2018 14:28
good evening
Jason Luboff
@JLuboff
Apr 03 2018 15:08
good morning
abraham anak agung
@padunk
Apr 03 2018 15:14
good night. are this room retired too?
Jason Luboff
@JLuboff
Apr 03 2018 15:34
Nope, not retired
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 15:36
Hello Nerds!!! How y'all!
Jason Luboff
@JLuboff
Apr 03 2018 15:38
Hey...doing alright, you?
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 15:38
I am here trying to get back on the coding horse.
Jason Luboff
@JLuboff
Apr 03 2018 15:39
Do. Or do not. There is no try.
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 15:40
I am gonna do it bruv
Markus Kiili
@Masd925
Apr 03 2018 15:41
Morning.
Jason Luboff
@JLuboff
Apr 03 2018 15:41
Hey
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 15:41
Sup
Todays challenge is to style a Login page :)
Jason Luboff
@JLuboff
Apr 03 2018 15:46
Do it
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 15:46
or a Login and a Sign up page :)
hello everyone
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 15:48
hello
Jason Luboff
@JLuboff
Apr 03 2018 15:48
Yo
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 15:48
Markus Kiili
@Masd925
Apr 03 2018 15:49
Hi.
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 15:49
@tiagocorreiaalmeida thankss bruv
CamperBot
@camperbot
Apr 03 2018 15:49
roniquericketts sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 512 | @tiagocorreiaalmeida |http://www.freecodecamp.org/tiagocorreiaalmeida
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 15:49
@tiagocorreiaalmeida these nice bruv
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 15:50
@JLuboff you coming ?:D
Jason Luboff
@JLuboff
Apr 03 2018 15:53
There
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 15:53
can I watch?
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 15:53
@RoniqueRicketts come aswell
why watch when you can join?
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 15:54
@tiagocorreiaalmeida I cam't solve algortithms fast
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 15:54
dont worry too much
Jason Luboff
@JLuboff
Apr 03 2018 15:54
Wtf? Why did it go from 2 minutes to 6 minutes
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 15:54
I did it
cause of inviting @RoniqueRicketts :\
to give him time to join
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 15:55
lol
what do I need to do to join
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 15:57
join in with google account
Jason Luboff
@JLuboff
Apr 03 2018 15:57
or github
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 15:57
orgithub
and after open the link I sent here
and click register
fast :D
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 16:02
ok
Jason Luboff
@JLuboff
Apr 03 2018 16:02
Got C
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 16:03
i haven't even done a
I am lost hehehe
Jason Luboff
@JLuboff
Apr 03 2018 16:03
You can skip to any of the others by clicking the letter in the upper left corner
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 16:05
I used an old solution i made on arcade on b, couldn't make my brain think
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 16:09
oh cool. I haven't completed one hehehe
worthless
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 16:09
the last one its simple give it a read
Blauelf
@Blauelf
Apr 03 2018 16:10
Umm... great. The tournament was over just after I discovered it.
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 16:10
this one was random and I had to use an old solution so I feel bad for wining
Jason Luboff
@JLuboff
Apr 03 2018 16:11
Argh... my solution for B was almost there
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 16:13
wait its over and I haven't solved one heheeh
my last one answer was not successful hahahaha
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 16:14
wtf is going on
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 16:14
spammer
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 16:14
someone seems mad with the world
Jason Luboff
@JLuboff
Apr 03 2018 16:15
Reported him
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 16:15
@JLuboff come again
Jason Luboff
@JLuboff
Apr 03 2018 16:15
Nah... gotta work
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 16:15
sorry for distracting you :D
Jason Luboff
@JLuboff
Apr 03 2018 16:15
Nope, no worries. Wanted to do one :D
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 16:17
wait the tournament is over?
Dang can I forfit
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 16:21
oh god no idea why I can0t pass last exercise @Blauelf
function shefferStroke(a, b) {
    return a && !b || !a && b;
}
Blauelf
@Blauelf
Apr 03 2018 16:22
@tiagocorreiaalmeida I somewhat misunderstood the "distance" in part B. And C is NAND. NAND is NOT AND. You are doing XOR.
!(a && b) or !a || !b would be correct.
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 16:24
crap, congrats @Blauelf :D
Jason Luboff
@JLuboff
Apr 03 2018 16:24
@tiagocorreiaalmeida Hey you work in IT right?
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 16:24
yes @JLuboff at least for the moment
Jason Luboff
@JLuboff
Apr 03 2018 16:25
@tiagocorreiaalmeida Do you support Office 2016?
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 16:25
I need some practice I am way behind :)
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 16:25
we use office 2016home and business but thinking about changing to office 365
@RoniqueRicketts dont worry too much its just a matter a pratice, also being fast doenst means being good in this situation
Jason Luboff
@JLuboff
Apr 03 2018 16:28
@tiagocorreiaalmeida Got it. We use a mix of Office 2016 volume license and Office 365. Have you had any trouble with Word 2016 recently? I have a bunch of clients that Word keeps fucking up. You just and open a file and it Stops working but you can still open Word by itself and then open the documents. Can't figure out why. No new updates have been installed from what I can see
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 16:29
@tiagocorreiaalmeida well true. I am at work also. so I am multitasking hehe
Daniel Simeonov
@dbsimeonov
Apr 03 2018 16:29

Guys if I have

<select class="form-control" id="exampleFormControlSelect1">
  <option>tonne</option>
  <option>Kilogram</option>
</select>

How can I get with javascript the option that is active? It doesnt add class or anything so I dont know how I can watch which item is selected

Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 16:30
@JLuboff try the fully repair option that you get on control panel by right click on the program, with word had no problems but with outlook had a few
Kaz Baig
@kbaig
Apr 03 2018 16:31
@dbsimeonov you want to get the value of the select tag
Tiago Correia
@tiagocorreiaalmeida
Apr 03 2018 16:31
^
Blauelf
@Blauelf
Apr 03 2018 16:31
I use Office 2016 in the Office365 version. I frequently find my Office installing an update exactly the moment I need it to work.
Jason Luboff
@JLuboff
Apr 03 2018 16:31
@tiagocorreiaalmeida Oh trust me I've tried that lol. Repair just takes forever and doesn't do shit. Only solution I've found so far is to do a full uninstall and reinstlal but the issue still comes back for some
Ronique Ricketts
@RoniqueRicketts
Apr 03 2018 16:31
@tiagocorreiaalmeida I am not worried really I am slow at solving some algorithms. :)
Daniel Simeonov
@dbsimeonov
Apr 03 2018 16:31
@kbaig and what eventlistener should I use to be run when its changing the option?
it should be on click ?
Jason Luboff
@JLuboff
Apr 03 2018 16:32
@Blauelf Convienent lol
Blauelf
@Blauelf
Apr 03 2018 16:33
@JLuboff Well, it searches for and installs updates on startup.
Kaz Baig
@kbaig
Apr 03 2018 16:33
@dbsimeonov onchange
Jason Luboff
@JLuboff
Apr 03 2018 16:35
@Blauelf We use a managed update system and even then it's only security updates that we push out so I dunno. Just frustrating I can't seem to find anything recent for it but I'm going to keep searching
Blauelf
@Blauelf
Apr 03 2018 16:35
Also, I am forced to change my Office365 password every few months. And a plethora of office programmes suddenly complain that they are no longer associated with a valid account. Wouldn't one use tokens that don't depend on the password?
Daniel Simeonov
@dbsimeonov
Apr 03 2018 16:35
@kbaig thanks man
CamperBot
@camperbot
Apr 03 2018 16:35
dbsimeonov sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 587 | @kbaig |http://www.freecodecamp.org/kbaig
Jason Luboff
@JLuboff
Apr 03 2018 16:36
Lol password changes have caused a host of issues with Outlook 2016. It always fucks up the autodiscover (even though we use Office 365 for our email)
Daniel Simeonov
@dbsimeonov
Apr 03 2018 16:45

@kbaig

formHead.addEventListener('change', function(){
        if(formHead.value == 'Mass'){
            console.log('It does')
        }else{
            console.log('doesnst');
        }

    })

Should be something like that? I have a simple select tag with multiple options

Markus Kiili
@Masd925
Apr 03 2018 16:51
Joseph
@revisualize
Apr 03 2018 20:48
Hey hey
Jason Luboff
@JLuboff
Apr 03 2018 20:49
Well well well... look who it is
Brad
@bradtaniguchi
Apr 03 2018 20:53
Everyone is abondoning ship from the main room, since apparently its closing down tomorrow
Jason Luboff
@JLuboff
Apr 03 2018 20:53
What? Really?
I know Quincy messaged me to check out the forum and get my opinion of it
and I know there was talk a while back of combining rooms but wasn't aware of the outcome
Brad
@bradtaniguchi
Apr 03 2018 20:56
Yea mstellaluna just said so a few mins ago
Jason Luboff
@JLuboff
Apr 03 2018 21:00
Crazy..
Kaz Baig
@kbaig
Apr 03 2018 21:01
ah so it's def just the main room and LetsPair right @bradtaniguchi
Brad
@bradtaniguchi
Apr 03 2018 21:02
Yes
Kaz Baig
@kbaig
Apr 03 2018 21:03
ah kk
Jason Luboff
@JLuboff
Apr 03 2018 21:03
I'm disappointed that they're pushing the forum so much. I get why, but ..eh..
mstellaluna
@mstellaluna
Apr 03 2018 21:06
@kbaig the let's pair is not affected. it is only the main room that is being closed tomorrow
the rest of the rooms are as is
Kaz Baig
@kbaig
Apr 03 2018 21:07
@mstellaluna Oh I guess Quincy removed the notice from LP
mstellaluna
@mstellaluna
Apr 03 2018 21:07
it appears so
it may have been posted in error
Joseph
@revisualize
Apr 03 2018 22:10
Anyone solve this kata?
Daniel Simeonov
@dbsimeonov
Apr 03 2018 22:12
Can somebody with few spare minutes help me with js, to give me a tip what approach should I use on small app im trying to create?
Jason Luboff
@JLuboff
Apr 03 2018 22:12
@revisualize Which kata?
@dbsimeonov Post up your question and if anyones around who can answer...they will :D
Daniel Simeonov
@dbsimeonov
Apr 03 2018 22:12
Its quite long the question thats why I wanted to be pm :D
Joseph
@revisualize
Apr 03 2018 22:12
@JLuboff I was looking at this one: https://www.codewars.com/kata/remove-zeros/
Daniel Simeonov
@dbsimeonov
Apr 03 2018 22:12
Give me a moment
Jason Luboff
@JLuboff
Apr 03 2018 22:13
@revisualize Give me a few minutes to take a look
Brad
@bradtaniguchi
Apr 03 2018 22:14
I can give my 2 cents, AFAIK @dbsimeonov , but id post it in chat not PM so anyone can go over it. (idk how long it is haha)
Daniel Simeonov
@dbsimeonov
Apr 03 2018 22:14

I'm trying to re-create the Google Converter which has different options for units.
The UI is following: https://ibb.co/kL3E4x

Javascript just don't know from where to start and in what order to put my EventHandlers

function calculate(){

    input.addEventListener("input", function(){

        if(formHead.value === 'Mass' && inpSect === 'Kilogram' && outSect === 'tonne'){
            calculateKilo(0.001);
        }
    });
    function calculateKilo(number){
        output.value = input.value * number;
    }
}
Tried to be as short as possible :D
Brad
@bradtaniguchi
Apr 03 2018 22:16
How come the order of the event listeners matters tho?
Daniel Simeonov
@dbsimeonov
Apr 03 2018 22:17
Umm I think I need one for the option on top, one for each input/output and for the options under them?
Jason Luboff
@JLuboff
Apr 03 2018 22:18
@revisualize Lol.. apparently you can't use push, concat, or filter all of which I had used
I guess I should have read the instructions more
Brad
@bradtaniguchi
Apr 03 2018 22:19
@dbsimeonov Yea so three in total
Joseph
@revisualize
Apr 03 2018 22:19
@JLuboff I'm trying something... I'm getting somewhere.
Daniel Simeonov
@dbsimeonov
Apr 03 2018 22:20
@bradtaniguchi I think I need to create a couple of functions first so I can call them back after the event listener is triggered. I thought they will be 5.. But I'm happy if you can explain me briefly what I should do.
Jason Luboff
@JLuboff
Apr 03 2018 22:20
@revisualize So where you been at anyways? Haven't seen you here in a while
Daniel Simeonov
@dbsimeonov
Apr 03 2018 22:20
Or this is too complicated for first project?
Brad
@bradtaniguchi
Apr 03 2018 22:23
@dbsimeonov I think is a pretty good first project, its pretty simple in terms of UI, and is mainly about handling the individual events properly and updating the other form fields.
Joseph
@revisualize
Apr 03 2018 22:23
@JLuboff Been unemployed. Looking for work.
Jason Luboff
@JLuboff
Apr 03 2018 22:24
@revisualize Ah man, that sucks.
Joseph
@revisualize
Apr 03 2018 22:26
It is what it is.
Jason Luboff
@JLuboff
Apr 03 2018 22:26
True
Daniel Simeonov
@dbsimeonov
Apr 03 2018 22:26
@bradtaniguchi Ok, so I should create a function as a wrapper, inside to have 3 or 5 event listeners with if/else statements? and outside to create functions for each of the calculations that will be nested inside the if/else statements?
Joseph
@revisualize
Apr 03 2018 22:27
@JLuboff I'm trying something like this:
function removeZeros(array, position, next) {
  if (position === array.length) return array;

  if (position == undefined) position = 0;
  if (next == undefined) next = 1;

  if (array[position] != 0) position++;
  if (position === next) next++;

  if (array[position] == 0 && array[next] != 0) {
    array[position] = array[next];
    array[next] = 0;
    position++
   }
   else if (array[next] == 0) {
    next++
   }

  return removeZeros(array, position, next);
}
Jason Luboff
@JLuboff
Apr 03 2018 22:28
Interesting, I gave up after my attempt lol
(aka I had to get back to actual work but meh)
Joseph
@revisualize
Apr 03 2018 22:29
@JLuboff Yeah, I know how that is.
Jason Luboff
@JLuboff
Apr 03 2018 22:35
Grrr...damn undefined properties
Joseph
@revisualize
Apr 03 2018 22:37
Okay so, my idea is working.
Ish
Joseph
@revisualize
Apr 03 2018 22:46
Damn, I'm close... ish
function removeZeros(array, position, next) {
  // Sort "array" so that all elements with the value of zero are moved to the
  // end of the array, while the other elements maintain order.
  // [0, 1, 2, 0, 3] --> [1, 2, 3, 0, 0]
  // Zero elements also maintain order in which they occurred.
  // [0, "0", 1, 2, 3] --> [1, 2, 3, 0, "0"]

  // Do not use any temporary arrays or objects. Additionally, you're not able
  // to use any Array or Object prototype methods such as .shift(), .push(), etc

  // the correctly sorted array should be returned.
  if (next >= array.length) return array;

  if (position == undefined) position = 0;
  if (next == undefined) next = 1;

  if (Boolean(array[position])) position++;
  if (position === next) next++;

  if (!Boolean(array[position]) && Boolean(array[next])) {
    array[position] = array[next];
    array[next] = 0;
    next++
   }
   else if (!Boolean(array[position]) && !Boolean(array[next])) {
    next++
    }

  return removeZeros(array, position, next);
}
Kaz Baig
@kbaig
Apr 03 2018 22:49
@revisualize presumably you saw us trying to do it in Help?
Joseph
@revisualize
Apr 03 2018 22:49
I actually got confused as to which room that was in.
Lance
@texas2010
Apr 03 2018 22:56
@revisualize that was in help chat room.
Joseph
@revisualize
Apr 03 2018 22:58
YEah yeah.
Brad
@bradtaniguchi
Apr 03 2018 23:05
@dbsimeonov Hey sorry was afk for a big, I would personally setup the event listeners in 1 function, then handle each event in other functions. This would be the cleanest approach. Since there will only be 3 possible input events, having three independent event listeners should be good.
Now in each function you would have the if/else statements to handle what kind of input occured and update the other values accordingly. Since the user can go convert "left-right" or "right-left" between the two input boxes you will need to be able to perform the conversion then update the opposite side value.