return meter * 100; //multiply the length value by 100, Step B } function kilo_to_meter(kilo) {
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
I am learning import and exports in Javascript (NOT HTML), and I have imported my first file in to the second file. The issue I am running into is its saying my num variable is not a function. I need help understanding where I went wrong in my second file. I am asking bartleby for help because all of Google talks about is html files.
This is the first file below:
function centi_to_milli(centi) {
return centi * 10; //multiply the length value by 10, Step A
}
function meter_to_centi(meter) {
return meter * 100; //multiply the length value by 100, Step B
}
function kilo_to_meter(kilo) {
return kilo * 1000; //multiply the length value by 1000, Step C
}
function inch_to_centi(inch) {
return inch * 2.54; //multiply the length value by 2.54, Step D
}
function feet_to_centi(feet) {
return feet * 30.48; //multiply the length value by 30.48, Step E
}
function yard_to_meter(yard) {
return yard / 1.094; //divide the length value of 1.094, Step F
}
function mile_to_meter(mile) {
return mile * 1609; //multiply the length value by 1609, Step G
}
function mile_to_kilo(mile2){
return mile2 * 1.60934; //multiply the length value by 1.609, Step H
}
module.exports = {centi_to_milli, meter_to_centi, kilo_to_meter, inch_to_centi, feet_to_centi, yard_to_meter, mile_to_meter, mile_to_kilo}
This is my second file below:
const readlineSync = require('readline-sync');
const convert = require("./conversionutils")
//import {
//centi_to_milli,
//meter_to_centi,
//kilo_to_meter,
//inch_to_centi,
//feet_to_centi,
//yard_to_meter,
//mile_to_meter,
//mile_to_kilo
//}from './conversionutils.js';
console.log("Select which converson method from the given options: ");
console.log("1. Convert centimeters to milimeters.");
console.log("2. Convert meters to centimeters.");
console.log("3. Convert kilometers to meters.");
console.log("4. Convert inches to centimeter.");
console.log("5. Convert feet to centimeters.");
console.log("6. Convert yards to meters.");
console.log("7. Convert miles to meters.");
console.log("8. Convert miles to kilometers.");
function num() {
return parseInt(readlineSync.question("Enter your selection: "));
}
let method = convert.num();
switch (method) {
case '1':
let con1 = parseInt(readlineSync.question("Enter centimeters to be converted to milimeters: "))
console.log(centi_to_milli(con1))
break;
case '2':
let con2 = parseInt(readlineSync.question("Enter meters to be converted to centimeters: "))
console.log(meter_to_centi(con2))
break;
case '3':
let con3 = parseInt(readlineSync.question("Enter kilometers to be converted to meters: "))
console.log(kilo_to_meter(con3))
break;
case '4':
let con4 = parseInt(readlineSync.question("Enter inches to be converted to centimeters: "))
console.log(inch_to_centi(con4))
break;
case '5':
let con5 = parseInt(readlineSync.question("Enter feet to be converted to centimeters: "))
console.log(feet_to_centi(con5))
break;
case '6':
let con6 = parseInt(readlineSync.question("Enter yards to be converted to meters: "))
console.log(yard_to_meter(con6))
break;
case '7':
let con7 = parseInt(readlineSync.question("Enter miles to be converted to meters: "))
console.log(mile_to_meter(con7))
break;
case '8':
let con8 = parseInt(readlineSync.question("Enter miles to be converted to kilometers: "))
console.log(mile_to_kilo(con8))
break;
}
Step by step
Solved in 3 steps
The while loop below does not work, I have also tried while (num != exit) and that doesn't work either. I have tried other things and the
Thank you for that, it works great. I didn't realize the ' ' being such an issue.
I just reread my assignment, and my prof. wants the program to continuously run until user enters the word exit.