Hi FE !
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub

##S009-随机生成指定长度的字符串

function randomString(n) {
	let str = 'abcdefghijklmnopqrstuvwxyz9876543210'
	let tmp = '',
	i = 0,
	l = str.length;
	for(i = 0; i < n; i ++) {
		tmp += str.charAt(Math.floor(Math.random()* l));
	}
	return tmp;
}

module.exports = randomString;
Edit this page
最近更新: 2025/12/2 01:46
Contributors: qdleader
qdleader
本站总访问量 129823次 | 本站访客数 12人