validar rut chile

`def rut_validator(rut): rut = rut.replace(/\./g, '').replace('-', '') let dv = rut[rut.length - 1] let new_rut = rut.slice(0, rut.length - 1) let sum = 0 let mul = 2 for (let i = 1; i <= new_rut.length; i++) { let index = new_rut.length - i sum = sum + parseInt(new_rut[index]) * mul if (mul == 7) { mul = 2 } else { mul = mul + 1 } } let rest = sum % 11 let digito if (rest == 1) { digito = 'k' } else if (rest == 0) { digito = '0' } else { digito = 11 - rest } if (digito == dv.toLowerCase()) {`