Tell us what’s happening:
This code is working for all test until 13… When I run this code under visual code, it returns the right value for each test case … Is there a mistake in my code ? or is it something with the platform ?
Thank you for your help.
Your code so far
function smallestMult(n) {
let returnVal = 0
let shouldContinu = true
let currentIndex = 1
while(shouldContinu){
currentIndex++
if( canBeDividedByAll(1, n, currentIndex) ) {
shouldContinu = false
returnVal = currentIndex
}
}
console.log('final value to return '+returnVal)
return returnVal
}
function canBeDividedByAll( start, end , numberToCheck){
let returnVal = true
for(let i = start; i <= end; i++){
if(numberToCheck % i !== 0) {
returnVal = false
break
}
}
//console.log('>> checking number: '+ numberToCheck + ' and return : '+ returnVal)
return returnVal
}
smallestMult(13);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
.