• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript FUCTION

KISHOR 1988

New Coder
JavaScript:
function monitorCount(rows, columns) {
  return rows * columns;
}

function costOfMonitors() {
  return monitorCount(rows, columns) * 2000

}

monitorCount(5, 7)

console.log(costOfMonitors());


THOUGH I HAVE PASSED ARGUMENT FOR ROWS AND COLUMNS , WHY AM I NOT GETTING VALUE IN CONSOLE?
 
Last edited by a moderator:

KISHOR 1988

New Coder
JavaScript:
function monitorCount(rows, columns) {
  return rows * columns;
}

 function costOfMonitors() {
  return monitorCount(rows, columns) * 2000
}

monitorCount(5, 7)

console.log(costOfMonitors());


Though i have passed arguments for rows and columns , why am i not getting data in console??
 

abhiweb_admec

New Coder
You are passing the arguments in wrong place and calling function somewhere else and what ends up happening is when you are passing the values it works but you are not previewing that and when are previewing it you are not passing the value. I think you are very confused how a function works in JavaScript. Regardless here is the code to make that work:

JavaScript:
 function monitorCount(rows, columns) {
        return rows * columns;
      }

      function costOfMonitors(rows, columns) {
        return monitorCount(rows, columns) * 2000;
      }

      console.log(monitorCount(5, 7)); // first fucntion works.

      console.log(costOfMonitors(5, 7)); // to call the first function with second function.

I would recommend reading this blog to get better understanding of the functions in JavaScript.
 
Last edited by a moderator:

Top