-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex03.js
27 lines (22 loc) · 781 Bytes
/
ex03.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Botão
let meuBotao = document.querySelector('button');
function orderAlph(input) {
let inputArray;
inputArray = input.split('');
inputArray = inputArray.sort();
inputArray = inputArray.toString();
return inputArray;
}
meuBotao.onclick = function() {
let firstInput = document.querySelector('#firstInput').value;
let secondInput = document.querySelector('#secondInput').value;
firstInput = firstInput.toLowerCase();
secondInput = secondInput.toLowerCase();
firstInput = orderAlph(firstInput);
secondInput = orderAlph(secondInput);
if(firstInput.length === secondInput.length && firstInput === secondInput ) {
alert('Pimba, suas palavras são um anagrama!')
} else {
alert('Não é um anagrama.')
}
}