Giter Club home page Giter Club logo

Comments (12)

RoseStory avatar RoseStory commented on July 21, 2024 2

q3:
var str = '123456789', arr = [], result;
for(var i = 0, len = str.length; i <len; i += 3) {
var num = +str.substring(i, i+3);
//var num = +str.substr(i, 3);
arr.push(num);
}
result = arr.join(',');

from blog.

SnailSword avatar SnailSword commented on July 21, 2024 1

q3的抖机灵方法:

function (num) {
    return num.toLocalString();
}

from blog.

iCodeBIT avatar iCodeBIT commented on July 21, 2024

q3可以考虑递归.

from blog.

Aaaaaaaty avatar Aaaaaaaty commented on July 21, 2024

@iCodeBIT 我试试看~

from blog.

lkoma avatar lkoma commented on July 21, 2024

q3
function cal(num) {
return num.toLocaleString();
}

from blog.

Aaaaaaaty avatar Aaaaaaaty commented on July 21, 2024

@oceanaly cool

from blog.

weik7313 avatar weik7313 commented on July 21, 2024
function foo (str) {
  str = str + ''
  return str.split('').reverse().map((item, key) => {
    if ((key + 1) % 3 === 0 && key !== str.length - 1) return ',' + item
    else return item
  }).reverse().join('')
}

单纯的改造q3

from blog.

Aaaaaaaty avatar Aaaaaaaty commented on July 21, 2024

@weik7313 正则/\B(?=(\d{3})+\b)/g或者toLocalString也不错

from blog.

weik7313 avatar weik7313 commented on July 21, 2024

@Aaaaaaaty 是的 方法很多 我这个是改你文章里的思路 换api

from blog.

Aaaaaaaty avatar Aaaaaaaty commented on July 21, 2024

@weik7313 嗯嗯 很链式哈哈

from blog.

jawil avatar jawil commented on July 21, 2024

打听一下,博主最后去了阿里吗?😂

from blog.

Aaaaaaaty avatar Aaaaaaaty commented on July 21, 2024

@jawil 大佬你都没进去 我咋进😂

from blog.

Related Issues (20)

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.