I am new to scripting and I am trying to determine the length of a sentence within a cell in Google Sheets. For example, if the sentence "I want to check the length" is in cell A1, I want to know how many characters are in the sentence.
Additionally, if I want to replace spaces (" ") with another character, such as a plus sign (+), I have used the following script:
var newdata = olddata.toString().replace(" ","+");
// In this case, olddata refers to the string "I want to check length"
// The output displayed in the log is "I+want to check length"
// However, I would like the output to be "I+want+to+check+length"
When I use this script, I notice that only the first space is being replaced in the entire string or sentence. How can I modify my code to replace all spaces with the desired character?