These are chat archives for FreeCodeCamp/HelpJavaScript

21st
Feb 2018
Roger Colquehuanca Calcina
@rogergcc
Feb 21 2018 03:47
result.failure has only 3 items
and its an array like this arr[0] arr[1] && arr[2]
abraham anak agung
@padunk
Feb 21 2018 05:53
@RoniqueRicketts I gave you the tips:
const result = {
  success: ["max-length", "no-amd", "prefer-arrow-functions"],
  failure: ["no-var", "var-on-top", "linebreak"],
  skipped: ["id-blacklist", "no-dup-keys"]
};

function makeList(arr) {
  "use strict";

  // change code below this line
  const resultDisplayArray =  [];
  //do the for loop in here or .map
 remember arr is same as result.failure so arr =  ["no-var", "var-on-top", "linebreak"]
  // change code above this line

  return resultDisplayArray;
}

const resultDisplayArray = makeList(result.failure);
Abdulah Hamzic
@hamzicabdulah
Feb 21 2018 13:06

Hey, guys. What I want to do is, develop an extension that adds a button to a site, and when a user clicks on that button, the extension should start doing some web automation, i.e. go to another website and complete a certain task there. However, that whole process should not be visible to the user and should happen in the background. My question is, is it possible to do this with any of Chrome's APIs (and if so, please point me to it), or do I have to use a web automation library to do this? E.g., since I am using JavaScript, I'd import this automation library https://github.com/segmentio/nightmare into the chrome extension, and do the automation with it. I'm just thinking there should be a cleaner way than this one.

Just to clarify, the idea here is not to do something in the user's browser without their knowing about it. It's the main and obvious use of the extension.

