Skip to content

Instantly share code, notes, and snippets.

@Shaxadhere
Created August 5, 2022 08:07
Show Gist options
  • Save Shaxadhere/37dec18abc2991fcf76f864410d3bbb0 to your computer and use it in GitHub Desktop.
Save Shaxadhere/37dec18abc2991fcf76f864410d3bbb0 to your computer and use it in GitHub Desktop.
const QuestionsMarks =(str="acc?7??sss?3rr1??????5")=>{
numberCount = 0
markCount = 0
markUsed=0
numberSum = 0
lastAdded=0
result = false
str.split("").forEach((item) => {
if(!isNaN(item)) numberCount=1
if(numberCount>0){
if(item=="?"){
markCount=markCount+1
}
if(markCount<=3){
if(!isNaN(item)){
markUsed=markUsed+1
if(markCount==3){
if(numberSum!=10){
numberSum=numberSum+parseInt(item)
}
}
}
}
}
if(numberSum==10){
result = true
}
console.log(markUsed)
if(markUsed>3){
result=false
}
})
return result
}
console.log(QuestionsMarks())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment