I want to iterate an array of strings and replace each element with another string:
let arr = ["-","-","-"]
let spaceArr = replaceStringArr.forEach(replaceDash)
const replaceDash = function(index:any, array:any){
// replace the value of each element containing "-" with " "
I have tried
return array[index] = " "
and
array[index] = " "
}
I have tried:
const replaceDash = function(index: any, array: any) {
return array[index] = " "
}
as well as:
const replaceDash = function(index: any, array: any) {
array[index] = " "
}
But I am getting a:
TypeError: Cannot create property '-' on number '0'