GithubHelp home page GithubHelp logo

logic-training's Introduction

Hi there 👋

I’m currently working on Tencent
I’m currently learning Node、TS
I’m looking to collaborate on Vue

logic-training's People

Contributors

erbing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

logic-training's Issues

[JS] 事件委托考察

<ul>
  <li class='target'>
      <span>test</span>
 </li>
</ul>
  1. 点击classtargetli可以 alert 出其所含内容(如上方代码点击弹出“test”)
  2. ul动态新增li元素的情况下,也要有相同效果
  3. 使用原生js实现,不使用jQuery\Vue\React\Angular 等框架

实现0和1的排列组合

要求:给定一个组合长度,输出由0和1在该长度内排列组合形成的二维数组。
例如:

function getArr( size ){
    //TODO - 完成该方法
}

var arr = getArr(4);  //给定组合长度为4
console.log( JSON.stringify(arr) );
/** 打印出:
[[0,0,0,0],[0,0,0,1],[0,0,1,0],[0,0,1,1],[0,1,0,0],[0,1,0,1],[0,1,1,0],[0,1,1,1],
[1,0,0,0],[1,0,0,1],[1,0,1,0],[1,0,1,1],[1,1,0,0],[1,1,0,1],[1,1,1,0],[1,1,1,1]]
****/

原生JS 实现 Promise 类

/*
*   原生JS 实现 Promise 类 ( class )
*   1、基本能力实现
*   2、状态的管理
*   3、链式调用 的实现
*/

class Promise {
  constructor() {
    // todo
  }
  then() {
    // todo
  }
}

排列组合矩阵实现

有这么几个变量:

  • a 其值可能为 0、1
  • b 其值可能为 3、4、5
  • c 其值可能为 6、7

实现一个函数 getArranging 可以返回它们的可能值的排列组合二维数组:

function getArranging( ){
      //TODO - 返回参数的排列组合
}

var a = [0, 1];
var b = [3, 4, 5];
var c = [6, 7];

var ret = getArranging( a, b, c );
// ret 值为:
/**
[ [0,3,6], [0,3,7], [0,4,6], [0,4,7], [0,5,6], [0,5,7], [1,3,6], [1,3,7], [1,4,6], [1,4,7], [1,5,6], [1,5,7] ]
**/

根据2019年 新个税政策计算,实现 每月个人应缴纳 个人所得税

/* 
 * 根据2019年 新个税政策计算,每月个人应缴纳 个人所得税
 * e.g.
 * // 年收入
 * const yearIncome = [36000, 144000, 300000, 420000, 660000, 960000]
 * // 对应不同阶段的税率
 * const newTax = [3, 10, 20, 25, 30, 35, 45]
 * 
 * 是否有 专项扣除
 * const  deduct = []
 * 
 * calculateTax(salary, deductType)
 * 
 * salary: 月薪
 * deductType: 专项扣除类型,如果无 则为 0
 */

 // 专项扣除 amount 代表每月 金额

const  deduct = [
    {
        name: '子女教育',
        type: 1,
        amount: 1000
    },
    {
        name: '继续教育',
        type: 2,
        amount: 400
    },
    {
        name: '住房贷款利息',
        type: 3,
        amount: 1000
    },
    {
        name: '住房租金',
        type: 4,
        amount: 1500
    },
    {
        name: '赡养老人',
        type: 5,
        amount: 2000
    },
    {
        name: '大病医疗',
        type: 6,
        amount: 6000
    }
]

 const calculateTax = (salary, deductType) => {
    // todo
 }

用JS实现身份证正确性校验(仅限身份证长度为18位的)

const getIdCard = () => {
  const idCard = '42062419921218761X'
  const computingCoefs = '7-9-10-5-8-4-2-1-6-3-7-9-10-5-8-4-2'.split('-')
  const mapY = '0-1-2-3-4-5-6-7-8-9-10'.split('-')
  const mapLastNumber = '1-0-X-9-8-7-6-5-4-3-2'.split('-')
 //  todo ...
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.