JS给定一个字符串如何随机打乱它
1个回答
展开全部
<!DOCTYPE html><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>RunJS 演示亩首代码</title> <script> // 插入随机字符串的方法 var fuck = function(str, desc) { var words = "abcdefghijklmnopqrstuvwxyz".split("散仿"); var result = ""; for (var i = 0; i < str.length; i += desc) { var rand = words[Math.floor(Math.random() * words.length)].fontcolor("red"); result += str.substring(i, i + desc); if (i + desc <= str.length) { result += rand; } } return result; } var desc = 1; // 指定间隔 var str = "我们的祖国是花园,花园的花朵真鲜艳。"; // 字符串 var result = fuck(str, desc); onload = function() { document.body.innerHTML = result; } </script></head> <body></冲耐纤body> </html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询