{"action":"created","comment":{"url":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/comments/48308009","id":48308009,"diff_hunk":"@@ -1,70 +1,106 @@\n-/*\n-1. Envolva todo o conteúdo desse desafio em uma IIFE.\n-2. Adicione a diretiva 'use strict';\n-3. Crie um arquivo index.html e adicione esse script à ele.\n-*/\n+(function() {\n+  /*\n+  1. Envolva todo o conteúdo desse desafio em uma IIFE.\n+  2. Adicione a diretiva 'use strict';\n+  3. Crie um arquivo index.html e adicione esse script à ele.\n+  */\n+  'use strict';\n \n-/*\n-Declare uma variável chamada `name` que receba seu primeiro nome.\n-Mostre no console todas as letras do seu nome separadas, com a frase:\n-- \"[LETRA] é a [POSIÇÃO]ª letra do meu nome.\"\n-Ex: no caso do nome ser \"Fernando\", deve mostrar as frases:\n-- \"F é a 1ª letra do meu nome.\"\n-- \"e é a 2ª letra do meu nome.\"\n-E assim por diante, até a última.\n-*/\n-console.log( 'As letras do seu nome:' );\n-// ?\n+  /*\n+  Declare uma variável chamada `name` que receba seu primeiro nome.\n+  Mostre no console todas as letras do seu nome separadas, com a frase:\n+  - \"[LETRA] é a [POSIÇÃO]ª letra do meu nome.\"\n+  Ex: no caso do nome ser \"Fernando\", deve mostrar as frases:\n+  - \"F é a 1ª letra do meu nome.\"\n+  - \"e é a 2ª letra do meu nome.\"\n+  E assim por diante, até a última.\n+  */\n+  console.log( 'As letras do seu nome:' );\n+  var name = 'Natan';\n \n-/*\n-- Declare uma variável chamada `fullName`, que receba seu nome completo,\n-escrito no formato de slug (caixa baixa e palavras separadas por um traço).\n-Ex: o nome \"Fernando Daciuk\" ficaria \"fernando-daciuk\"\n-- Faça a primeira letra de cada nome ficar em caixa alta, e troque o traço\n-por um espaço.\n-- Detalhe: o código que você escrever abaixo deve funcionar para qualquer\n-nome, então fique à vontade para usar as artimanhas que já viu até agora no\n-curso para fazer isso funcionar corretamente :)\n-- Mostre no console o nome no formato slug, e o resultado final. Use um\n-console.log para cada formato.\n-*/\n-console.log( '\\nNome convertido à partir de um slug:' );\n-// ?\n+  for( var index = 0; index < name.length; index++ ) {\n+    console.log( name[ index ] + ' é a ' + ( index + 1 ) + 'ª letra do meu nome.' );\n+  }\n \n-/*\n-- Crie um array com 5 nomes. Reduza esses nomes a uma única string, separando\n-cada nome por vírgula. Entre o penúltimo e o último nome, o separador deve\n-ser um \"e\". No final, concatene com a frase: \" são meus amigos.\".\n-O resultado final deve ficar mais ou menos assim:\n-- \"João, Maria, Roberto, Pedro e Marcos são meus amigos.\"\n-- Detalhe: o código abaixo deve funcionar com um array de qualquer tamanho.\n-5 nomes foi somente uma sugestão ;)\n-*/\n-console.log( '\\nMeus amigos:' );\n-// ?\n+  /*\n+  - Declare uma variável chamada `fullName`, que receba seu nome completo,\n+  escrito no formato de slug (caixa baixa e palavras separadas por um traço).\n+  Ex: o nome \"Fernando Daciuk\" ficaria \"fernando-daciuk\"\n+  - Faça a primeira letra de cada nome ficar em caixa alta, e troque o traço\n+  por um espaço.\n+  - Detalhe: o código que você escrever abaixo deve funcionar para qualquer\n+  nome, então fique à vontade para usar as artimanhas que já viu até agora no\n+  curso para fazer isso funcionar corretamente :)\n+  - Mostre no console o nome no formato slug, e o resultado final. Use um\n+  console.log para cada formato.\n+  */\n+  console.log( '\\nNome convertido à partir de um slug:' );\n+  var fullName = 'natan-siqueira-alves';\n+  var fullNameResult = '';\n \n-/*\n-Usando o replace(), faça a string \"Roberto\" virar \"Roberta\".\n-Mostre o resultado no console.\n-*/\n-console.log( '\\nEra \"Roberto\", agora é:' );\n-// ?\n+  for( var i = 0; i < fullName.split( '-' ).length; i++ ) {\n+    fullNameResult += fullName.split( '-' )[ i ].charAt( 0 ).toUpperCase() + fullName.split( '-' )[ i ].substring(1) + ' ';","path":"challenge-16/challenge-16.js","position":89,"original_position":89,"commit_id":"b19f2b946d04e4859fa2e693906adcdc9da61552","original_commit_id":"b19f2b946d04e4859fa2e693906adcdc9da61552","user":{"login":"fdaciuk","id":487669,"avatar_url":"https://avatars.githubusercontent.com/u/487669?v=3","gravatar_id":"","url":"https://api.github.com/users/fdaciuk","html_url":"https://github.com/fdaciuk","followers_url":"https://api.github.com/users/fdaciuk/followers","following_url":"https://api.github.com/users/fdaciuk/following{/other_user}","gists_url":"https://api.github.com/users/fdaciuk/gists{/gist_id}","starred_url":"https://api.github.com/users/fdaciuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fdaciuk/subscriptions","organizations_url":"https://api.github.com/users/fdaciuk/orgs","repos_url":"https://api.github.com/users/fdaciuk/repos","events_url":"https://api.github.com/users/fdaciuk/events{/privacy}","received_events_url":"https://api.github.com/users/fdaciuk/received_events","type":"User","site_admin":false},"body":"-1\r\nO seu exemplo funciona! Mas usando dessa forma, você estará \"gastando\" mais memória quando a sua aplicação for acessada. Por que?\r\n\r\nLembre-se que, a cada novo objeto criado, é separado um espaço na memória para esse objeto. Quando você o `split`, você não modifica o valor da variável `fullName`, mas cria um novo array.\r\n\r\nComo você está fazendo `fullName.split( '-' )` 3 vezes, você está colocando o mesmo valor em 3 espaços diferentes da memória, sendo que você poderia utilizar somente 1, atribuindo esse array à uma variável :)\r\n\r\nE já que você está utilizando um array, você consegue utilizar, por exemplo, o método `map` para gerar os nomes, ao invés de utilizar o `for`. \r\n\r\nSão algumas variáveis a menos que você cria, e ainda deixa seu código mais legível :)","created_at":"2015-12-22T22:56:30Z","updated_at":"2015-12-22T22:56:30Z","html_url":"https://github.com/da2k/curso-javascript-ninja/pull/479#discussion_r48308009","pull_request_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/479","_links":{"self":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/comments/48308009"},"html":{"href":"https://github.com/da2k/curso-javascript-ninja/pull/479#discussion_r48308009"},"pull_request":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/479"}}},"pull_request":{"url":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/479","id":51413303,"html_url":"https://github.com/da2k/curso-javascript-ninja/pull/479","diff_url":"https://github.com/da2k/curso-javascript-ninja/pull/479.diff","patch_url":"https://github.com/da2k/curso-javascript-ninja/pull/479.patch","issue_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/issues/479","number":479,"state":"open","locked":false,"title":"Challenge 16","user":{"login":"zalvesnatan","id":10634665,"avatar_url":"https://avatars.githubusercontent.com/u/10634665?v=3","gravatar_id":"","url":"https://api.github.com/users/zalvesnatan","html_url":"https://github.com/zalvesnatan","followers_url":"https://api.github.com/users/zalvesnatan/followers","following_url":"https://api.github.com/users/zalvesnatan/following{/other_user}","gists_url":"https://api.github.com/users/zalvesnatan/gists{/gist_id}","starred_url":"https://api.github.com/users/zalvesnatan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalvesnatan/subscriptions","organizations_url":"https://api.github.com/users/zalvesnatan/orgs","repos_url":"https://api.github.com/users/zalvesnatan/repos","events_url":"https://api.github.com/users/zalvesnatan/events{/privacy}","received_events_url":"https://api.github.com/users/zalvesnatan/received_events","type":"User","site_admin":false},"body":"@fdaciuk Challenge 16.","created_at":"2015-11-20T21:54:41Z","updated_at":"2015-12-22T22:56:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3c5a4d5fc41366f05a00ca96d79ebb0ab9fc9a7d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/479/commits","review_comments_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/479/comments","review_comment_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/comments{/number}","comments_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/issues/479/comments","statuses_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/statuses/b19f2b946d04e4859fa2e693906adcdc9da61552","head":{"label":"zalvesnatan:challenge-16","ref":"challenge-16","sha":"b19f2b946d04e4859fa2e693906adcdc9da61552","user":{"login":"zalvesnatan","id":10634665,"avatar_url":"https://avatars.githubusercontent.com/u/10634665?v=3","gravatar_id":"","url":"https://api.github.com/users/zalvesnatan","html_url":"https://github.com/zalvesnatan","followers_url":"https://api.github.com/users/zalvesnatan/followers","following_url":"https://api.github.com/users/zalvesnatan/following{/other_user}","gists_url":"https://api.github.com/users/zalvesnatan/gists{/gist_id}","starred_url":"https://api.github.com/users/zalvesnatan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalvesnatan/subscriptions","organizations_url":"https://api.github.com/users/zalvesnatan/orgs","repos_url":"https://api.github.com/users/zalvesnatan/repos","events_url":"https://api.github.com/users/zalvesnatan/events{/privacy}","received_events_url":"https://api.github.com/users/zalvesnatan/received_events","type":"User","site_admin":false},"repo":null},"base":{"label":"da2k:master","ref":"master","sha":"5bc3b7ef0710a871577faeed51a1f5c1d0d5806f","user":{"login":"da2k","id":11011075,"avatar_url":"https://avatars.githubusercontent.com/u/11011075?v=3","gravatar_id":"","url":"https://api.github.com/users/da2k","html_url":"https://github.com/da2k","followers_url":"https://api.github.com/users/da2k/followers","following_url":"https://api.github.com/users/da2k/following{/other_user}","gists_url":"https://api.github.com/users/da2k/gists{/gist_id}","starred_url":"https://api.github.com/users/da2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/da2k/subscriptions","organizations_url":"https://api.github.com/users/da2k/orgs","repos_url":"https://api.github.com/users/da2k/repos","events_url":"https://api.github.com/users/da2k/events{/privacy}","received_events_url":"https://api.github.com/users/da2k/received_events","type":"Organization","site_admin":false},"repo":{"id":30896610,"name":"curso-javascript-ninja","full_name":"da2k/curso-javascript-ninja","owner":{"login":"da2k","id":11011075,"avatar_url":"https://avatars.githubusercontent.com/u/11011075?v=3","gravatar_id":"","url":"https://api.github.com/users/da2k","html_url":"https://github.com/da2k","followers_url":"https://api.github.com/users/da2k/followers","following_url":"https://api.github.com/users/da2k/following{/other_user}","gists_url":"https://api.github.com/users/da2k/gists{/gist_id}","starred_url":"https://api.github.com/users/da2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/da2k/subscriptions","organizations_url":"https://api.github.com/users/da2k/orgs","repos_url":"https://api.github.com/users/da2k/repos","events_url":"https://api.github.com/users/da2k/events{/privacy}","received_events_url":"https://api.github.com/users/da2k/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/da2k/curso-javascript-ninja","description":"Curso Javascript Ninja","fork":false,"url":"https://api.github.com/repos/da2k/curso-javascript-ninja","forks_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/forks","keys_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/keys{/key_id}","collaborators_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/teams","hooks_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/hooks","issue_events_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/issues/events{/number}","events_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/events","assignees_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/assignees{/user}","branches_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/branches{/branch}","tags_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/tags","blobs_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/git/refs{/sha}","trees_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/git/trees{/sha}","statuses_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/statuses/{sha}","languages_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/languages","stargazers_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/stargazers","contributors_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/contributors","subscribers_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/subscribers","subscription_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/subscription","commits_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/commits{/sha}","git_commits_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/git/commits{/sha}","comments_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/comments{/number}","issue_comment_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/issues/comments{/number}","contents_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/contents/{+path}","compare_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/compare/{base}...{head}","merges_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/merges","archive_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/downloads","issues_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/issues{/number}","pulls_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls{/number}","milestones_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/milestones{/number}","notifications_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/labels{/name}","releases_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/releases{/id}","created_at":"2015-02-17T00:57:58Z","updated_at":"2015-12-15T12:13:05Z","pushed_at":"2015-12-21T10:44:32Z","git_url":"git://github.com/da2k/curso-javascript-ninja.git","ssh_url":"git@github.com:da2k/curso-javascript-ninja.git","clone_url":"https://github.com/da2k/curso-javascript-ninja.git","svn_url":"https://github.com/da2k/curso-javascript-ninja","homepage":"http://blog.da2k.com.br/curso-javascript-ninja/","size":3120,"stargazers_count":55,"watchers_count":55,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":59,"mirror_url":null,"open_issues_count":114,"forks":59,"open_issues":114,"watchers":55,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/479"},"html":{"href":"https://github.com/da2k/curso-javascript-ninja/pull/479"},"issue":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/issues/479"},"comments":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/issues/479/comments"},"review_comments":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/479/comments"},"review_comment":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/479/commits"},"statuses":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/statuses/b19f2b946d04e4859fa2e693906adcdc9da61552"}}}}