📄 char-at.js
字号:
// create and initialize two string variables
var str = "linger in", newstr = "";
// get the first and last letters of the str variable
var a = "First letter : " + str.charAt(0);
var z = "Final letter : " + str.charAt( str.length -1 );
// loop through each character and copy into newstr
// unless it's an i - then copy an o into newstr
for( var i = 0; i < str.length; i++ )
{
if( str.charAt(i) != "i" ) newstr += str.charAt(i);
else newstr += "o";
}
// display newstr and the first and last letters of str
var result = "STRINGS\n\n";
result += "New string : " + newstr + "\n";
alert( result + a + "\n" + z );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -