Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
eisenhiem775y@SortOfTested it is a problem for me :'(
JS is kinda of a new world to me, and i only need to program in it for the bootcamp project i am doing. I am mostly used to programming languages for scientific computing in the past. Matlab/FORTRAN earlier, and now Python etc. -
-
eisenhiem775y@C0D4 Its hard to explain!
maybe this helps?
//source: https://gist.github.com/tleen/...
var states = ['Alabama', 'Alaska', 'American Samoa', etc etc...
// Initialize totalCasesPerState with 0
// Copy array and set it to zero
var totalCasesPerState = [...states];
totalCasesPerState.fill(0);
for (let idx = 0; idx < array.length; idx++) {
// console.log(`${array[idx].Province}: ${array[idx].Cases}`);
var stateIndex = states.indexOf(array[idx].Province);
if (stateIndex > -1) {
totalCasesPerState[stateIndex] = totalCasesPerState[stateIndex] + array[idx].Cases;
}
} -
C0D4669025y@eisenhiem it feels like your trying to achieve this?
https://gist.github.com/C0D4-101/...
add your data set to a list of all regions/states? -
Array.slice() and you get your copy.
Side note : seriously? Are we gonna use the "copy vs reference" as an argument against js? Have we gone that low?
Almost all languages have that. For good reasons!
Check how computer memory works and all will be explained. -
eisenhiem775y@react-guy yeah well i didnt know this because in all other languages known to man (a man like me) you can just make a copy by doing array1 = array2 and ser array1 to zero and be sure that array2 wouldnt have been changed. Sorry if i offended anybody. Not my intention :(
-
@eisenhiem don't worry, not offended 😉 just joking.
However, almost all the languages I know also use arrays as reference (Java, C/C++, idk about php...).
Which languages do not?
Related Rants
Because JS is not like any other freaking language previously known to man! :/
rant
js