console
var getIntArr = function(B){
for(let j = 0; j < B.length; j++){
B[j] = parseInt(B[j]);
}
return B;
}
var prefixesDivBy5 = function(A) {
var res = [], num = 0;
for(let i = 0; i < A.length; i++){
num = ((num << 1)+A[i])%5;
res.push(num === 0);
}
return res;
};
const numberInput = document.querySelector('.input');
const button = document.querySelector('.submit');
const getArr = document.querySelector('.getArr');
button.addEventListener('click',function(){
if(numberInput.value === ''){
console.log(false);
}else{
getArr.innerHTML=`${prefixesDivBy5(getIntArr(numberInput.value.split(',')))}`;
}
})
<div>
<input class="input" type="text">
<button class="submit">提交</button>
<div class="getArr"></div>
</div>
input {
margin: 200px 0 200px 200px;
width: 200px;
height: 30px;
border-radius: 12px;
border: 1px solid grey;
}
button {
width: 50px;
height: 30px;
border-radius: 8px;
border: 1px solid red;
}
.getArr{
width: 100%;
height: 50px;
text-align: center;
line-height: 50px;
border: 1px dotted #dc7646;
}