20170816
#132 Comment your JavaScript Code
JavaScript的注释
//这是一个JavaScript的注释
/*这是一个JavaScript的
段落注释
*/
#133 Declare JavaScript Variables
创建JavaScript变量
var myName;
#134 Storing Values with the Equal Operator
给变量赋值
a = 7;
b = a;
#135 Initializing Variables with the Equal Operator
用var初始化变量值
var a = 9;
#136 Understanding Uninitialized Variables
修改a,b,c并分别赋值
var a = 5;
var b = 10;
var c ="I am a";
#137 Understanding Case Sensitivity in Variables
驼峰命名法,这节培养程序员写代码的基础规范,养成良好的命名规范才能减少将来自己的麻烦.这一节建议大家仔细找找变量名的问题,不要拷贝粘贴
var studlyCapVar;
var properCamelCase;
var titleCaseOver;
// 给变量赋值
studlyCapVar = 10;
properCamelCase = "A String";
titleCaseOver = 9000;
#138 Add Two Numbers with JavaScript
JavaScript做加法
var sum = 10 + 10;
#139 Subtract One Number from Another with JavaScript
JavaScript减法
var difference = 45 - 33;
#140 Multiply Two Numbers with JavaScript
JavaScript乘法
var product = 8 * 10;
#141 Divide One Number by Another with JavaScript
JavaScript除法
var quotient = 66 / 33;
#142 Increment a Number with JavaScript
变量自增
myVar++;
#143 Decrement a Number with JavaScript
变量自减
var myVar = 11;
// 请只修改这条注释以下的代码
myVar--;
#144 Create Decimal Numbers with JavaScript
赋值浮点数
var myDecimal = 5.7;
#145 Multiply Two Decimals with JavaScript
两个小数相乘
var product = 2.0 * 2.5;
#146 Divide one Decimal by Another with JavaScript
小数除法
var quotient = 4.4 / 2.0;
#147 Finding a Remainder in JavaScript
取余
var remainder = 11%3;
#150 Assignment with Plus Equals
运用+=运算符
a += 12;
b += 9;
c += 7;
#151 Assignment with Minus Equals
运用-=运算符
a-=6;
b -= 15;
c -= 1;
#152 Assignment with Times Equals
运用*=运算符
a *= 5;
b *= 3;
c *= 10;
#153 Assignment with Divided by Equals
运用 /= 运算符
a /= 12;
b /= 4;
c /= 11;
#154 Convert Celsius to Fahrenheit
把摄氏度改成华氏度(我觉得我写的可能有问题,不过还是通过了)
function convert(celsius) {
// 请把你的代码写在这条注释以下
var fahrenheit = celsius * 9 / 5 + 32;
#155 Declare String Variables
字符串赋值
var myFirstName = "wang";
var myLastName = "cong";
#156 Escaping Literal Quotes in Strings
转义符号"\"
var myStr = "I am a \"double quoted\" string inside \"double quotes\"";
#157 Quoting Strings with Single Quotes
修改代码,去掉转义符号,将双引号改为单引号,也就是说单引号里面的字符串中,增加双引号是不用写转义字符的.
var myStr = '<a href="http://www.example.com" target="_blank">Link</a>'
#158 Escape Sequences in Strings
用转义符按顺序输入符号
var myStr="\\ \t \b \r \n"; // 请修改这一行
#159 Concatenating Strings with Plus Operator
+为连接符号(这里注意This is the start.后面有个空格)
var myStr = "This is the start. "+"This is the end.";
#160 Concatenating Strings with the Plus Equals Operator
用+=运算符连接字符串
var myStr = "This is the first sentence. ";
myStr += "This is the second sentence.";