公司名字吉凶测试免费
javascript // script.jsconst companyNameInput = document.getElementById("company_name"); const resultDiv = document.getElementById("result");const submitForm = (e) => {e.preventDefault();const companyName = companyNameInput.value;// 计算公司名的笔画数 const strokeCount = getStrokeCount(companyName);// 根据笔画数判断公司名的吉祥程度let result = "";if (strokeCount <= 17) {result = "大吉大利";} else if (strokeCount >= 18 && strokeCount <= 26) {result = "吉";} else if (strokeCount >= 27 && strokeCount <= 33) {result = "小吉";} else if (strokeCount >= 34 && strokeCount <= 40) {result = "凶";} else {result = "大凶";}// 显示结果resultDiv.innerHTML = `公司名『${companyName}』的笔画数为:${strokeCount}
`;resultDiv.innerHTML += `吉凶程度:${result}
`; };const getStrokeCount = (chinese) => {// 转换中文为 unicode 码const unicodeArray = chinese.split("").map(char => char.charCodeAt(0));// 获取每个 unicode 码对应的笔画数