---
# System prepended metadata

title: javascript 取最大最小值間的亂數 合成一個亂碼變數
tags: [javascript]

---



### 取最大最小值間的亂數
```javascript=
const randomNumber = (min, max) =>
    Math.floor(Math.random() * (max - min + 1) + min);
```

### 運用上面產生亂數取三組亂數 合成一個亂碼變數
```javascript=
const textGenerator = () => {
    let generatedText = "";
    for (let i = 0; i < 3; i++) {
        generatedText += Srting.fromCharCode(randomNumber(65, 90));
        generatedText += String.fromCharCode(randomNumber(97, 122));
        generatedText += String.fromCharCode(randomNumber(48, 57));
    }
    return generatedText;
}
```