Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Exercises/1-key.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use strict';

const generateKey = (length, possible) => {
// Generate string of random characters
// Use Math.random() and Math.floor()
// See documentation at MDN
let resStr = '';
for (let i = 0; i < length; i++) {
const charInd = Math.floor(Math.random() * (possible.length));
resStr += possible[charInd];
}
return resStr;
};

module.exports = { generateKey };