These are chat archives for FreeCodeCamp/HelpJavaScript

24th
May 2018
Gulsvi
@gulsvi
May 24 2018 00:11
@NJM8 No, I don't know C. Just going through a book on algorithm design. It had me do a queue for BFS and a stack for DFS on trees, but I haven't gotten to graphs yet.
Ronique Ricketts
@RoniqueRicketts
May 24 2018 00:26
can i add environment secret codes in React
Nate Mallison
@NJM8
May 24 2018 00:47
@RoniqueRicketts There should be, how is the app being hosted? I'm don't know much about React but everyone needs environment variables
Stephen James
@sjames1958gm
May 24 2018 01:28
@RoniqueRicketts The environment would be server side, so in your React "build" you could inject these. Care must be taken as anything on the client is
exposed to the user.
Nate Mallison
@NJM8
May 24 2018 02:06
@gulsvi what book?
Claudio Restifo
@Marmiz
May 24 2018 03:11

anyone knows if in react propTypes I can:

Component.propTypes = {
// test for an array of Objects with a particular shape
  data: PropTypes.arrayOf(
    PropTypes.shape({ title: PropTypes.string, value: PropTypes.number })
  ),
// instead of just an array of objects
  data: PropTypes.arrayOf(PropTypes.object)
};

Unfortunately I'm not leveraging TS here T_T

ArchivalBoat50
@ArchivalBoat50
May 24 2018 03:41
image.png
Hey guys I was doing the Falsy Bouncer algorithm and I succeeded in a matter of minutes. However I don't quite understand the code I typed as I typed this by accident off the top of my head. Does anyone mind explaining to me my code?
function bouncer(arr) {
  var x = new Boolean(false);
  if (x) {
    return arr.filter(Boolean);
  }
}

bouncer([7, "ate", "", false, 9]);
Brad
@bradtaniguchi
May 24 2018 03:45
@ArchivalBoat50 I don't think that actually works as expected, it just so happens to work
the key is this part of the code: return arr.filter(Boolean)
ArchivalBoat50
@ArchivalBoat50
May 24 2018 03:46
@bradtaniguchi I think i only need that part
Brad
@bradtaniguchi
May 24 2018 03:47
Yes, the rest of the code doesn't really do anything besides make things confusing
ArchivalBoat50
@ArchivalBoat50
May 24 2018 03:47
@bradtaniguchi What does the return arr.filter(Boolean) code do?
How does it work?
Brad
@bradtaniguchi
May 24 2018 03:50

Yea THAT's pretty funky, but the usual use case of filter (and how id use it to solve the challenge would be this)

arr.filter((el)  => {
  if (el) {
    return true;
  }
  return false;
})

or simply:

arr.filter(el => el);
Now onto why you can use Boolean as the "callback" I think comes down to how it relates to a function
I flipped the filter to a map and it prints out true/false values instead, which helps in understanding but this is why it works:
Boolean(undefined) // false
Brad
@bradtaniguchi
May 24 2018 03:55
So basically new Boolean(/*whatever*/) makes an object wrapper for boolean. (An object is ALWAYS true, which is why your if statement is true) and Boolean(/*whatever*/) is a function that converts values to booleans

pretty trippy but makes sense at the end of the day. Also I wanted to throw out this is the same:

const trueOrFalse = !!val;
const trueOrFalse = Boolean(val);

double ! is pretty funky looking, but makes sense when you think about it, its just double negation so you get true/false as expected. A lot shorter :D

@ArchivalBoat50 Here's a pen I wrote my notes in just as a reference too. https://codepen.io/bradtaniguchi/pen/eraWeB?editors=0012
ArchivalBoat50
@ArchivalBoat50
May 24 2018 04:09
@bradtaniguchi Thanks for your explanation.
CamperBot
@camperbot
May 24 2018 04:09
archivalboat50 sends brownie points to @bradtaniguchi :sparkles: :thumbsup: :sparkles:
:cookie: 489 | @bradtaniguchi |http://www.freecodecamp.org/bradtaniguchi
Brad
@bradtaniguchi
May 24 2018 04:09
np :D
KingKongg
@KingKongg
May 24 2018 05:09
Hi can anyone help me with my code.

