javascript course online, problems with task










1














I am complete beginner in javascript, well and programming in general. The task given in online course is pretty complicated for me.



Basically, it is called checks.js (because it suppose to check your index work) suppose to work like this:



// Built-in Node.JS module for the check
var assert = require('assert');

// input your function
var addTime = require('./index.js');

assert.equal(addTime(12, 30, 30), '13:00', 'when 30 min is added to 12:30 we get 13:00');
assert.equal(addTime(23, 59, 31), '00:30', 'when 31 min is added to 23:59 we get 00:30');
assert.equal(addTime(11, 50, 61), '12:51', 'when 61 min is added to 11:50 we get 12:51');
assert.equal(addTime(23, 1, 80), '00:21', 'when 80 min is added to 23:01 we get 00:21');

console.info('OK!');


'index.js' is made by a student, the template is like this:



/**
* @param Number hours
* @param Number minutes
* @param Number interval
* @returns String
*/
module.exports = function (hours, minutes, interval)

;


So I have been made index like this:



module.exports = function (hours, minutes, interval) 
var allmin = (hours * 60)+minutes+interval;
var allhours = Math.floor(allmin / 60);
var fMin = allmin % 60

if (allhours < 10)
allhours = toString(allhours);
allhours = '0'+allhours;


if (fMin < 10)
fMin = toString(fMin);
fMin = '0'+fMin;

return allhours+':'+fMin



And the second one like this:



module.exports = function (hours, minutes, interval) hours > 23) return false
var hours = Math.floor((minutes + interval) / 60);
var minutes = (minutes + interval) % 60;

if (hours < 10)
hours = toString(hours);
hours = '0'+hours;


if (minutes < 10)
minutes = toString(minutes);
minutes = '0'+minutes;


return (hours+':'+minutes);



which is pretty much the same, but when i run checks.js in terminal to check my index.js, I constantly getting an error:



MBP-John-2:coursera JJ$ node checks.js
assert.js:86
throw new AssertionError(obj);
^

AssertionError [ERR_ASSERTION]: При добавлении 30 мин. к 12:30 получится 13:00
at Object.<anonymous> (/Users/JJ/js_playground/coursera/checks.js:7:8)
at Module._compile (internal/modules/cjs/loader.js:707:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
at Module.load (internal/modules/cjs/loader.js:605:32)
at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
at Function.Module._load (internal/modules/cjs/loader.js:536:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:760:12)
at startup (internal/bootstrap/node.js:308:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:878:3)
MBP-John-2:coursera JJ$


Really need help!



Thanks in advance!!!










share|improve this question





















  • The error comes from the fact that your code does not return what the assertion expects. Just call the function you've developed (without the asserts), for example: addTime(12, 30, 30) , you will see that the result is not 13:00.
    – sjahan
    Nov 11 at 8:23











  • Just helping you debugging it: you cannot call toString(something), what you should do is something.toString().
    – sjahan
    Nov 11 at 8:26















1














I am complete beginner in javascript, well and programming in general. The task given in online course is pretty complicated for me.



Basically, it is called checks.js (because it suppose to check your index work) suppose to work like this:



// Built-in Node.JS module for the check
var assert = require('assert');

// input your function
var addTime = require('./index.js');

assert.equal(addTime(12, 30, 30), '13:00', 'when 30 min is added to 12:30 we get 13:00');
assert.equal(addTime(23, 59, 31), '00:30', 'when 31 min is added to 23:59 we get 00:30');
assert.equal(addTime(11, 50, 61), '12:51', 'when 61 min is added to 11:50 we get 12:51');
assert.equal(addTime(23, 1, 80), '00:21', 'when 80 min is added to 23:01 we get 00:21');

console.info('OK!');


'index.js' is made by a student, the template is like this:



/**
* @param Number hours
* @param Number minutes
* @param Number interval
* @returns String
*/
module.exports = function (hours, minutes, interval)

;


So I have been made index like this:



module.exports = function (hours, minutes, interval) 
var allmin = (hours * 60)+minutes+interval;
var allhours = Math.floor(allmin / 60);
var fMin = allmin % 60

if (allhours < 10)
allhours = toString(allhours);
allhours = '0'+allhours;


if (fMin < 10)
fMin = toString(fMin);
fMin = '0'+fMin;

return allhours+':'+fMin



And the second one like this:



module.exports = function (hours, minutes, interval) hours > 23) return false
var hours = Math.floor((minutes + interval) / 60);
var minutes = (minutes + interval) % 60;

