glutonium
glutonium
KPCKevin Powell - Community
Created by Dovah on 6/30/2024 in #front-end
How to get to differently named array-items when iterating over the whole array?
oops, u already got the solution sorry
87 replies
KPCKevin Powell - Community
Created by Dovah on 6/30/2024 in #front-end
How to get to differently named array-items when iterating over the whole array?
basically the key would be the property name (which can be fra, en, ita etc), and value is the object it holds
87 replies
KPCKevin Powell - Community
Created by Dovah on 6/30/2024 in #front-end
How to get to differently named array-items when iterating over the whole array?
No description
87 replies
KPCKevin Powell - Community
Created by Dovah on 6/30/2024 in #front-end
How to get to differently named array-items when iterating over the whole array?
@Dovah
const data = {
name: {
common: "common name",
nativeName: {
fra: {
common: "desired name",
official: "other stuff"
},
test: {
name: "random data"
}
}
}
}

const [key, value] = Object.entries(data.name.nativeName)[0];

console.log(key, value)
const data = {
name: {
common: "common name",
nativeName: {
fra: {
common: "desired name",
official: "other stuff"
},
test: {
name: "random data"
}
}
}
}

const [key, value] = Object.entries(data.name.nativeName)[0];

console.log(key, value)
87 replies
KPCKevin Powell - Community
Created by Dovah on 6/30/2024 in #front-end
How to get to differently named array-items when iterating over the whole array?
u still need to name the object
87 replies
KPCKevin Powell - Community
Created by Dovah on 6/30/2024 in #front-end
How to get to differently named array-items when iterating over the whole array?
nvm won't work
87 replies
KPCKevin Powell - Community
Created by Dovah on 6/30/2024 in #front-end
How to get to differently named array-items when iterating over the whole array?
ig just deconstruct?
87 replies
KPCKevin Powell - Community
Created by Vandana on 6/27/2024 in #front-end
variables inside the function and order of Precedence in JS
const cond1 = age <= 6 && ; // add further conditions if u want
const cond2 = age >= 65 && !isHoliday;
if(cond1 || cond2) {...}
const cond1 = age <= 6 && ; // add further conditions if u want
const cond2 = age >= 65 && !isHoliday;
if(cond1 || cond2) {...}
76 replies
KPCKevin Powell - Community
Created by Vandana on 6/27/2024 in #front-end
variables inside the function and order of Precedence in JS
break it further down if u want
76 replies
KPCKevin Powell - Community
Created by Vandana on 6/27/2024 in #front-end
variables inside the function and order of Precedence in JS
but if u wanna do more check just add
76 replies
KPCKevin Powell - Community
Created by Vandana on 6/27/2024 in #front-end
variables inside the function and order of Precedence in JS
i broke down this code, and here it doesn't check if age <= and if it's a holiday or not
76 replies
KPCKevin Powell - Community
Created by Vandana on 6/27/2024 in #front-end
variables inside the function and order of Precedence in JS
like for example u r trying to check for box collision for your game, that requires 4 conditions. on top if u need to add extra conditions like is the item red coloured that's 5 total. instead of having all 5 conditions at once u can break it down
const isColliding = ; // the 4 conditions to check for collision
if( isColliding && item.color === "red" ){...}
const isColliding = ; // the 4 conditions to check for collision
if( isColliding && item.color === "red" ){...}
76 replies
KPCKevin Powell - Community
Created by Vandana on 6/27/2024 in #front-end
variables inside the function and order of Precedence in JS
like this is something i also do when i have a bunch of conditions
76 replies
KPCKevin Powell - Community
Created by Vandana on 6/27/2024 in #front-end
variables inside the function and order of Precedence in JS
const cond1 = age >= 65 && !isHoliday;
if(age <= 6 || cond1) {...}
const cond1 = age >= 65 && !isHoliday;
if(age <= 6 || cond1) {...}
76 replies
KPCKevin Powell - Community
Created by Vandana on 6/27/2024 in #front-end
variables inside the function and order of Precedence in JS
btw u can also break up conditions if u want
76 replies
KPCKevin Powell - Community
Created by Vandana on 6/27/2024 in #front-end
variables inside the function and order of Precedence in JS
ya i agree
76 replies
KPCKevin Powell - Community
Created by Vandana on 6/27/2024 in #front-end
variables inside the function and order of Precedence in JS
but u can override it by using brackets
76 replies
KPCKevin Powell - Community
Created by Vandana on 6/27/2024 in #front-end
variables inside the function and order of Precedence in JS
when it comes to conditionals normally AND operation (&&) is evaluated before an OR (||)
76 replies
KPCKevin Powell - Community
Created by Vandana on 6/27/2024 in #front-end
variables inside the function and order of Precedence in JS
Bracket Division Multiplication Addition Subtraction
76 replies
KPCKevin Powell - Community
Created by Vandana on 6/27/2024 in #front-end
variables inside the function and order of Precedence in JS
i mean this is just the same ol' BDMAS rule
76 replies