jajaplus / blog

0 stars 0 forks source link

ARTS 第二十三周(2019.12.02-2019.12.08) #24

Open jajaplus opened 4 years ago

jajaplus commented 4 years ago

算法

https://leetcode-cn.com/problems/integer-to-roman/submissions/

/**
 * @param {number} num
 * @return {string}
 */
var intToRoman = function(num) {
  let Rnum = ''
  function changeRnum(number,one='',five='',ten=''){
      switch(number){
          case 9:
          Rnum+=(one+ten)
          break
          case 8:
          Rnum+=(five+one+one+one)
          break
          case 7:
          Rnum+=(five+one+one)
          break
          case 6:
          Rnum+=(five+one)
          break
          case 5:
          Rnum+=five
          break
          case 4:
          Rnum+=(one+five)
          break
          case 3:
          Rnum+=(one+one+one)
          break
          case 2:
          Rnum+=(one+one)
          break
          case 1:
          Rnum+=one
          break
          case 0:
          break
      }
  }
  let thousand = parseInt(num/1000)
  changeRnum(thousand,'M')
  let hundred = parseInt(num/100)
  changeRnum(hundred%10,'C','D','M')
  let ten = parseInt(num/10)
  changeRnum(ten%10,'X','L','C')
  let one = num%10
  changeRnum(one,'I','V','X')
  return Rnum
};

通过判断和传参,来进行修改

阅读

https://www.freecodecamp.org/news/the-last-ten-years-or-how-to-get-better-at-anything/

  1. 独立完成任务
  2. 做记录
  3. 做分享

    技巧(中间层)

    中间层可以帮助我们在数据产生变化的时候进行判断来决定是否要进行操作。 需要加中间层:数据改变,主题,http,消息,网关

    分享(webpack优化)

    https://www.toutiao.com/a6775483622695633419/?tt_from=weixin&utm_campaign=client_share&wxshare_count=1&timestamp=1577580767&app=news_article&utm_source=weixin&utm_medium=toutiao_android&req_id=2019122908524601002607720537D01ADC&group_id=6775483622695633419

  4. 采用插件(happypack,)
  5. include,exclude
  6. 抽离第三方模块
  7. 配置缓存 (加线程,优化打包,确定打包文件)