Programming Questions

  • Newest
  • Popular Tags
  • Ask Question
  • Counting Minutes: Help with code
    Hi everybody , could anyone help me with my code, I'm sure the code below is not the best method but I just begun programming. Thank you in advance and have a nice day function CountingMinutesI(str) { // code goes here var primhora = Number(str.slice(0,str.indexOf("-")-5))*60; var primhorapm = primhora *12; if (str.slice(str.indexOf("-")-2,str.indexOf("-"))==="pm") {return primhorapm} else {return primhora} var ultihora = Number(str.slice(str.indexOf("-")+1,str.length-5))*60; var ultimhorapm = ultihora*12; if ((str.slice(str.length-2,str.length))==="pm") {return ultimhorapm} else {return ultihora} var priminu = Number(str.slice(str.indexOf(":")+1,str.indexOf("a"||"p"))); var ultminu = Number(str.slice(str.length-4,str.length-2)); var primera = (primhora||primhorapm) + priminu; var ultima = (ultihora ||ultimhorapm) + ultminu; return Math.abs(ultima-primera); }
    ge00rge posted this question on 4/12/17 | counting, minutes, javascript
    Answers
  • +
  • -1
  • -
  • Can you tell more about the input? Thanks!
    Log in to write an answer.