用户选择未显示结果请给我帮助
这是一个使用闭包函数的计算器操作符
结果块中的在将其转换为整数后也显示为NaN。
Mathamatical.js //封闭内容
var pradeep=(function(){
result = 0; sum_is=sub_is=mul_is=divn_is=0;
function manupulation(x,y){
sum_is = getsumValues(x,y);
sub_is = getsubValues(x,y);
mul_is = getmulValues(x,y);
divn_is = getdivnValues(x,y);
return result[sum_is,sub_is,mul_is,divn_is];
}
function getsumValues(x,y){
var sum_is = x+y;
return result[0];
}
function getsubValues(x,y){
var sub_is = x-y;
return sub_is;
}
function getmulValues(x,y){
var mul_is = x*y;
return mul_is;
}
function getdivnValues(x,y){
var divn_is = x/y;
return divn_is;
}return{
manupulation_value : function(x,y){
return manupulation(x,y);
}
}
})();
我的第二个js文件
function calculate_operations(){
var details = {}
details.Firstvalue = document.querySelector("#fnumber").value;
details.SecondValue = document.querySelector("#snumber").value;
details.Firstvalue = parseInt(details.Firstvalue);
details.SecondValue = parseInt(details.SecondValue);
details.result = 0;
//details.selectedOperation = document.querySelector("operation")
details.showdetails = function(){
console.log(pradeep);
document.querySelector("#numberF").innerText = details.Firstvalue;
document.querySelector("#numberS").innerText = details.SecondValue;
function operationsMathematical(){
if (document.querySelector("#operation".value == "")) {
document.querySelector("#sel_operation").innerText = +"No operation selected";
}
if (document.querySelector("#operation").value== "add") {
document.querySelector("#sel_operation").innerHTML =+details.Firstvalue +"+" +details.SecondValue ;
details.result= pradeep.manupulation_value(details.Firstvalue,details.SecondValue);
//console.log(details.Firstvalue,details.SecondValue);
details.result=parseInt(pradeep.manupulation_value(result[0]));
document.querySelector("#result_block").innerHTML = +details.result;
}
if (document.querySelector("#operation").value== "sub") {
document.querySelector("#sel_operation").innerText =+details.Firstvalue +"-" +details.SecondValue;
details.result=pradeep.manupulation_value(result[1]);
document.querySelector("#result_block").innerHTML = +details.result;
}
if (document.querySelector("#operation").value== "mul") {
document.querySelector("#sel_operation").innerText =+details.Firstvalue +"*" +details.SecondValue;
details.result= pradeep.manupulation_value(details.Firstvalue,details.SecondValue);
details.result=parseInt(pradeep.manupulation_value(result[sum_is]));
document.querySelector("#result_block").innerHTML = +details.result;
}
if (document.querySelector("#operation").value== "divn") {
document.querySelector("#sel_operation").innerText =+details.Firstvalue +"/" +details.SecondValue;
}
}
operationsMathematical();
}
//details.result= pradeep.manupulation_value(details.Firstvalue,details.SecondValue);
document.querySelector("#showvalues").style.display="block";
details.showdetails();
}
答案 0 :(得分:0)
更改了文件。这应该工作
np.concatenate([a[1:, :2], a[:0:-1, [2,0]]], axis=1)
# array([[ 2.1, 2.2, 4.3, 4.1],
# [ 3.1, 3.2, 3.3, 3.1],
# [ 4.1, 4.2, 2.3, 2.1]])
您的第二个文件有错误。
var pradeep=(function(){
// No need of these variables result = 0; sum_is=sub_is=mul_is=divn_is=0;
function manupulation(x,y){
var sum_is = getsumValues(x,y); //use var otherwise global scope is used
var sub_is = getsubValues(x,y);
var mul_is = getmulValues(x,y);
var divn_is = getdivnValues(x,y);
return [sum_is,sub_is,mul_is,divn_is];
}
function getsumValues(x,y){
var sum_is = x+y;
return sum_is;
}
function getsubValues(x,y){
var sub_is = x-y;
return sub_is;
}
function getmulValues(x,y){
var mul_is = x*y;
return mul_is;
}
function getdivnValues(x,y){
var divn_is = x/y;
return divn_is;
}
return{
manupulation_value : function(x,y){
return manupulation(x,y);
}
}
})();