I have string that exist in array as follow
getid Array [
"E8R52y6dD8XI3shXhnhS9pVzUpe26Lf5bHwzCSbI2bmoMv7KuduMGwe2",
]
I want to exclude this part E8R52y6dD8XI3shXhnhS9pVzUpe2 from that ,
actually E8R52y6dD8XI3shXhnhS9pVzUpe2 this is user.uid .
this is two user id combine id "E8R52y6dD8XI3shXhnhS9pVzUpe26Lf5bHwzCSbI2bmoMv7KuduMGwe2"
this combine id exist in arrays.
so many combine id will has in this array.
I want to exclude user.uid E8R52y6dD8XI3shXhnhS9pVzUpe2 from all combine id .
if exclude user.uid , there will be remain one id part in this array.
I want to get this remain part of id value to use.
let userid = E8R52y6dD8XI3shXhnhS9pVzUpe2
let combineId = ["E8R52y6dD8XI3shXhnhS9pVzUpe26Lf5bHwzCSbI2bmoMv7KuduMGwe2","E8R52y6dD8XI3shXhnhS9pVzUpe26Lh5bHrzCSvI2bmoMv7KuduMGwe2","E8R52y6dD8XI3shXhnhS9pVzUpe26Lf5bHwzCSbI2bmoMv7KuduMGwe2"]
// this is value what i want
let remainIdinArray = ["6Lf5bHwzCSbI2bmoMv7KuduMGwe2","6Lh5bHrzCSvI2bmoMv7KuduMGwe2","6Lf5bHwzCSbI2bmoMv7KuduMGwe2"]
how can do that.
thanks
>Solution :
You can use the map and the slice!
let userid = "E8R52y6dD8XI3shXhnhS9pVzUpe2";
let combineId = [
"E8R52y6dD8XI3shXhnhS9pVzUpe26Lf5bHwzCSbI2bmoMv7KuduMGwe2",
"E8R52y6dD8XI3shXhnhS9pVzUpe26Lh5bHrzCSvI2bmoMv7KuduMGwe2",
"E8R52y6dD8XI3shXhnhS9pVzUpe26Lf5bHwzCSbI2bmoMv7KuduMGwe2"
];
let remainIdinArray = combineId.map((id) => id.slice(-userid.length));
console.log(remainIdinArray);