有人知道如何在javascript中将此代码转换为递归吗?我想制作一个将二进制转换为十进制但在javascript中使用递归的代码。
<html>
<head>
<title>Converting Binary to Decimal</title>
</head>
<style>
</style>
<body>
<div>
<input type="text" id="binary" />
<input type="submit" value="convert" onclick="convertBinary()" />
</div>
<script>
function convertBinary()
{
var binaryNumber = document.getElementById('binary').value;
binaryNumber = parseInt(binaryNumber,2);
var decimalNumber = binaryNumber.toString(10);
alert(decimalNumber)
}
</script>
</body>
答案 0 :(得分:0)
我所做的是一种字符操作,但这会动态工作并且还会有某种递归。
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class CallManagement extends Model
{
/**
* Get the task record associated with the user.
*/
public function task()
{
return $this->hasOne('App\TaskManagement');
}
}