Algorithm - The Office VI Sabbatical

Description

https://www.codewars.com/kata/57fe50d000d05166720000b1/train/javascript

val=your value to the organisation
happ=her happiness level at the time of asking and finally
The numbers of letters from ‘sabbatical’ that are present in string ‘x’.

If the sum of the three parameters (as described above) is > 22, return ‘Sabbatical! Boom!’, else return ‘Back to your desk, boy.’. memory?

Read More

JavaScript 在字符串前面的加号+

加法运算符会触发三种类型转换:

  • 转换为原始值
  • 转换为数字
  • 转换为字符串

基本数据类型转换:

1、将数值转换成字符串toString()

    格式:数值变量名.toString()

2、将字符串转换成整型parseInt()

    注意点:字符串第一个字符只能为数字 如果不是数字 会报NaN (Not a Number);

    格式:parseInt(字符串变量名)

3、将字符串转换成浮点型 pareFloat()

    格式:parseFloat(数值变量名)

Read More