Google Earth Engine JavaScript API – Combine Number and String

google-earth-enginegoogle-earth-engine-javascript-api

I am trying to combine an extracted number with a string through the below code in Google Earth Engine Java Script but it does not work. Does anyone has any idea?

code link: https://code.earthengine.google.com/2c3fec1bf89ea9e43ef1fe9058d16164

var number = 0.2;
var val2  = ee.Number(number).format().slice(2); 

var string = 'test';

var combine = string + val2

print(combine)

Best Answer

By using exclusively GEE class methods, following script works as expected:

var number = 0.2;
var val2  = ee.Number(number).format().slice(2); 

print("val2", val2);

var string = 'test';

var combine = ee.String(string).cat(val2);

print(combine);

It is printed in Tab console:

val2
2
test2