/**
* Generate random lowercase word
* @param {number} length Word length
* @returns Random n-letter word
*/
randomWord(length: number): string {
let result = '';
for (let index = 0; index < length; index++) {
// one of 26 en letters, 'a' = 97
const ascii = Math.floor(Math.random() * 26 + 97);
result += String.fromCharCode(ascii);
}
return result;
}
Wednesday, 23 September 2020
TypeScript - generate random word
This method will generate random string of n-letter length with lowercase letters:
Etykiety:
code,
in English,
JavaScript,
TypeScript
Tuesday, 1 September 2020
Hide Addons panel for some stories in Storybook
I'm using Code Preview globally in Storybook with
To hide the panel for single story, set following parameters in Story:
storybook-addon-preview
. However, I there is one story that has no code preview and it displays "No Preview found" message.
To hide the panel for single story, set following parameters in Story:
export default { title: 'Some title', parameters: { options: { showPanel: false } } };
Etykiety:
code,
in English,
Storybook
Subscribe to:
Posts (Atom)