使用三个并行数组创建货币转换器 [英] Creating a currency converter using three parrallel arrays

查看:111
本文介绍了使用三个并行数组创建货币转换器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人可以帮助我,我对Javascript很新,不得不创建一个程序,将美元兑换成欧元,反之亦然,这是我的脚本正在运行

Hi, I''m hoping someone can help me I am quite new to Javascript and have had to create a programme which converts dollars into euros and vice versa, here is my script which is working

展开 | 选择 | Wrap | 行号

推荐答案

看了谷歌之后,似乎你的计算转换为usd有点偏。

1欧元= 1.3081美元
1日元= 0.00826036676美元
1英镑= 1.9539美元

我离开了用你的计算代码。如果您需要帮助或者甚至想要这些计算,请告诉我,我会帮助您将它们放入
after looking at google it seems as if your calculations to convert to usd is a bit off.

1 Euro = 1.3081 U.S. dollar
1 Japanese yen = 0.00826036676 U.S. dollar
1 British pound = 1.9539 U.S. dollar

I left the code with your calculations in it. if you need help or even want these calculations in it let me know and i will help u put them in


展开 | 选择 | Wrap | 行号


您可以使用对象。


创建实例时,请设置唯一属性 - 金额,货币格式和日期。用对象原型中的汇率数组设置转换方法(往返)。


这使得添加新货币或更新汇率变得微不足道(这就是你需要为每笔交易附上日期的原因。)
You could use an object.

When you create an instance, set the unique properties- amount, currency format, and date. Set the conversion methods (to and from) with arrays of exchange ratesin the object''s prototype.

This makes it trivial to add new currencies, or update the exchange rates- (which is why you need a date attached to every transaction).


这篇关于使用三个并行数组创建货币转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