Dimitris Nik.
@dimitrissnk
Feb 21 2018 13:07
Hello guys, I am trying to solve the "Title Case a Sentence", can somebody help me a bit?
Stephen James
@sjames1958gm
Feb 21 2018 13:10
@Dimitrios51 What do you have so far?
Dimitris Nik.
@dimitrissnk
Feb 21 2018 13:16
@sjames1958gm Hey, I saw the hint, but I think that is possible with slice() too? See my code: function titleCase(str) { var array=str.toLowerCase().split(" "); for (var i=0;i<array.length;i++) { return array[i][0].toUpperCase() + array[i].slice(1); } }
CamperBot
@camperbot
Feb 21 2018 13:16
:bulb: to format code use backticks! ``` more info
Stephen James
@sjames1958gm
Feb 21 2018 13:16
@Dimitrios51 return will exit your function immediately. You need to store each modified word inside the loop and return afterwords
slice is what I used, so it does work fine.
Dimitris Nik.
@dimitrissnk
Feb 21 2018 13:18
so I need something like var storeStr=array[i][0].toUpperCase() + array[i].slice(1);
under my for loop
Stephen James
@sjames1958gm
Feb 21 2018 13:20
@Dimitrios51 well you will need to store every word somewhere (perhaps you have an array already you can put the changed words back into?)
Dimitris Nik.
@dimitrissnk
Feb 21 2018 13:22
@sjames1958gm I have only the array which came from the split()
Stephen James
@sjames1958gm
Feb 21 2018 13:23
@Dimitrios51 yes, so you could array[i] = modfied word from array[i]
Dimitris Nik.
@dimitrissnk
Feb 21 2018 13:24
@sjames1958gm I did it and after the for loop I return array;
Stephen James
@sjames1958gm
Feb 21 2018 13:25
@Dimitrios51 Is the result supposed to be an array?
Dimitris Nik.
@dimitrissnk
Feb 21 2018 13:25
As I see I need to join too
Stephen James
@sjames1958gm
Feb 21 2018 13:25
@Dimitrios51 :)
Dimitris Nik.
@dimitrissnk
Feb 21 2018 13:28
@sjames1958gm youpiii :P
Stephen James
@sjames1958gm
Feb 21 2018 13:29
@Dimitrios51 This is a challenge that is good to come back to when you learn about the array map function
Dimitris Nik.
@dimitrissnk
Feb 21 2018 13:32
@sjames1958gm difficult definition to understand on MDN :P Thanks for the info, I will do so!
CamperBot
@camperbot
Feb 21 2018 13:32
dimitrios51 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9005 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Feb 21 2018 13:32
@Dimitrios51 :+1:
Simon Cordova
@gbsimon87
Feb 21 2018 13:36
Hey all good aft!
Was wondering if anyone could help me refactor a tiny bit of logic (rewrite it more efficiently and perhaps shorter)...
function yesterdaysAnswer() {

    let answeredYesterday = userData.last_answer_day == config.test_day - 2
    console.log('MYCODE, answeredYesterday', answeredYesterday)

    let yesterdaysCorrectAnswer = config.questions[config.test_day - 2].answer
    console.log('MYCODE, yesterdaysCorrectAnswer', yesterdaysCorrectAnswer)

    if ( answeredYesterday ) {

        let yesterdaysAnswer = userData.last_answer
        console.log('MYCODE, yesterdaysAnswer', yesterdaysAnswer)        

        if ( yesterdaysAnswer == 'no' ) {
            if ( yesterdaysCorrectAnswer === false ) {
                console.log('MYCODE: answers match!')
            }
            else {
                console.log('MYCODE: answers DON\'T match!')    
            }
        }

        if ( yesterdaysAnswer == 'yes' ) {
            if ( yesterdaysCorrectAnswer === true ) {
                console.log('MYCODE: answers match!')
            } else {
                console.log('MYCODE: answers DON\'T match!')
            }
        }

    }

}
Stephen James
@sjames1958gm
Feb 21 2018 13:57
@gbsimon87 let answeredYesterday = userData.last_answer_day == config.test_day - 2 this variable isn't needed just use the condition in the if
You have two values for answers "yes"/"no" and true/false? If the values were both one or the other then you could just do
if (yesterdaysAnswer == yesterdaysCorrectAnswer) {
  console.log('MYCODE: answers match!')
}
else {
   console.log('MYCODE: answers DON\'T match!')    
}
The refactoring could be (don't create variables that are only used once)
function yesterdaysAnswer() {
  if ( userData.last_answer_day == config.test_day - 2 ) {
    if ( userData.last_answer ==  config.questions[config.test_day - 2].answer) {
      console.log('MYCODE: answers match!')
    }
    else {
      console.log('MYCODE: answers DON\'T match!')
    }
  }
}
Muhammad Hasham
@MohammadHasham
Feb 21 2018 14:55
how to get value of counter in client side whenever it is updated
actually what i want on my client side is to call an api endpoint after 1 second? is it a bad practice? is there a better approach?
Stephen James
@sjames1958gm
Feb 21 2018 14:57
@MohammadHasham Websockets were created to allow server to have long term communication with the client.
There is also long polling https://www.pubnub.com/blog/2014-12-01-http-long-polling/
From the perspective of a small app it isn't a big problem, but think about if you had many many users with each one
hitting your server every second
Muhammad Hasham
@MohammadHasham
Feb 21 2018 14:59

@sjames1958gm actually i have just one client as an admin that just wants to see how many people are visiting are visiting another route

so i am doing something like this,

app.post('/count',(req,res)=>{
  QR.find({"title":req.body.title},(err,response)=>{
    let count = response[0].Students.length;
    res.send({count})
  });
});

i am just wanting to call this after 1 second delay from one machine at an instance.

is that fine?
or should i study and use websockets instead
what do you recommend?
Stephen James
@sjames1958gm
Feb 21 2018 15:00
@MohammadHasham For the admin interface, probably ok. Maybe put websockets on your list of things to learn about
Muhammad Hasham
@MohammadHasham
Feb 21 2018 15:01
yeah sure pretty curious about that! @sjames1958gm thanks
CamperBot
@camperbot
Feb 21 2018 15:01
mohammadhasham sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9006 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Jason Luboff
@JLuboff
Feb 21 2018 16:26
:wave:
Kaz Baig
@kbaig
Feb 21 2018 16:37
:wave:
Jason Luboff
@JLuboff
Feb 21 2018 16:38
Whats going on?
Kaz Baig
@kbaig
Feb 21 2018 16:44
Doing some business development researchy type work
hbu?
Jason Luboff
@JLuboff
Feb 21 2018 16:46
Working with a user to get him setup on a new computer.
Kaz Baig
@kbaig
Feb 21 2018 16:47
I'm basically creating decks to pitch our tech stack to various verticals
Tom
@moT01
Feb 21 2018 16:49
:panda_face:
Onome Sotu
@onomesotu
Feb 21 2018 16:50
Least common multiples is driving me crazy :worried:
Kaz Baig
@kbaig
Feb 21 2018 16:50
@onomesotu feel free to ask about it :)
Onome Sotu
@onomesotu
Feb 21 2018 16:53
To find the multiples, I decided to incrementally (++1) map the array continuously, while testing each new mapped array against the original array to see if there is an element in the mapped array that is divisible by all elements of the original array
How to do this is surprisingly elusive :worried:
I can map new arrays continously using a while loop..
it is the test thats confusing as heck
I'm not sure if i should use filter, every, or what not... I'm gonna try again..
:)
Stephen James
@sjames1958gm
Feb 21 2018 16:55
@onomesotu creating an array of test values is probably too expensive computewise
Kaz Baig
@kbaig
Feb 21 2018 16:56
One brute force way of doing it is to do a while loop, testing the iterator against your set of numbers
Stephen James
@sjames1958gm
Feb 21 2018 16:56
@onomesotu One maths element to remember that only multiples of the largest number have to be considered
since to be a multiple of all numbers they have to be a multiple of the largest
Onome Sotu
@onomesotu
Feb 21 2018 16:57
@sjames1958gm oh dear
dang!!
brilliant..
Kaz Baig
@kbaig
Feb 21 2018 16:57
You could work your way up to this method @onomesotu
Onome Sotu
@onomesotu
Feb 21 2018 16:59
@sjames1958gm @kbaig thanks.. i'm gonna run back and check again :)
CamperBot
@camperbot
Feb 21 2018 16:59
onomesotu sends brownie points to @sjames1958gm and @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 575 | @kbaig |http://www.freecodecamp.org/kbaig
:star2: 9008 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Kaz Baig
@kbaig
Feb 21 2018 17:01
@sjames1958gm with the > 9000 dang
Stephen James
@sjames1958gm
Feb 21 2018 17:01
@kbaig :)
I may retire at 10k
Onome Sotu
@onomesotu
Feb 21 2018 17:02
@kbaig I was wondering.. how does one get that? :smile:
Kaz Baig
@kbaig
Feb 21 2018 17:02
@onomesotu Get what
Onome Sotu
@onomesotu
Feb 21 2018 17:02
9000
Kaz Baig
@kbaig
Feb 21 2018 17:02
Being a legend I suppose
Jason Luboff
@JLuboff
Feb 21 2018 17:15

@kbaig I....I don't understand.. lol

I'm basically creating decks to pitch our tech stack to various verticals

@sjames1958gm Retiring is not allowed
Stephen James
@sjames1958gm
Feb 21 2018 17:23
@JLuboff I think that statement wins jargon bingo in one sentence :)
Jason Luboff
@JLuboff
Feb 21 2018 17:24
:)
Onome Sotu
@onomesotu
Feb 21 2018 17:36
Is this a legit function?
function foundMultiple(range, int){
    range.every(function(value){
      return value % int === 0;
    });
  }
Jason Luboff
@JLuboff
Feb 21 2018 17:37
Assuming range is an array, ya I don't see why not.
Onome Sotu
@onomesotu
Feb 21 2018 17:37
yes, range is an array
but it returns undefined in my test
Jason Luboff
@JLuboff
Feb 21 2018 17:38
whats the function call?
Onome Sotu
@onomesotu
Feb 21 2018 17:38
function smallestCommons(arr) {
  var array = [];
  arr.sort();
  var largestNum = arr[arr.length - 1];
  for(var i = arr[0]; i <= arr[arr.length - 1]; ++i){
    array.push(i);
  }

  function foundMultiple(range, int){
    range.every(function(value){
      return value % int === 0;
    });
  }

  /*var foundMultiple = array.every(function(value){
    return value % largestNum === 0;
  });*/

  console.log(foundMultiple(array, largestNum), array);

  /*var j = 2;
  while(true){
    var largestNum = arr[arr.length - 1];
    if(foundMultiple(array, largestNum)){
      return largestNum;
    } else {
       ++j;
       largestNum = largestNum * j;
    }
  } */
}

smallestCommons([23, 18]);
Jason Luboff
@JLuboff
Feb 21 2018 17:39
Well, foundMultiple isn't returning anything
Onome Sotu
@onomesotu
Feb 21 2018 17:39
console.log prints = > undefined [ 18, 19, 20, 21, 22, 23 ]
it should return true or false
Jason Luboff
@JLuboff
Feb 21 2018 17:40
So you need
function foundMultiple(range, int){
    return range.every(function(value){
      return value % int === 0;
    });
  }
Onome Sotu
@onomesotu
Feb 21 2018 17:41
SOmetimes I just want to crawl under my bed and hide my face
:worried:
Thanks @JLuboff
CamperBot
@camperbot
Feb 21 2018 17:41
onomesotu sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2338 | @jluboff |http://www.freecodecamp.org/jluboff
Jason Luboff
@JLuboff
Feb 21 2018 17:41
No reason to. Its all about learning and trust me, while I'm not professional, I make mistakes daily
Onome Sotu
@onomesotu
Feb 21 2018 17:42
There should be a facepalm emoji :)
Jason Luboff
@JLuboff
Feb 21 2018 17:42
I agree. Closest I've found is :facepunch:
since its facepunch lol
Onome Sotu
@onomesotu
Feb 21 2018 17:43
looooool
SO right :)
Tai Jones
@taiJones00
Feb 21 2018 17:48
There's a bug when using multiple operations before pressing equals. Is it obvious to anyone how to solve it? https://codepen.io/taiJones00/pen/wrZgGq?editors=1011
Jason Luboff
@JLuboff
Feb 21 2018 17:50
@taiJones00 You need to check what the last button clicked was, if it was an operator you need to replace it with the new operator. Same for your decimal point
Tai Jones
@taiJones00
Feb 21 2018 17:51
there's a bug with the decimal point too? @JLuboff
Jason Luboff
@JLuboff
Feb 21 2018 17:51
I can click it multiple times, yes
Also.. shouldn't be able to click an operator prior to their being a number (except maybe to make a number negative)
Tai Jones
@taiJones00
Feb 21 2018 17:53
Oh okay. There's so many conditions to this calculator
Onome Sotu
@onomesotu
Feb 21 2018 17:54
Why is this while loop infinite?
function smallestCommons(arr) {
  var array = [];
  arr.sort();

  //create array for the range
  for(var i = arr[0]; i <= arr[arr.length - 1]; ++i){
    array.push(i);
  }

  //test function 
  function foundMultiple(range, int){
    return range.every(function(value){
      return value % int === 0;
    });
  }

  var j = 2;
  while(true){
    var largestNum = arr[arr.length - 1] * j;//get first multiple of largest number in range 
    if(foundMultiple(array, largestNum)){//test for matches
      return largestNum;
    } 
    ++j;
  } 
}
smallestCommons([23, 18]);
Tai Jones
@taiJones00
Feb 21 2018 17:55
Your condition is true for the while loop. Nothing sets the condition of true to false so the loop never stops @onomesotu
Onome Sotu
@onomesotu
Feb 21 2018 17:56
@taiJones00 it should stop eventually if the if condition is met
which it should
Tai Jones
@taiJones00
Feb 21 2018 17:57
Since the while loop is forever going, it will forever check your if condition @onomesotu
Onome Sotu
@onomesotu
Feb 21 2018 17:57
@taiJones00 what about the return statement? it ignores it?
Tai Jones
@taiJones00
Feb 21 2018 17:58
Hm. Not sure about that
Aniculaesei
@Aniculaesei
Feb 21 2018 17:59
Hello !Can you help me please?What is wrong with this code?Thank you
function checkSign(num) {
  return (num < 0)? "negative" : (num ==0)? "zero" : (num>0)? "positive";
}

checkSign(10);
Jason Luboff
@JLuboff
Feb 21 2018 17:59
@onomesotu It's going to see it as an infinite loop becuase there is potential for the return to never be reached
Tai Jones
@taiJones00
Feb 21 2018 18:00
Ohhh
Onome Sotu
@onomesotu
Feb 21 2018 18:00
i think you should remove (num > 0) @Aniculaesei
Aditya
@ezioda004
Feb 21 2018 18:01
@Aniculaesei You dont have a final else condition
Jason Luboff
@JLuboff
Feb 21 2018 18:01
@Aniculaesei You're not ending the final condition
Aniculaesei
@Aniculaesei
Feb 21 2018 18:01
@JLuboff how i can end it? :))))
Aditya
@ezioda004
Feb 21 2018 18:01
function checkSign(num) {
  return num < 0? "negative" :num ==0?"zero" : "positive"
}
checkSign(10);
Onome Sotu
@onomesotu
Feb 21 2018 18:02
@JLuboff I don't understand, because of the potential for an infinite loop, the code doesn't run?
Aniculaesei
@Aniculaesei
Feb 21 2018 18:03
@JLuboff @ezioda004 @onomesotu thank you
CamperBot
@camperbot
Feb 21 2018 18:03
aniculaesei sends brownie points to @jluboff and @ezioda004 and @onomesotu :sparkles: :thumbsup: :sparkles:
:cookie: 470 | @ezioda004 |http://www.freecodecamp.org/ezioda004
:star2: 2339 | @jluboff |http://www.freecodecamp.org/jluboff
:cookie: 312 | @onomesotu |http://www.freecodecamp.org/onomesotu
Aniculaesei
@Aniculaesei
Feb 21 2018 18:04
still not working:

function checkSign(num) {
  return (num < 0)? "negative" : (num ==0)? "zero" :  "positive";
}

checkSign(10);
Aditya
@ezioda004
Feb 21 2018 18:05
@Aniculaesei Its working for me
What error are you getting?
Jason Luboff
@JLuboff
Feb 21 2018 18:06
@Aniculaesei I get positive when I run that
Onome Sotu
@onomesotu
Feb 21 2018 18:07
@Aniculaesei it works well, i just tested it
Aniculaesei
@Aniculaesei
Feb 21 2018 18:07
I think it is a problem from beta freecodecamp
Jason Luboff
@JLuboff
Feb 21 2018 18:07
@Aniculaesei Whats the challenge?
Onome Sotu
@onomesotu
Feb 21 2018 18:08
does anyone else have server error from FCC?
Aniculaesei
@Aniculaesei
Feb 21 2018 18:09
me :)
Aditya
@ezioda004
Feb 21 2018 18:09
Yeah beta has problems, none of the sass challenges/es6 challenges work
Aniculaesei
@Aniculaesei
Feb 21 2018 18:09
Basic JavaScript: Use Multiple Conditional (Ternary) Operators
@JLuboff
Jason Luboff
@JLuboff
Feb 21 2018 18:09
Send a link if you can
Onome Sotu
@onomesotu
Feb 21 2018 18:11
i'm not using beta and i also have problems :)
Aniculaesei
@Aniculaesei
Feb 21 2018 18:11
:)
Jason Luboff
@JLuboff
Feb 21 2018 18:12
...ya link doesn't do me much good right now haha
Aniculaesei
@Aniculaesei
Feb 21 2018 18:12
@JLuboff From how many years you are here? :)
I saw you from minimum 2 years..right? :)
Jason Luboff
@JLuboff
Feb 21 2018 18:13
Ya, I started FCC I believe May 2016?
Aniculaesei
@Aniculaesei
Feb 21 2018 18:14
and...at ...you work in this time? :)
Ronique Ricketts
@RoniqueRicketts
Feb 21 2018 18:14
const result = {
  success: ["max-length", "no-amd", "prefer-arrow-functions"],
  failure: ["no-var", "var-on-top", "linebreak"],
  skipped: ["id-blacklist", "no-dup-keys"]
};
function makeList(arr) {

  const resultDisplayArray = [];
arr.forEach(function(i){
  resultDisplayArray.push(`<li class="text-warning"${i}</li>`);
});
  return resultDisplayArray;
}
const resultDisplayArray = makeList(result.failure);
console.log(resultDisplayArray);
Jason Luboff
@JLuboff
Feb 21 2018 18:16
I've worked in IT this whole time, but as I've progressed I've started taking on my programming/database related projects. I'm actually working on my first production project (I've deployed a few things, one is a conference room sign which isn't really that involved and the other I rebuilt a current in house application that was using VB to use C# but this project is my first from scratch project thats big)
@RoniqueRicketts You're missing a >
Aniculaesei
@Aniculaesei
Feb 21 2018 18:17
@JLuboff good luck and thank you very much for your time!
CamperBot
@camperbot
Feb 21 2018 18:17
aniculaesei sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
api offline
Jason Luboff
@JLuboff
Feb 21 2018 18:18
@Aniculaesei Thank you! By the way...tried your code in that challenge, and it passes ;)
CamperBot
@camperbot
Feb 21 2018 18:18
jluboff sends brownie points to @aniculaesei :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @aniculaesei |http://www.freecodecamp.org/aniculaesei
Aniculaesei
@Aniculaesei
Feb 21 2018 18:19
@JLuboff thanks again :)
CamperBot
@camperbot
Feb 21 2018 18:19
aniculaesei sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
api offline
Ronique Ricketts
@RoniqueRicketts
Feb 21 2018 18:20
@JLuboff still not goign through
Aniculaesei
@Aniculaesei
Feb 21 2018 18:21
@JLuboff you have a bachelor degree on IT or you have learned here? :)
Jason Luboff
@JLuboff
Feb 21 2018 18:23
@Aniculaesei I have an associates degree for general education and then after that I took IT related courses (Windows Server, Cisco, little linux, etc). Took some certifications exams and then ended up working in Apple repair for a few years before getting into my current job which is HelpDesk/Network Tech/anything and everything lol As far as programming goes, I learned mostly through FCC with a few udemy courses. C# I learned through a book and practice. I'd still say I'm only proficient at JS, and a beginner at C#
Aniculaesei
@Aniculaesei
Feb 21 2018 18:24
good luck in your career!
Jason Luboff
@JLuboff
Feb 21 2018 18:24
@RoniqueRicketts Adding the > passes the challenge for me
@Aniculaesei Thank you, good luck to you in all current and future endevors :D
CamperBot
@camperbot
Feb 21 2018 18:24
jluboff sends brownie points to @aniculaesei :sparkles: :thumbsup: :sparkles:
api offline
Ronique Ricketts
@RoniqueRicketts
Feb 21 2018 18:24
not for me
Jason Luboff
@JLuboff
Feb 21 2018 18:25

@RoniqueRicketts

const result = {
  success: ["max-length", "no-amd", "prefer-arrow-functions"],
  failure: ["no-var", "var-on-top", "linebreak"],
  skipped: ["id-blacklist", "no-dup-keys"]
};
function makeList(arr) {

  const resultDisplayArray = [];
arr.forEach(function(i){
  resultDisplayArray.push(`<li class="text-warning">${i}</li>`);
});
  return resultDisplayArray;
}
const resultDisplayArray = makeList(result.failure);
console.log(resultDisplayArray);
`

