Skip to content
Snippets Groups Projects
Commit 4dd1cf36 authored by Kartik Mohan's avatar Kartik Mohan
Browse files

Delete Lab 4 script.js

parent 23341bc4
Branches
No related tags found
No related merge requests found
function getRandomNumber(min, max) {
return Math.floor((Math.random() * max) + min);
}
function filterWords(words) {
let wordList = words.split(" ");
let bannedWords = [
"The",
"the",
"is",
"it",
"a",
"and",
"an"
];
let filterWords = [];
wordList.forEach(word => {
var keepWord = true;
bannedWords.forEach(bannedWord =>{
if (word == bannedWord) {
keepWord = false;
}
});
if (keepWord) {
filterWords.push(word);
}
});
return filterWords;
}
function generatePassWord() {
let answers = [
document.getElementById("question1").value,
document.getElementById("question2").value,
document.getElementById("question3").value,
];
let filteredAnswers = [];
answers.forEach(answer => {
let filteredAnswer = filterWords(answer);
filteredAnswers.push(...filteredAnswer);
});
let passwords = [];
for (let i = 0; i < 3; i++) {
password = "";
for (let j = 0; j < 3; j++) {
password += filteredAnswers[getRandomNumber(0, filteredAnswers.length - 1)];
}
passwords.push(password);
}
var UI = document.getElementById("myDIV");
passwords.forEach(password => {
var childElement = document.createElement("p");
childElement.innerText = password;
UI.appendChild(childElement);
});
return passwords;
}
function showPasswordGeneratorUI() {
var x = document.getElementById("myDIV");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment