var num = Math.floor(Math.random() * 100000); //生成0-99999之间的随机整数 console.log("生成的随机数为:" + num); var arr = num.toString().split(""); //将随机数转换成字符串,并拆分成数组 console.log("该数共有" + arr.length + "位"); console.log("每位数字分别为:" + arr.join(", ")); //将数组转换成字符串并输出

用js实现随机生成一个五位以内的数然后输出该数共有多少位每位分别是什么

原文地址: https://www.cveoy.top/t/topic/eb12 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录