Matt Carter
11/29/2023, 3:08 PMconst val1 = 172.5 + Math.ceil((445200 - 100000) / 100) * 100 / 1000 * 1.5
const val2 = 172.5 + Math.ceil((445000 - 100000) / 100) * 100 / 1000 * 1.5
console.log(val1)
console.log(val2)
Results:
PS C:\Users\mcarter\Documents\VsCode\netsuite investigate> node .\test2.js
690.3
690Mike Robbins
11/29/2023, 3:10 PMMatt Carter
11/29/2023, 3:11 PMShawn Talbert
11/29/2023, 5:15 PMalien4u
11/29/2023, 5:29 PMalien4u
11/29/2023, 5:30 PMShawn Talbert
11/29/2023, 5:32 PMreturn statement as it's implied.alien4u
11/29/2023, 5:43 PMreturn for code readability and maintenance.Shawn Talbert
11/29/2023, 7:16 PMfunction statements.Shawn Talbert
11/29/2023, 7:17 PMShawn Talbert
11/29/2023, 7:43 PMShawn Talbert
11/29/2023, 7:44 PMalien4u
11/29/2023, 7:50 PM=> with {} and return is perfectly valid syntax, and you sort of keep a consistent coding standard with your old code base without having to use the old function initialization.
I use this also as a way to identify and/or isolate 2.1 code from 2.0 code without having to scroll up to check.
I take advantage of everything related to ES6 in 2.1, with the only exception of keeping {} and return again for code readability purposes.alien4u
11/29/2023, 7:56 PMconsole.log("Hello, world! " + 123);
⢠Developer Two: console["\x6C\x6F\x67"]("\x48\x65\x6C\x6C\x6F\x2C\x20\x77\x6F\x72\x6C\x64\x21\x20"+ 123)
I'm hiring Developer One without a doubt, and I couldn't care less how smart Developer Two thinks he is.Shawn Talbert
11/29/2023, 9:05 PMconst roundByExponent = (pValue, pDecimals) => { is at all easier to read/understand than function roundByExponent (pValue, pDecimals) {Shawn Talbert
11/29/2023, 9:07 PMfunction keyword it's clear you're talking about a function definition - with the other syntax you're assigning a variable who's value happens to be a function.Shawn Talbert
11/29/2023, 9:09 PMfunction statements for functions, with the notable exception of predicate/iteratee type functions which are often clearest as one-line arrow functions. e.g. _.filter(so.item, line => line.quantity > 10)Shawn Talbert
11/29/2023, 9:09 PMalien4u
11/29/2023, 9:12 PM{} and return are not the only differences between function and => , yes I do want to keep consistency as much as I can between 2.0 and 2.1 without sacrificing what I get with => as restrictions of this, and other things. Nice chat!...Shawn Talbert
11/29/2023, 9:15 PMthis is important, but I rarely see SuteScript code in the wild actually referring to this or making assumptions about it. I've asked on this forum a couple times and it seems this is mostly avoided by SuiteScript devs (probably for the best, most of the time)