This passed

Either reset the code and try that again or try a different browser
Aniculaesei
@Aniculaesei
Feb 21 2018 18:25
I have a nother question can you explain me a lttle bit about parseInt and radix :(..I dont understand how i can use it
Ronique Ricketts
@RoniqueRicketts
Feb 21 2018 18:26
oh that woeks to reset and refresh my browser thanks
@JLuboff thanks
Jason Luboff
@JLuboff
Feb 21 2018 18:28
@Aniculaesei I'm probably not the best to explain that. But essentially radix is the base system to use. For example, Hexadecimal is base 16, so radix for that would be 16. Binary is base two, it only uses 1 and 0 for its number so radix would be 2
So Binary uses only two distinct characters, hexedecimal uses 16 distinct characters (0-9, A-F)
Aniculaesei
@Aniculaesei
Feb 21 2018 18:30
and how about parseInt("11",2)
Jason Luboff
@JLuboff
Feb 21 2018 18:38
That would be parsing the number 11 to base 2 which would be 3 (the one on the right is 1, the one on the left is 2). For binary numbers (base 2) 1 and 0 act as an on/off switch
Onome Sotu
@onomesotu
Feb 21 2018 18:42
This was the final solution for the smallest multiple problem
Aniculaesei
@Aniculaesei
Feb 21 2018 18:42
pfff....I really dont understand..so hard.. :((
Onome Sotu
@onomesotu
Feb 21 2018 18:42
function smallestCommons(arr) {
  var array = [];
  arr.sort();

  //create array for the range
  for(var i = arr[0]; i <= arr[arr.length - 1]; ++i){
    array.push(i);
  }

  //test function 
  function foundMultiple(range, int){
    return range.every(function(value){
      return int % value === 0;
    });
  }

  var j = 2; 
  while(j){
    var largestNum = arr[arr.length - 1] * j;//get first multiple of largest number in range 
    if(foundMultiple(array, largestNum)){//test for matches
      return largestNum;
    } 
    ++j;
  } 
}


smallestCommons([5, 1]);
Aniculaesei
@Aniculaesei
Feb 21 2018 18:42
@JLuboff thank you for your time
CamperBot
@camperbot
Feb 21 2018 18:42
aniculaesei sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
api offline
Onome Sotu
@onomesotu
Feb 21 2018 18:42
Any suggestions for refactoring is welcome
Jason Luboff
@JLuboff
Feb 21 2018 18:45
@Aniculaesei Sorry I couldn't be more clear. I'd suggest googling some
Aniculaesei
@Aniculaesei
Feb 21 2018 18:46
@JLuboff thanks
CamperBot
@camperbot
Feb 21 2018 18:46
api offline
aniculaesei sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
Quantomistro3178
@Quantomistro3178
Feb 21 2018 18:48
Can I get ONLY the text of an html element without using jQuery?
Christopher McCormack
@cmccormack
Feb 21 2018 18:48
@Quantomistro3178 yup
Quantomistro3178
@Quantomistro3178
Feb 21 2018 18:49
I dont want to use .innerHTML
Jason Luboff
@JLuboff
Feb 21 2018 18:49
jQuery is just a library of vanilla javascript
Christopher McCormack
@cmccormack
Feb 21 2018 18:49
document.getElementById('[element id]').textContent
Quantomistro3178
@Quantomistro3178
Feb 21 2018 18:49
ah, ok. thanks! @cmccormack
CamperBot
@camperbot
Feb 21 2018 18:49
quantomistro3178 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1330 | @cmccormack |http://www.freecodecamp.org/cmccormack
Christopher McCormack
@cmccormack
Feb 21 2018 18:50
@Quantomistro3178 yeah like @JLuboff it's just fancy functions, if you review the source code for how jQuery gets text from an element, I believe it uses textContent
Jason Luboff
@JLuboff
Feb 21 2018 18:50
@cmccormack What up
Christopher McCormack
@cmccormack
Feb 21 2018 18:51
@JLuboff yo
In all day meeting with vendor, fun stuff :)
Jason Luboff
@JLuboff
Feb 21 2018 18:52
Sweet... a vendor I would know?
Christopher McCormack
@cmccormack
Feb 21 2018 18:54
Cisco?
Jason Luboff
@JLuboff
Feb 21 2018 18:54
Who are they?
Quantomistro3178
@Quantomistro3178
Feb 21 2018 18:54
what's vanilla javascript btw?
Jason Luboff
@JLuboff
Feb 21 2018 18:54
:P
Christopher McCormack
@cmccormack
Feb 21 2018 18:54
More specifically their new acquisition Viptela
@Quantomistro3178 just Javascript :)
Jason Luboff
@JLuboff
Feb 21 2018 18:54
@Quantomistro3178 It's just plain Javascript
Christopher McCormack
@cmccormack
Feb 21 2018 18:54
not chocolate Javascript
Jason Luboff
@JLuboff
Feb 21 2018 18:54
vanilla is just another way to say plain or original
Quantomistro3178
@Quantomistro3178
Feb 21 2018 18:55
oh
Jason Luboff
@JLuboff
Feb 21 2018 19:03
Using long name/ids is really starting to get annoying when I have to write my SQL queries..
vivachucksama
@vivachucksama
Feb 21 2018 19:32
Hi guys, I'm wondering about the difference between 'object.objName' and 'object[objName]'. Is there anyone can help me
Christopher McCormack
@cmccormack
Feb 21 2018 19:34
@JLuboff how long are they?
Jason Luboff
@JLuboff
Feb 21 2018 19:34
@vivachucksama Dot notation searches for a string literal. so object.objName is looking for a key that is "objName". Bracket notation does not, so object[objName] is looing for a key where objName is a variable/parameter. But Bracket notation can also search for string as such object["objName"] this would look for the key "objName" in object
Christopher McCormack
@cmccormack
Feb 21 2018 19:35
.objName would be better written as obj.propertyName or obj['propertyName']
Jason Luboff
@JLuboff
Feb 21 2018 19:36
@cmccormack ...Long.. lol for example approvalVPOperationsComments but once everything is written out its not a huge deal. Obiviousily I could make it shorter appVPOpsCom or something like that but.. its nice having it human readable for anyone who may look at this in the future
vivachucksama
@vivachucksama
Feb 21 2018 19:37
@JLuboff @cmccormack Thanks a lot, i
CamperBot
@camperbot
Feb 21 2018 19:37
vivachucksama sends brownie points to @jluboff and @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1331 | @cmccormack |http://www.freecodecamp.org/cmccormack
:star2: 2340 | @jluboff |http://www.freecodecamp.org/jluboff
Christopher McCormack
@cmccormack
Feb 21 2018 19:37
@JLuboff haha. Are you using VS Code? will it autocomplete?
Jason Luboff
@JLuboff
Feb 21 2018 19:37
@cmccormack Using Atom, so ya it will which helps
@cmccormack Oh, and thus far my single page app is (including JS within the page).. 1334 lines haha. I maaayyy see about trying to have handlebars import the templates as needed but we'll see
Christopher McCormack
@cmccormack
Feb 21 2018 19:39
haha
Jason Luboff
@JLuboff
Feb 21 2018 19:40
I have a lot of repeating lines due to the template nature and checking what the user can/can not do
Christopher McCormack
@cmccormack
Feb 21 2018 19:42
Can you build it in JS instead?
Jason Luboff
@JLuboff
Feb 21 2018 19:43
.....
Ya... I guess I could..
haha
Christopher McCormack
@cmccormack
Feb 21 2018 19:44
For a large SPA that may be better than trying to deal with loads of repeated elements
Jason Luboff
@JLuboff
Feb 21 2018 19:45
@cmccormack True. It does only render whats necessary but I may consider that
Lunch time... catch ya afterwards
Christopher McCormack
@cmccormack
Feb 21 2018 19:45
later man
Tai Jones
@taiJones00
Feb 21 2018 19:48
Hey i'm sorry for asking again but why can't I chain operations? https://codepen.io/taiJones00/pen/wrZgGq
Matej BoĆĄnjak
@mbosnjak01
Feb 21 2018 19:54
@taiJones00 chain operations like?
Tai Jones
@taiJones00
Feb 21 2018 19:55
Like 5 + 7 + 2. Right now I have to do 5 + 7 = (something) + 2. I can't do two or more operations in a row
@mbosnjak01
Nate Mallison
@NJM8
Feb 21 2018 19:59
Does anyone have any Scheme experience or have read SICP?
Stephen James
@sjames1958gm
Feb 21 2018 20:02
@taiJones00 What I did was when another operator was entered it basically does what your =
so 5 + 7 + (would show 12)
Christopher McCormack
@cmccormack
Feb 21 2018 20:06
yup @sjames1958gm I did the same
Tai Jones
@taiJones00
Feb 21 2018 20:06
I might have code that does that in my update function
Stephen James
@sjames1958gm
Feb 21 2018 20:10
@sjames1958gm Your = function seems to do something like that
Tai Jones
@taiJones00
Feb 21 2018 20:11
Something like that. If I uncomment the comment in the update function then everything is messed up @sjames1958gm