function titleCase(str) {
var splitCase=str.lowerCase.split(" ");
for(i=0;i<splitCase.length;i++){
var x= splitCase[i].split("");
for(j=0;i<x.length;j++){
x[0].charAt(0).toUpperCase();

}
splitCase[i]=x[i].join("");

}
return splitCase.join("");

}
titleCase("I'm a little tea pot");

the error is that the split property is undefined
Markus Kiili
@Masd925
May 24 2018 05:12
@KingKongg It needs to be .toLowerCase(...)
It is better to use string operations instead of character arrays.
Meaning that you can easily avoid the second loop.
KingKongg
@KingKongg
May 24 2018 05:17
@Masd925 what do you mean using string operations instead of character arrays
Markus Kiili
@Masd925
May 24 2018 05:25
@KingKongg You can use String methods like charAt and .slice and concatenation + to construct a new titlecased word from the original, instead of using split to characters.
KingKongg
@KingKongg
May 24 2018 05:28
var word=str.toLowerCase.split(" ");
why is there an error for this code, it say it not a function
Markus Kiili
@Masd925
May 24 2018 05:29
@KingKongg str.toLowerCase() <- parens
KingKongg
@KingKongg
May 24 2018 05:35
@Masd925 Thank you! I solved it!
CamperBot
@camperbot
May 24 2018 05:35
kingkongg sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4803 | @masd925 |http://www.freecodecamp.org/masd925
Markus Kiili
@Masd925
May 24 2018 05:36
@KingKongg :+1:
Nemanja Simeunovic
@Saymon85
May 24 2018 06:11
@ConnectCodes Woow... nice bro, respect!!! :)
Rajat
@rajataudichya
May 24 2018 08:31
Hey anyone there?
I am running a jquery each loop for an array but the loop is not iterating numerically
```js
$(document).ready(function(){


  var user_arr = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"]


  $(user_arr).each(function(num,name){

function createUrl(){

return "https://wind-bow.gomix.me/twitch-api/streams/"+name+"?callback=?"
    }

    $.getJSON(createUrl(),function(json){
    console.log(name);console.log(num);

  });


  })


  /* Another Alternative using $.ajax function 

  $.ajax({
  method:"GET",
  url:better to store url in variable,
  dataType:"JSON/HTML",
  async:false,
  success:function(res){

  }



  }); */


});
Shubham soni
@shubhamsoni2617
May 24 2018 10:12
I am quite confused with "return keyword". Most of the times with the built-in methods.
For example: arr.filter(function(val){
return val%2;
});
when to put return in front if arr.filter and vice-versa?
Stephen James
@sjames1958gm
May 24 2018 10:15
@shubhamsoni2617 calling arr.filter results in a value - if you want that value to be 'returned' from the function that contains filter then
arr.filter
otherwise you will need to assign the result to a variable
let filteredarr = arr.filter
Rajat
@rajataudichya
May 24 2018 10:15
whenever you wish a return val
Stephen James
@sjames1958gm
May 24 2018 10:17
@shubhamsoni2617 The return inside the .filter callback has nothing to do with returning from the function that contains the filter
function findodds (arr) {
   let odds = arr.filter(function(val){
return val%2; // This return has no relationship to returning from findodds, only the callback
});
}
Shubham soni
@shubhamsoni2617
May 24 2018 10:20

function destroyer(arr) {
var args = Array.from(arguments).slice(1);
return arr.filter(function(val) {
return !args.includes(val);
});
}

What both the return exactly doing here?

Stephen James
@sjames1958gm
May 24 2018 10:22
@shubhamsoni2617 the first is returning the result of the filter from destroyer, the second is returning the result of !args.includes(val) to filter
@shubhamsoni2617 The second return is inside of a callback function, so it is only a return from that function back to filter
Rajat
@rajataudichya
May 24 2018 10:23
Hi @sjames1958gm
I am trying to uses a foreach loop to iterate an array
CamperBot
@camperbot
May 24 2018 10:24
shubhamsoni2617 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9254 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Rajat
@rajataudichya
May 24 2018 10:24
but instead for going numerically it is return array randomly
Stephen James
@sjames1958gm
May 24 2018 10:26
@rajataudichya I have never used jquery .each function
Just use vanilla js for each
user_arr.forEach(function(name, index) {});
Rajat
@rajataudichya
May 24 2018 10:36
user_arr.forEach(function(name, index) {}); this function iterates an array from 0 index right
Stephen James
@sjames1958gm
May 24 2018 10:42
@rajataudichya yes
Rajat
@rajataudichya
May 24 2018 11:48
@sjames1958gm the issue was not with the foreach loop
the $.getJSON function is cause of randomizing the area
dinesh
@1532j0004kg
May 24 2018 11:55
@sjames1958gm hi
Stephen James
@sjames1958gm
May 24 2018 12:02
@rajataudichya The console.log is in the $.getJSON then the responses will come back in random order.
dinesh
@1532j0004kg
May 24 2018 12:03

https://addressbook-express.glitch.me/store.html
try this
But I want it to search by name only
like this

Press "D" ...all the names starting with D appear.
Then press "I"...all the names starting with Di only appear...

Rajat
@rajataudichya
May 24 2018 12:28
@sjames1958gm i think it is becuase of the callback function
Need help here guys
as you can check the Pen what i am trying to do is get the json channel wise as stated in the array but for some reason i resulted data I am getting is random, can someone tell me what could be the issue here
Stephen James
@sjames1958gm
May 24 2018 12:42
@rajataudichya You are sending multiple requests to a remote site, the responses are handled as they come back and some may take longer
so the order is not fixed. Your code will have to handler that (this is part of the complexity of this challenge)
Rajat
@rajataudichya
May 24 2018 12:44
any hint ? on how i can arrange them numerically?
Moisés Man
@moigithub
May 24 2018 12:49
https://stackoverflow.com/questions/28066429/promise-all-order-of-resolved-values @rajataudichya
Promises might help
..another way could be collect all the answer first.. and only aftr u get em all.. u display it on the order u want (which in theory is what Promise.all does internally)
Stephen James
@sjames1958gm
May 24 2018 13:30
@rajataudichya You could store them in an object with keyed names, and then use the original array order to process that object
Nate Mallison
@NJM8
May 24 2018 14:04
@sjames1958gm Do you have experience with JWT and rest api's? I'm doing the voting app and building the back end as a rest api then a separate SPA for the front end. My question is how do the login and signup routes access credentials, they won't be in req.body correct? I have to pass an object with my http call but I'm not sure how that data is accessible by the api
nvm, it is in req.body
Gulsvi
@gulsvi
May 24 2018 14:44
@NJM8 It's The Algorithm Design Manual, by Steven Skiena
Ronique Ricketts
@RoniqueRicketts
May 24 2018 14:50
@sjames1958gm Ok I wanted to pass a secret key to verify a token to see if its expired or not.
Nate Mallison
@NJM8
May 24 2018 14:55
@gulsvi Nice, that one is on my list
my someday list
Gulsvi
@gulsvi
May 24 2018 14:56
I've had it since December. Hard to get motivated to go through it to be honest - pretty dry and technical, but good when I get in the right mindset.
Classes finally done, summer is ahead, so thought why not pick it up again :)
Ronique Ricketts
@RoniqueRicketts
May 24 2018 15:00
@sjames1958gm I will let it do all the secret stuff on my server
Nate Mallison
@NJM8
May 24 2018 15:00
nice. How did you hear about it? I saw it on teachyourselfcs.com, started from the beginning with SICP. another good one, had to stop after a few chapters though,
Gulsvi
@gulsvi
May 24 2018 15:02
The older brother of a friend of mine is a software engineer - recommended it to me
Koohyar Movassagh
@Koohyar-m
May 24 2018 15:14
Hi guys :wave:
Gulsvi
@gulsvi
May 24 2018 15:18
:wave:
Jason Luboff
@JLuboff
May 24 2018 15:19
:wave:
Koohyar Movassagh
@Koohyar-m
May 24 2018 15:23
I have a question if anyone can help
Jason Luboff
@JLuboff
May 24 2018 15:23
We can always try
Daniel Simeonov
@dbsimeonov
May 24 2018 15:26

Hey guys, I'm trying to create simple app, where I build the markup from javascript but have some errors that never seen before - DOMException: The play() request was interrupted by a new load request

I think its because I create everything in the global scope and its kind of mess, should I wrap the markup function and the functionality separate?

Koohyar Movassagh
@Koohyar-m
May 24 2018 15:28
I need to change the session timer in pomodoro timer. I thought $("#inc").on("click",function(){ session++; $("#show").empty().append(session); $("#sessShow").empty().append(session); }); I have defualt session timer session = 25 after button +/- is pressed it will change the session variable inside on click function but session variable outside remains unchanged. Is there a way to change session?
https://codepen.io/Codeconnect/pen/wjYGZQ?editors=0011
Gulsvi
@gulsvi
May 24 2018 15:31
@dbsimeonov Hard to tell without seeing your code, but usually a good idea to separate logic as much as possible. Each function does 1-2 things at most.
Daniel Simeonov
@dbsimeonov
May 24 2018 15:33
@gulsvi Can you give me a hint/tip ?My Repo
Gulsvi
@gulsvi
May 24 2018 15:34
@ConnectCodes Your global session variable is getting updated from what I see. You could use .text() instead of .empty().append() though:
        $("#show").text(session);
        $("#sessShow").text(session)
Daniel Simeonov
@dbsimeonov
May 24 2018 15:34
I'm sure the code is right, as I was using it when I had the html setup, but now decided to create everything with javascript. Just I'm missing the logic or the order of my functions
Gulsvi
@gulsvi
May 24 2018 15:35
I'm not sure how to help with that error off the top of my head @dbsimeonov Have you tried searching for that error? Might be browser-related.
Daniel Simeonov
@dbsimeonov
May 24 2018 15:37
Thanks! @gulsvi
CamperBot
@camperbot
May 24 2018 15:37
dbsimeonov sends brownie points to @gulsvi :sparkles: :thumbsup: :sparkles:
:star2: 2730 | @gulsvi |http://www.freecodecamp.org/gulsvi
Koohyar Movassagh
@Koohyar-m
May 24 2018 15:46
@gulsvi thats great I am using that, However I still can't customizing session timer( On top right) I have increase and decrease $("#inc").on("click",function(){ session++; to change the var session but when I start the timer it sets it to default session value 25. I dont know if I explained it well :)
Gulsvi
@gulsvi
May 24 2018 15:49
@ConnectCodes Add a console.log to your timer function, your session variable is updated, but you aren't using it to calculate the time for display:
    function timer(){
        console.log(session);
Hello guys
Ronique Ricketts
@RoniqueRicketts
May 24 2018 15:55
hello
Rajat
@rajataudichya
May 24 2018 15:56
my aim is to get objects in order
Jason Luboff
@JLuboff
May 24 2018 15:56
@RoniqueRicketts Yo
Ronique Ricketts
@RoniqueRicketts
May 24 2018 15:57
@JLuboff wazzup
Rajat
@rajataudichya
May 24 2018 15:57
I am running $.getJSON inside a foreach loop but somehow I am getting responses randomly and not numericallu
I believe is because of late response from the API server
Jason Luboff
@JLuboff
May 24 2018 15:58
@RoniqueRicketts Working..you
Koohyar Movassagh
@Koohyar-m
May 24 2018 15:58
@gulsvi I see you are right! I am confused probably because I defined $("#sessShow").text(session); $("#show").text(session);before function timer() or something else. I am not sure yet but thank you
Ronique Ricketts
@RoniqueRicketts
May 24 2018 15:58
@JLuboff Same. I am remote on a customer's computer and my computer from home. I am am working on my perosnal project
Jason Luboff
@JLuboff
May 24 2018 16:00
@rajataudichya Why the second loop inside your getjson? Thats duplicating info
@rajataudichya If you want to sort...than I would advise pushing everything to an array, and sorting that on a key then displaying
@RoniqueRicketts Focus on the customer!
Ronique Ricketts
@RoniqueRicketts
May 24 2018 16:05
@JLuboff I am at the moment once I am done with him its back to coding.
Jason Luboff
@JLuboff
May 24 2018 16:05
@RoniqueRicketts Whats the customer's problem?
Kudzu
@czhower
May 24 2018 16:07
@rajataudichya It sounds like you are encountering the fun of async. You need to async request all, hold then sort after if you want this. Or you can use sync methods, but the standard methods dont use sync and its frowned up on in the JS world because of how multi tasking is done in JS. Its like Win3.1 16 bit, but even more limited.
Ronique Ricketts
@RoniqueRicketts
May 24 2018 16:07
@JLuboff His print is not responding to any print jobs. :)
Jason Luboff
@JLuboff
May 24 2018 16:08
@RoniqueRicketts Restart the print spooler, restart the printer
Kudzu
@czhower
May 24 2018 16:08
that usually wont fix it, get to the folder that has the queue. Stop print service, delete items in the queue folder, restart the print service.
Its a common problem with print queues (Im assuming Windows)
Jason Luboff
@JLuboff
May 24 2018 16:09
You can delete the print jobs, then just restart the spooler, no need to stop spooler first
Ronique Ricketts
@RoniqueRicketts
May 24 2018 16:09
@JLuboff I just did, he had 2 print drivers , a copy one and the original both print drives had their list of queued jobs. So I had to clear the print spooler and calibrate the printer to prevent potential jams. The issue is resolved and I am back to coding :)
Kudzu
@czhower
May 24 2018 16:10
They are usually locked if there was an error, so yes, you do need to stop it.
Jason Luboff
@JLuboff
May 24 2018 16:10
:+1:
Rajat
@rajataudichya
May 24 2018 16:10
@JLuboff I am continuously trying different methods actually the second loop what for that reason
Kudzu
@czhower
May 24 2018 16:10
Else it wont let you delete all the items in the queue.
Ronique Ricketts
@RoniqueRicketts
May 24 2018 16:10
@czhower I did that, yes its windows. Lol I can see the troubleshooters in the room :)
Rajat
@rajataudichya
May 24 2018 16:11
@JLuboff Even if I push the objects in an empty array the problem would still persist as I believe the loop is still running despite the objects not loading fully
Ronique Ricketts
@RoniqueRicketts
May 24 2018 16:11
@czhower ya I normally stop the spooler service and then clear the jobs manually from the system32> spool> printer folder
Kudzu
@czhower
May 24 2018 16:17
I have an HP laser that is such a PITA I have a bat file that does all 3 steps.
Ronique Ricketts
@RoniqueRicketts
May 24 2018 16:21
@czhower nice. I will get there one day. Created my own desktop helpers :)
Rajat
@rajataudichya
May 24 2018 16:25
I want the loop to iterate once all the data is received
Jason Luboff
@JLuboff
May 24 2018 16:27
@rajataudichya I'd recomend looking into promises, I believe $.getJSON supports them
Kudzu
@czhower
May 24 2018 16:34
If he uses promises, he will still possibly end up with data out of order that he wants or if used sequentially he will end up basically causing them to serialize which is the same as doing is sync.
So if he needs them ordered, he still has to store all then sort when all are complete, even with promises.
Jason Luboff
@JLuboff
May 24 2018 16:38
@czhower And I get that, I had already suggested prior to store them.
Kudzu
@czhower
May 24 2018 16:38
Sorry, I didnt see the earlier parts. Just wanted to make sure he understands.
ArchivalBoat50
@ArchivalBoat50
May 24 2018 18:28

Hey guys, I am doing the Seek and Destroy Algorithm challenge, and here is my code:

function destroyer(arr) {
  for (i=1; i<arguments.length; i++) {
    console.log(arguments[i]);
  }
  return arr.filter(arguments[i]);
  }


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

I do not know why the arr.filter(arguments[i]) is returning an undefined. Does someone mind explaining? I also tried doing arr.filter(x => x = arguments[i]) but that only return[]```.

