Færdiggjort

PHP to Javascript - Convert 2 functions and small piece of code.

I have a function for standard deviation and one for simple moving average, doing calculations in php.

I need the javascript equivalent. Obviously function need to be written differently.

My desire is for the same output in Javascript, like php gives.

This is the PHP Code, along with a Javascript function to Display calculated values.

The project task is to produce code that will the calculations. Doesn't matter to me how (with how many function ect.), need same result.

Please note, in the example, php is marked with ///CODE TO MAKE IN JS BEGIN, ///CODE TO MAKE IN JS END.

Bid only if you are able to do it, and do not require any more explanations. Should be straight forward for somebody with experience in JS.

<?php

$period = 7;

$recent = array(13755,13720.9,13738.5,13792.7,13828,13813.1,13854.4);

///CODE TO MAKE IN JS BEGIN

function sd_square($x, $mean) { return pow($x - $mean,2); }

function sma($data, $range)

{

$sum = array_sum(array_slice($data, 0, $range));

$result = array($range - 1 => $sum / $range);

for ($i = $range, $n = count($data); $i != $n; ++$i) {

$result[$i] = $result[$i - 1] + ($data[$i] - $data[$i - $range]) / $range;

}

return $result;

}

$stdev = sqrt(array_sum(array_map("sd_square", $recent, array_fill(0,count($recent), (array_sum($recent) / count($recent)) ) ) ) / (count($recent)-1));$sma = sma($recent,$period);

///CODE TO MAKE IN JS END

?>

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>Untitled Document</title>

<script type="text/javascript">

var recent = [url removed, login to view]('<?php echo json_encode($recent); ?>');

///CODE TO MADE IN JS BEGIN

///////PROJECT TASK HERE

///CODE TO MAKE IN JS END

var stdev = 13786.085714286;//HARDCODED FOR DEMO , EXPECTING YOUR CODE TO CALCULATE

var sma = 49.458852546719; //HARDCODED FOR DEMO , EXPECTING YOUR CODE TO CALCULATE

function PopulateJs()

{

[url removed, login to view]("jsstdev").innerHTML = stdev;

[url removed, login to view]("jssma").innerHTML = sma;

}

</script>

</head>

<body>

<table>

<tr><th colspan="2">PHP</th><th colspan="2">JS</th></tr>

<tr><td>Dev:</td><td><?php echo $sma[($period-1)];?></td><td>Dev:</td><td id="jsstdev"></td></tr>

<tr><td>Sma:</td><td><?php echo $stdev;?></td><td>Sma:</td><td id="jssma"></td></tr>

</table>

<button onclick="PopulateJs();">PopulateJS</button>

</body>

</html>

Færdigheder: Javascript, jQuery / Prototype

Se mere: http www own free website com pwd vergessen php mode 2&user programe pc&code 37586a6ef8f73, convert as3 function php, php javascript validation code example, php swf convert code php, code using php javascript, small php javascript projects, code project php javascript, code logo php javascript, php asp convert code, enter security code php javascript, template php javascript code drupal, small photoshop code php, image gallaery light view source code php javascript, php javascript code states india drop list, php format link convert url function, protect code html php javascript jquery, function calculator html code javascript, convert php javascript, php flv convert upload, php openoffice convert, php asp convert, javascript convert utf big5, javascript return false function within function, php convert link function, php script convert pdf web page

Om arbejdsgiveren:
( 15 bedømmelser ) Sofia, Bulgaria

Projekt-ID: #16082677

Tildelt til:

rohitagarberg

hi sir, i have read the code where php is calculating the standard deviation and moving average, i will write the exace same implementation in javascrit within 2 hrs and will not need any explanation Relevant Skills a Mere

$25 USD på 1 dag
(79 bedømmelser)
5.7

17 freelancers are bidding on average $26 for this job

$61 USD på 1 dag
(64 bedømmelser)
6.4
vaishali1191

I have experience in JavaScript and php and can do this task within less time. Relevant Skills and Experience Php, javascript

$15 USD på 1 dag
(1 bedømmelse)
4.1
testotorko

PHP to Javascript - Convert 2 functions and small piece of code. Stay tuned, I'm still working on this proposal.

$25 USD på 1 dag
(18 bedømmelser)
4.2
softcarve

Hi, I would like to change the function sd_square and sma into javascript. available to start right now. Regards, Manish Relevant Skills and Experience I have good proficiency in PHP, mysql, html, js, jquery, css, boo Mere

$20 USD på 1 dag
(14 bedømmelser)
3.9
$25 USD på 1 dag
(9 bedømmelser)
3.0
zhiqiang1988

Dear sir. I am a Web expert. If you hire me, I will give you excellent results with a small amount of money in the shortest time. I hope to meet you again. Thank you. Relevant Skills and Experience Javascript, jQuery Mere

$15 USD på 1 dag
(4 bedømmelser)
3.0
$25 USD på 1 dag
(6 bedømmelser)
2.6
shingjin

i am interested in your post. i can help you with that. Stay tuned, I'm still working on this proposal.

$20 USD på 1 dag
(3 bedømmelser)
1.9
FMknott

Hi there, How are you? I'm interested in your project and I'm talented full stack developer. I have developed many large scale projects, so I'm good at both javascript and PHP. Relevant Skills and Experience I can imp Mere

$30 USD på 1 dag
(2 bedømmelser)
1.6
AyatSaid2

Php Javascript Relevant Skills and Experience Php Java script

$25 USD på 1 dag
(1 bedømmelse)
1.1
markbrandt968

I take pride in my attention to detail, and technical expertise required to deliver high quality, bug free code for your job. Thank you for your time and consideration Best regards Relevant Skills and Experience Java Mere

$25 USD på 1 dag
(0 bedømmelser)
0.0
$25 USD på 1 dag
(0 bedømmelser)
0.0
hongsoft

Please give me your simple project. Relevant Skills and Experience Hello! I've clearly read your requirements and it's very interesting. I will send you javascript in 10 minutes. Please contact me... Proposed Milesto Mere

$10 USD in 0 dage
(1 bedømmelse)
0.0
doaakhalf

i will convert two function from php to javascript and part of code through two days and i will Relevant Skills and Experience i work with javascript ,php,laravel,jquery ,laravel With myself abd also in training in a Mere

$30 USD in 2 dage
(0 bedømmelser)
0.0
$25 USD på 1 dag
(0 bedømmelser)
0.0
s43id

Many can provide javascript solutions, but when you're talking JS, Performance has to be taken in consideration, I can offer you that, with a well structured and commented code that explains it all. Relevant Skills an Mere

$45 USD på 1 dag
(0 bedømmelser)
0.0