分类
期权交易指南

朱凱婷Double up投資法

Write a function that doubles up each item in an array

You are just summing some elements of the array. You need to (1) iterate through the array (2) insert the encountered element twice in another array (3à) return the newly constructed array. The parameter array is the one to iterate through, and you must construct a local one with a different name, say myDoublingArray , write the code is suggested you and return myDoublingArray .

8 Answers 8

Trending sort

Trending sort is based off of the default sorting method — by 朱凱婷Double up投資法 highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

Way with reduce , maybe the shortest one

and ES6 version

Here's a concise way to do this:朱凱婷Double up投資法

A somewhat more easy-to-understand approach:

And an ESNext version:

Untested code, I'm not overly familiar with javascript, so this might have some syntactical errors:

First, we declare a function with a parameter named array . Because array is a parameter, we don't need to declare it in the function body.

Next, we declare the array where we will put the result of our duplication. Let's name this simply result .

Next, we loop through the array. And for every member of the array we push the element to the end of the result. Which means if the first member is 1 we push 1 two different times ending up with [1,1] after the first step.

8年股市經驗學叻咗 朱凱婷專買穩健大藍籌

我們《胡.說樓市》早前收到一名谷友查詢,表示本身是房協樓業主,物業過了兩年房協禁售期,最近打算在第二市場出售,並獲買家出價500萬元,但卻因持貨未夠三年,故轉售物業時可能被稅局徵收「額外印花稅」,究竟要交多少稅款? 是用市值價計算、還是以出售價500萬元計算? 谷友當初購入的是一手居屋,而非私樓,買賣程序跟私樓不同,計算上亦可能不同。前提要視乎買入物業為房協,或房委會物業。購買房協物業,程序上跟私樓沒有太大分別,因為跟房協購入一手居屋時,均會按程序先簽署「臨時買賣合約」,之後再簽署「正式買賣合約」。因此計算其「持貨時間」的起點,也會以「臨時買賣合約」開始計起。 但若果購入房委會一手居屋,由於買家在售樓處揀樓時沒有簽署協議,而是在入伙時才辦理買樓法律手續,包括支付「印花稅」,所以其計算持貨的日期由入伙開始計起。要特別提出這點,因為現在普遍房委會的居屋樓花期較長,但實情其額印期限並非由揀樓開始計算,而是由入伙才開始計算。 今次谷友個案,他以500萬元在「居屋第二市場」出售物業,究竟500萬元是否屬於「市值價」? 應該直接用500萬元計算額印稅項,還是稅局會再釐訂一個「市值價」打稅呢? 我們曾向稅務局查詢,谷友可繼續用500萬元作為基準繳付「額外印花稅」,但收到稅項後,稅務局會再作評估,看看是否低於市價。如果認為已繳稅項不足,可能要求業主再補交稅項。