var myVar =87;// Only change code below this line
myVar++;
JavaScript自减运算–
var myVar =11;// Only change code below this line
myVar--;
JavaScript浮点数
var ourDecimal =5.7;// Only change code below this linevar myDecimal =5.7;
JavaScript小数乘法运算
var product =2.0*2.5;
JavaScript小数的除法运算
var quotient =4.4/2.0;
JavaScript取余运算%
// Only change code below this linevar remainder =11%3;
JavaScript +=赋值操作
var a =3;var b =17;var c =12;// Only modify code below this line
a +=12;
b +=9;
c +=7;
JavaScript -=赋值操作
var a =11;var b =9;var c =3;// Only modify code below this line
a -=6;
b -=15;
c -=1;
JavaScript *=赋值操作
var a =5;var b =12;var c =4.6;// Only modify code below this line
a *=5;
b *=3;
c *=10;
JavaScript /=赋值操作
var a =48;var b =108;var c =33;// Only modify code below this line
a /=12;
b /=4;
c /=11;
JavaScript 基本运算综合练习
functionconvert(celsius){// Only change code below this line
fahrenheit = celsius*9/5+32;// Only change code above this linereturn fahrenheit;}// Change the inputs below to test your codeconvert(30);
JavaScript 声明字符串变量
// 举例var firstName ="Alan";var lastName ="Turing";// Only change code below this linevar myFirstName ="Alan";var myLastName ="Turing";
JavaScript 转义字符串中的引号
var myStr ="I am a \"double quoted\" string inside \"double quotes\"";// Change this line
JavaScript 使用单引号引用字符串
var myStr ='<a href="http://www.example.com" target="_blank">Link</a>';
JavaScript 转义字符串中的特殊符号
var myStr ='\\ \t \r \n';
JavaScript字符串连接方式
// 举例var ourStr ="I come first. "+"I come second.";// Only change code below this linevar myStr ="This is the start. "+"This is the end.";
JavaScript +=连接字符串操作
// 举例var ourStr ="I come first. ";
ourStr +="I come second.";// Only change code below this linevar myStr ="This is the first sentence. ";
myStr +="This is the second sentence.";
JavaScript 使用变量连接字符串
// 举例var ourName ="Free Code Camp";var ourStr ="Hello, our name is "+ ourName +", how are you?";// Only change code below this linevar myName="Free Code Camp";var myStr="Hello, our name is "+ myName +", how are you?";
JavaScript 追加变量到字符串上
// 举例var anAdjective ="awesome!";var ourStr ="Free Code Camp is ";
ourStr += anAdjective;// Only change code below this linevar someAdjective ="awesome!";var myStr ="Learning to code is ";
myStr += someAdjective;