if (hours < 10)
hours = toString(hours);
hours = '0'+hours;


if (minutes < 10)
minutes = toString(minutes);
minutes = '0'+minutes;


return (hours+':'+minutes);



which is pretty much the same, but when i run checks.js in terminal to check my index.js, I constantly getting an error:



MBP-John-2:coursera JJ$ node checks.js
assert.js:86
throw new AssertionError(obj);
^

AssertionError [ERR_ASSERTION]: При добавлении 30 мин. к 12:30 получится 13:00
at Object.<anonymous> (/Users/JJ/js_playground/coursera/checks.js:7:8)
at Module._compile (internal/modules/cjs/loader.js:707:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
at Module.load (internal/modules/cjs/loader.js:605:32)
at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
at Function.Module._load (internal/modules/cjs/loader.js:536:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:760:12)
at startup (internal/bootstrap/node.js:308:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:878:3)
MBP-John-2:coursera JJ$


Really need help!



Thanks in advance!!!










share|improve this question





















  • The error comes from the fact that your code does not return what the assertion expects. Just call the function you've developed (without the asserts), for example: addTime(12, 30, 30) , you will see that the result is not 13:00.
    – sjahan
    Nov 11 at 8:23











  • Just helping you debugging it: you cannot call toString(something), what you should do is something.toString().
    – sjahan
    Nov 11 at 8:26













1












1








1







I am complete beginner in javascript, well and programming in general. The task given in online course is pretty complicated for me.



Basically, it is called checks.js (because it suppose to check your index work) suppose to work like this:



// Built-in Node.JS module for the check
var assert = require('assert');

// input your function
var addTime = require('./index.js');

assert.equal(addTime(12, 30, 30), '13:00', 'when 30 min is added to 12:30 we get 13:00');
assert.equal(addTime(23, 59, 31), '00:30', 'when 31 min is added to 23:59 we get 00:30');
assert.equal(addTime(11, 50, 61), '12:51', 'when 61 min is added to 11:50 we get 12:51');
assert.equal(addTime(23, 1, 80), '00:21', 'when 80 min is added to 23:01 we get 00:21');

console.info('OK!');


'index.js' is made by a student, the template is like this:



/**
* @param Number hours
* @param Number minutes
* @param Number interval
* @returns String
*/
module.exports = function (hours, minutes, interval)

;


So I have been made index like this:



module.exports = function (hours, minutes, interval) 
var allmin = (hours * 60)+minutes+interval;
var allhours = Math.floor(allmin / 60);
var fMin = allmin % 60

if (allhours < 10)
allhours = toString(allhours);
allhours = '0'+allhours;


if (fMin < 10)
fMin = toString(fMin);
fMin = '0'+fMin;

return allhours+':'+fMin



And the second one like this:



module.exports = function (hours, minutes, interval) hours > 23) return false
var hours = Math.floor((minutes + interval) / 60);
var minutes = (minutes + interval) % 60;

if (hours < 10)
hours = toString(hours);
hours = '0'+hours;


if (minutes < 10)
minutes = toString(minutes);
minutes = '0'+minutes;


return (hours+':'+minutes);



which is pretty much the same, but when i run checks.js in terminal to check my index.js, I constantly getting an error:



MBP-John-2:coursera JJ$ node checks.js
assert.js:86
throw new AssertionError(obj);
^

