我正在尝试为谷歌表制作一个脚本,谁可以计算文本中的一个字母。但似乎 .length 不起作用。任何可以就在哪里找到解决方案提供指导的人。
function Tjekkode(tekst , bogstav){
var test = "";
// find the length of laengdeTekst
var laengdeTekst = tekst.length;
var t = 0;
// through the text character by character
for ( var i = 1; i<laengdeTekst ; i++) {
var test = tekst.substr(i,1);
if (test == bogstav) {
// if the letter is found, it is counted up
// REMEMBER == means compare
var t = t + 1;
}
}
// returns percent appearance of the …Run Code Online (Sandbox Code Playgroud)