Kudzu
@czhower
May 24 2018 18:29
because i after the for loop is out of range.
Jason Luboff
@JLuboff
May 24 2018 18:29
As well as each function has its own set of arguments
Kudzu
@czhower
May 24 2018 18:30
using non block variables in a for loop is frowned up on in most cases for this and other reasons.
Kudzu
@czhower
May 24 2018 18:36
Filter isnt being used correctly either unless arguments is an array of functions.
ArchivalBoat50
@ArchivalBoat50
May 24 2018 18:44

I did this now and it's returning [ 1, 2, 3, 1, 2, 3 ]

function destroyer(arr) {
  for (i=1; i<arguments.length; i++) {
    console.log(arguments[i]);
    return arr.filter(x => x = arguments[i]);
  }
  }


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

I don't fully understand what exactly an arrow function is, does anyone mind explaining my code and the arrow function?

Jason Luboff
@JLuboff
May 24 2018 18:49
@ArchivalBoat50 Again, arguments is not the same in two different functions. And I'd advise against using arrow functions until you're comfortable with regular function syntax
Essentially arrow functions is just a shorthand way of writing functions but with a few caveats
like this keyword does not work within a arrow function (there might be workarounds, not sure)
Kudzu
@czhower
May 24 2018 18:52
There are workarounds, I use them a lot. :)
the easiest is to declare a local/block var right before the arrow func line, ie
const xThis = this
and then you can use xThis in the arrow func.
Jason Luboff
@JLuboff
May 24 2018 18:53
@czhower Curious, can you show an example?
Kudzu
@czhower
May 24 2018 18:55
```
const xThis = this;
const x = arr.filter( x => x === xThis.something);
arrow funcs can access local and block vars, so if you do that, you save this in the context of the parent function into a local var, so the this scope problem is bypassed when the anon func is called.
Jason Luboff
@JLuboff
May 24 2018 18:58
But the parents function can't be an arrow function..can it? (Thats where I think I'm missing the idea behind this)
Kudzu
@czhower
May 24 2018 18:58
if the parent is an arrow func then you have to pass it in each time. I generally dont nest arrow funcs.
Its all about scope.
Jason Luboff
@JLuboff
May 24 2018 19:00
Ya. I infrequently use this so... I'm not the strongest with it
Kudzu
@czhower
May 24 2018 19:01
Since we have a custom framework and its using classes we use this quite a lot.
Jason Luboff
@JLuboff
May 24 2018 19:02
...classes...another thing I'm not the strongest at albeit C# helped reinforce that a bit (actually have to use classes there). I just don't really use them in JS (probably a fault of being self-taught)
Kudzu
@czhower
May 24 2018 19:03
If you are doing just web pages etc then becuase of how the DOM and events etc are its often counter productive for such code, but if you are building a large framework like we are, OOP is very useful.
Jason Luboff
@JLuboff
May 24 2018 19:04
Ya I'm pretty much solely web pages/API's with JS
Kudzu
@czhower
May 24 2018 19:04
OOP becomes more important as complexity increases. But most JS devs arent writing complex frameworks - they are writing dozens of mini loosely connected pieces.
Jason Luboff
@JLuboff
May 24 2018 19:04
C# I've only built an app with WinForm so had to use classes for that (create new forms, etc).
Kudzu
@czhower
May 24 2018 19:05
JS devs (in general) are like VB (pre .NET) devs. They USE objects (such as the DOM objects, etc) but generally dont build objects.
Jason Luboff
@JLuboff
May 24 2018 19:05
Ya... that sounds like me hah
Use objects all the time but see no reason to make an object construct
Kudzu
@czhower
May 24 2018 19:06
Its all about complexity. :) Once complexity increases, it makes a huge difference.
Jason Luboff
@JLuboff
May 24 2018 19:07
I'm working into the DB/Programming role here at my job....which is to replace the only other DB/programmer...so.. its only as complex as I make it
But... he is/was a VB programmer... which...as much as VB and C# is similar.. I much prefer C#. VB is just..nasty
Kudzu
@czhower
May 24 2018 19:08

OOP was designed to help with comlexity. The irony is that many JS devs have been told that OOP is evil and only creates complexity. Thats totally wrong, OOP helps SOLVE complexity. So of course in reality OOP solutions will be more complex because that is what they are designed for. But implementing those types of things without OOP is FAR more complex.

Some love to throw FP out there, but if you look at full size FP projects, they consume objects a lot and even build them too. Even F# works that way.

VB or VB.NET? They are different and only share a similar syntax. I prefer C# too but pre .NET and pre Delphi, ie early 90s, VB was one of the best things out their for apps so I used it for many years.
Jason Luboff
@JLuboff
May 24 2018 19:10
Mmm.. I guess it would be VB.NET
Kudzu
@czhower
May 24 2018 19:10
Despite is flaws, was still the only RAD tool of the time. VB 1.0 for DOS was amazing for its time.
VB.NET is a lot better than the old VB, but I still prefer C#.
Jason Luboff
@JLuboff
May 24 2018 19:11
Are you fairly well versed in C#? I may have to come to you in the future if oyu are
Kudzu
@czhower
May 24 2018 19:11
Yes. Im ex-Microsoft. :)
Jason Luboff
@JLuboff
May 24 2018 19:11
Good to know
Kudzu
@czhower
May 24 2018 19:13
And I still use C# extensively although the last 8 months Ive been almost exclusively in TypeScript (and a little PHP because of WordPress). But I will be moving back into C#, Delphi and others later this year.
Jason Luboff
@JLuboff
May 24 2018 19:14
I have to head out for a bit...but for a stand alone C# application.. what is your go to method for GUI? My first production application is using WinForm (I had rebuilt a VB app using C# and made modifications as asked by users), but I know WinForm is pretty dated and not the most customizable. I know there is WPF but wondering what you would use (I'm going to head out for a bit but I'll read your response when I get back)
Kudzu
@czhower
May 24 2018 19:14
JS classes are also very basic, TS really helps a lot if your goal is OOP. And you resuse all your JS knowledge as its a JS superset and all JS code still works.

WPF is a mess. Its very powerful but they never simplified essential parts. I gave up on WPF last year after 10 years in it. The new Metro (not called that any more) is where they are pushing things now.

But if you want simplicity, then WinForms works great but is being slowly phased out despite a lot of people still using it.

The new stuff doesnt work pre Win8 also though... so depends on your target.
I do mostly server side work, or low level stuff. If I have to do desktop UI work I now go back to Delphi. WinForms is basically a poormans copy of what Delphi's UI framework is (Largely because of Anders I'm sure being involved in both)
Delphi has its own shortcomings, but it can talk easily to .NET. So a C# backend and Delphi UI is now easy to do.
WPF is like WinForms 1.0 and all MS 1.0 products - simple things are too complex and they normally evolve by 3.0 as WinForms did.. but WPF never evolved very far and is still basically a 1.0/2.0 product and now that they are focusing on the new Windows Store type apps, WPF is basically in maintainance mode at best with no real evolutions coming and only small improvements.
Kudzu
@czhower
May 24 2018 19:20
Simply adding a hotkey to a button or menu item in WPF will drive you nuts. Its so designer biased and almost MVVM exclusive - if you want to do something other than MVVM, it will drive you insane working around things that are hardcoded around MVVM. Things that in Winforms are 1 line of code can easily be 40 in WPF.
Avalonia an open source "replacement" for WPF looks promising, but its not ready for prime time yet.
If you are interested in OOP or basic type safety, check out TypeScript. It lets you reuse all your JS and all your JS knowledge but adds a lot of new functionality. Its JS++
Kudzu
@czhower
May 24 2018 19:27
@ArchivalBoat50 Are you still stuck or did you make progress?
anthonygallina1
@anthonygallina1
May 24 2018 19:45
MSDOS?
:)
Hi
Gulsvi
@gulsvi
May 24 2018 19:46
echo hello
hello
:grin:
anthonygallina1
@anthonygallina1
May 24 2018 19:46
:smile:
Joseph
@revisualize
May 24 2018 19:56
Hi.
Jason Luboff
@JLuboff
May 24 2018 20:34
@czhower Thanks for the info. I had previousily read that WPF is overly complicated to do basic things and based on what you said, I'll bypass it as WinForms is rather easy which is nice. You mention Delphi, I've never heard of it. Is this what you're refering to: https://www.embarcadero.com/products/delphi ? Don't think my company will pony up $1500 heh (I'm going to be building mostly web based apps anyhow). Might end up looking into Electron but I like some of the features of Winforms + C# when working with certain SQL data
CamperBot
@camperbot
May 24 2018 20:34
jluboff sends brownie points to @czhower :sparkles: :thumbsup: :sparkles:
:cookie: 106 | @czhower |http://www.freecodecamp.org/czhower
Kudzu
@czhower
May 24 2018 20:59
yeah, Delphi is pricey and its a whole other language, so unless you already know it or are a small shop looking for good desktop dev, its a hard sell.
Jason Luboff
@JLuboff
May 24 2018 21:03
Definitely don't know it :smile: I'll stick with WinForms for now
anthonygallina1
@anthonygallina1
May 24 2018 21:05
@JLuboff I have a old version on a win2000 machine I keep around I think I got delphi for 200 dollars back then.
Jason Luboff
@JLuboff
May 24 2018 21:06
Dang haha
anthonygallina1
@anthonygallina1
May 24 2018 21:06
Keep it to run old software Some of my graphics programs were pricy
Jason Luboff
@JLuboff
May 24 2018 21:06
I had a lot of programs that were... ahem found on the floor
anthonygallina1
@anthonygallina1
May 24 2018 21:08
I still have a data program I did in dos on floppy LOL
This wouldnt be good enough for work But did you know about it? https://www.embarcadero.com/products/delphi/starter/free-download
Jason Luboff
@JLuboff
May 24 2018 21:12
@anthonygallina1 I was trying to find it but from the link I posted above when you click on starter it just takes you to the pricing page lol
anthonygallina1
@anthonygallina1
May 24 2018 21:12
I hate that Interface wading
Jason Luboff
@JLuboff
May 24 2018 21:15
Yup
Kudzu
@czhower
May 24 2018 21:19
Disclaimer - Im essentially ex-Borland (never FTE though) and have written significant parts of it which are still used today in it.
Starter has revenue limits, I think after you make $1000 or so you have to buy a bigger version.
WinForms will be fine if you arent doing anything to advanced.
Gulsvi
@gulsvi
May 24 2018 21:23
Another fun challenge for anyone who might be bored :) Convert an array of digits to a number:
Example Input: [5, 3, 2, 8, 1]
Expected Output: 53281
Might not be as easy as it seems at first glance :wink:
Jason Luboff
@JLuboff
May 24 2018 21:29
@gulsvi console.log(arr.reduce( ( a, b) => a.toString() + b.toString()))
Moisés Man
@moigithub
May 24 2018 21:29
+[5, 3, 2, 8, 1].join("")
Gulsvi
@gulsvi
May 24 2018 21:29
@JLuboff yours returns a string I believe
@moigithub Yours works as a number, but not for larger arrays, like: [2, 4, 7, 2, 1, 2, 5, 4, 5, 6, 4, 8, 3, 2, 2, 3, 8, 3, 1, 2]
Jason Luboff
@JLuboff
May 24 2018 21:31
@gulsvi So than console.log(Number(arr.reduce( ( a, b) => a.toString() + b.toString()))) :P
Gulsvi
@gulsvi
May 24 2018 21:31
These can be such a pain lol, but try that with the larger array
Brad
@bradtaniguchi
May 24 2018 21:34
How come @JLuboff's solution doesn't work with a larger array?
Id do the same but with a + '' + b in my reduce
Moisés Man
@moigithub
May 24 2018 21:36
Number.MAX_SAFE_INTEGER
//9007199254740991
Jason Luboff
@JLuboff
May 24 2018 21:36
@bradtaniguchi Thats a cleaner solution actually
Moisés Man
@moigithub
May 24 2018 21:36
Javascript dont support BigInt yet
probably will need a external library
Brad
@bradtaniguchi
May 24 2018 21:37
ah so the number gets to "big" haha
Gulsvi
@gulsvi
May 24 2018 21:37
Yeah, it's a stupid javascript thing - not a very fun challenge. That was a bit misleading lol
Brad
@bradtaniguchi
May 24 2018 21:38
Yea I mean, we finished the challenge, but JS breaks in an extreme use case, not my problem :P
Gulsvi
@gulsvi
May 24 2018 21:41
Maybe a better challenge if we have to add one to the final number created, but output as a string
I have to pack and head home, maybe I'll have some more fun and exciting challenges next week lol
Brad
@bradtaniguchi
May 24 2018 21:44
hehe alright
Jason Luboff
@JLuboff
May 24 2018 21:52
I hate testing emailing. Lol I have everything routed to my email so I just bombard myself