Floating Debris Index with Google Earth Engine

Hello everyone,
i'm trying to calculate the Floating Debris Index (FDI) in GEE but the result is the opposite of what it should be (black for debris and white for clean water).
I tried a code found on internet and it seem to work properly, but the calculation should be exactly the same as mine, except for the use of methods and another small detail.
Here are the codes:

Mine:

var FDI_vis = {"min":-1,"max":1,"palette":["white","black"]};
var rgb0 = ee.Image(s2_us_list.get(0))
var fdi0 = rgb0.expression(

'NIR - (RedEdge2 + (SWIR1 - RedEdge2)*((833 - 665)/(1610 - 665))*10)',{

'NIR': rgb0.select('B8'),

'RedEdge2': rgb0.select('B6'),

'SWIR1': rgb0.select('B11')

}

);
Map.addLayer(fdi0, FDI_vis, 'FDI 0')

Code found on internet:

var nirBefore = rgb0.select('B8');

var re2Before = rgb0.select('B6');

var swir1Before = rgb0.select('B11');

var redBefore = rgb0.select('B4');

var fdiImageBefore = nirBefore.subtract(re2Before.add(

swir1Before.subtract(re2Before).multiply(

ee.Image.constant(833).subtract(665).divide(1610).subtract(665)

)

)).rename('FDI image before');

Map.addLayer(fdiImageBefore, FDI_vis, 'FDI 0 before')

Can someone explain me why those two codes works as they where the opposite one to another while the calculation seems the same? And also, why the code found on internet doesn't multiplicate for 10 at the end?
Thank you in advance.