AssertionError [ERR_ASSERTION]: При добавлении 30 мин. к 12:30 получится 13:00
at Object.<anonymous> (/Users/JJ/js_playground/coursera/checks.js:7:8)
at Module._compile (internal/modules/cjs/loader.js:707:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
at Module.load (internal/modules/cjs/loader.js:605:32)
at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
at Function.Module._load (internal/modules/cjs/loader.js:536:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:760:12)
at startup (internal/bootstrap/node.js:308:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:878:3)
MBP-John-2:coursera JJ$


Really need help!



Thanks in advance!!!










share|improve this question













I am complete beginner in javascript, well and programming in general. The task given in online course is pretty complicated for me.



Basically, it is called checks.js (because it suppose to check your index work) suppose to work like this:



// Built-in Node.JS module for the check
var assert = require('assert');

// input your function
var addTime = require('./index.js');

assert.equal(addTime(12, 30, 30), '13:00', 'when 30 min is added to 12:30 we get 13:00');
assert.equal(addTime(23, 59, 31), '00:30', 'when 31 min is added to 23:59 we get 00:30');
assert.equal(addTime(11, 50, 61), '12:51', 'when 61 min is added to 11:50 we get 12:51');
assert.equal(addTime(23, 1, 80), '00:21', 'when 80 min is added to 23:01 we get 00:21');

console.info('OK!');


'index.js' is made by a student, the template is like this:



/**
* @param Number hours
* @param Number minutes
* @param Number interval
* @returns String
*/
module.exports = function (hours, minutes, interval)

;


So I have been made index like this:



module.exports = function (hours, minutes, interval) 
var allmin = (hours * 60)+minutes+interval;
var allhours = Math.floor(allmin / 60);
var fMin = allmin % 60

if (allhours < 10)
allhours = toString(allhours);
allhours = '0'+allhours;


if (fMin < 10)
fMin = toString(fMin);
fMin = '0'+fMin;

return allhours+':'+fMin



And the second one like this:



module.exports = function (hours, minutes, interval) hours > 23) return false
var hours = Math.floor((minutes + interval) / 60);
var minutes = (minutes + interval) % 60;

if (hours < 10)
hours = toString(hours);
hours = '0'+hours;


if (minutes < 10)
minutes = toString(minutes);
minutes = '0'+minutes;


return (hours+':'+minutes);



which is pretty much the same, but when i run checks.js in terminal to check my index.js, I constantly getting an error:



MBP-John-2:coursera JJ$ node checks.js
assert.js:86
throw new AssertionError(obj);
^

AssertionError [ERR_ASSERTION]: При добавлении 30 мин. к 12:30 получится 13:00
at Object.<anonymous> (/Users/JJ/js_playground/coursera/checks.js:7:8)
at Module._compile (internal/modules/cjs/loader.js:707:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
at Module.load (internal/modules/cjs/loader.js:605:32)
at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
at Function.Module._load (internal/modules/cjs/loader.js:536:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:760:12)
at startup (internal/bootstrap/node.js:308:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:878:3)
MBP-John-2:coursera JJ$


Really need help!



Thanks in advance!!!







javascript






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 7:43









Grimmie

61




61











  • The error comes from the fact that your code does not return what the assertion expects. Just call the function you've developed (without the asserts), for example: addTime(12, 30, 30) , you will see that the result is not 13:00.
    – sjahan
    Nov 11 at 8:23











  • Just helping you debugging it: you cannot call toString(something), what you should do is something.toString().
    – sjahan
    Nov 11 at 8:26
















  • The error comes from the fact that your code does not return what the assertion expects. Just call the function you've developed (without the asserts), for example: addTime(12, 30, 30) , you will see that the result is not 13:00.
    – sjahan
    Nov 11 at 8:23











  • Just helping you debugging it: you cannot call toString(something), what you should do is something.toString().
    – sjahan
    Nov 11 at 8:26















The error comes from the fact that your code does not return what the assertion expects. Just call the function you've developed (without the asserts), for example: addTime(12, 30, 30) , you will see that the result is not 13:00.
– sjahan
Nov 11 at 8:23





The error comes from the fact that your code does not return what the assertion expects. Just call the function you've developed (without the asserts), for example: addTime(12, 30, 30) , you will see that the result is not 13:00.
– sjahan
Nov 11 at 8:23













Just helping you debugging it: you cannot call toString(something), what you should do is something.toString().
– sjahan
Nov 11 at 8:26




Just helping you debugging it: you cannot call toString(something), what you should do is something.toString().
– sjahan
Nov 11 at 8:26

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246777%2fjavascript-course-online-problems-with-task%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246777%2fjavascript-course-online-problems-with-task%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

Syphilis

Darth Vader #20